简化本地开发的git/tox方便包装器

workspace-tools的Python项目详细描述


工作区工具

通过无缝集成git和tox简化使用多个Python存储库的工具, 在这里,您可以简单地运行一个命令,而不是单独运行多个本机命令来执行常见任务

它主要是在现有工具之上的包装器,最终目的是提供一个简单的、无缝的、 在使用一个或多个存储库时,重复性更少。功能支持主要是 仅限于作者目前使用的工具,它首先是一个个人工具,用于增强 作者自己的生产力,但分享它作为其他人可能会发现它有用。

概述

  • 一个无缝管理/集成所有工作区工具的工具,从安装到发布。
  • 简化了通用工作流的命令执行-只需运行一个命令,而不是许多单独的本机命令。
  • 命令执行也是智能的/优化的-例如,测试命令自动检测需求更改以重新开发。
  • 跨所有签出运行的路径感知上下文命令-例如,有关所有repo,请参阅status/diff。
  • 通过轻松地将依赖项更新到最新版本,充分利用其他产品
  • 用于快速设置新产品的模板
  • 支持具有子/父关系的多个分支
  • 酷和明智的快捷方式别名,帮助你做更多的打字更少-你会喜欢“电视”[如果你知道AG]!

快速入门教程

首先,安装时使用:

sudo pip3 install autopip
app install workspace-tools

第二,可以选择使用bash函数/别名设置环境:

$cd ~/workspace
$ wst setup --commands-with-aliases

[INFO] Added "ws" bash function with workspace directory set to ~/workspace
[INFO] Added bash functions: bump, checkout, clean, commit, log, publish, push, status, test, update
[INFO] Added aliases: co=checkout, ci=commit, di=diff, st=status, up=update
[INFO] Added special aliases: a='activate', d='deactivate',
       tv='open_files_from_last_command'  # from ag/ack/grep/find/which [t]o [v]im
[INFO] To use, run "source ~/.wstrc" or open a new shell.

$source ~/.wstrc

然后看看工作区工具的强大功能:

$ ws
# Runs `cd ~/workspace && ls`aiohttp-requests               localconfig              python-examples
ansible-hostmanager            pytest-fixtures          utils-core
...

$cd localconfig
# Use your favorite editor to make some changes
$ ci -tp 'This adds/commits all files, runs style check/tests with coverage, and then pushes to all remotes!'Checking style
Running tests
...........................
----------- coverage: platform linux, python 3.6.5-final-0 -----------
Name                      Stmts   Miss  Cover
---------------------------------------------
localconfig/__init__.py       2      0   100%
localconfig/manager.py      215     14    93%
localconfig/utils.py         20      0   100%
---------------------------------------------
TOTAL                       237     14    94%
Required test coverage of 80% reached. Total coverage: 81.90%
==================  22 passed in 0.82 seconds  =======================
cover: OK
style: OK
[master d5f6e6b] This adds/commits all files, runs style check/tests with coverage, ...
 1 file changed, 78 insertions(+), 38 deletions(-)
Pushing master

剩下的教程将假设wst setup-a不是为了清晰起见而运行的,尽管setup是 建议使用,因为提供了许多有用的别名。

要签出回购协议:

$ wst checkout maxzheng/workspace-tools       # Exact match from Github
$ wst checkout requests                       # Best match from Github
$ wst checkout https://github.com/maxzheng/aiohttp-requests.git

要同时更新工作区中的所有回购协议,请执行以下操作:

$ wst update

Updating aiohttp-requests
Updating ansible-hostmanager
...

提交并为其创建新分支:

$cd workspace-tools
# vi README.rst and make some changes
$ wst commit "Updated README.rst"
[updated-readme@master 0af8850] Updated README.rst
 1 file changed, 1 deletion(-)

# The commit created the branch 'updated-readme@master', added all files, and then committed change.
# Notice the "@master" that indicates the parent branch. The parent branch will be used
# during push with --merge and when updating the branch (updates parent and rebases branch on top).
# To create a branch without parent relationship, use --branch option with any name that you like.

安装测试环境并运行所有测试(通过tox/pytest):

$ wst test...
cover: OK
style: OK

# To setup a new project with tox test, cover, and style environments:
$cd new-product
$ wst setup --product
# To check style or generate coverage report:
$ wst test style
$ wst test cover
# To run a specific test only:
$ wst test -k test_filter

要查看单个回购或所有回购的状态:

$ wst status
# Branches: updated-readme@master master
$cd ..
$ wst status

[ bumper-lib ]
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   src/bumper/cars.py

no changes added to commit (use "git add" and/or "git commit -a")

[ clicast ]
# Branches: master display-changes@master fix-download@master

[ workspace-tools ]
# Branches: updated-readme@master master

修改更改并推动:

$cd workspace-tools
# vi README.rst and make more changes
$ wst commit --amend --push

[updated-readme@master 738f659] Updated README.rst
1 file changed, 2 insertions(+), 1 deletion(-)
Pushing updated-readme@master

# It will fail at push as you are not a committer, but the change was committed to branch,
# and then merged into its parent branch (master).

或者只需在您当前的分支中推动更改:

$ wst push --merge
# This will update its parent branch (master), rebase branch with parent branch and merge into
# parent branch if on child branch (child@parent) and then push.
# Upon success, it will remove the local and remote branch if pushing from child branch.

如果有多个上游分支(由~/.config/workspace.cfg中的merge config定义)需要合并 更改为,使用自动合并:

# Assuming you are currently on 3.2.x branch and have these branches: 3.3.x, master
$ wst merge --all

[INFO] Merging 3.2.x into 3.3.x
[INFO] Pushing 3.3.x
[INFO] Merging 3.3.x into master
[INFO] Pushing master

如果您已锁定依赖项要求并希望更新到最新版本:

$ wst bump

[INFO] Updating workspace-tools
[INFO] Checking bumper-lib
...
[INFO] Checking requests
[bump ac06160] Require remoteconfig==0.2.4, requests==2.6.0
 1 file changed, 2 insertions(+), 2 deletions(-)

# To bump to a specific version (why not just vi? This validates the version for you and pulls in the changelog)$ wst bump requests==2.5.1

要提升版本,请更新changelog,然后发布到pypi:

$ publish
PyPI Password:
Updating master
Building source/built distribution
Uploading to PyPI
[master a58b001] Publish version 1.0.7
 2 files changed, 8 insertions(+), 2 deletions(-)
Pushing master

现在您可以自己尝试其他命令:

$ wst -h

usage: wst [-h] [-v] [--debug] <sub-command> ...

optional arguments:

  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --debug               Turn on debug mode

sub-commands:
  {bump,checkout,co,clean,commit,ci,diff,di,log,publish,push,setup,status,st,test,update,up}
                        List of sub-commands
    bump                Bump dependency versions in requirements.txt,
                        pinned.txt, or any specified file.
    checkout (co)       Checkout products (repo urls) or revert files.
    clean               Clean workspace by removing build, dist, and .pyc
                        files
    commit (ci)         Commit all changes locally, including new files.
    diff (di)           Show diff on current product or all products in
                        workspace
    log                 Show commit logs
    merge               Merge changes from branch to current branch
    publish             Bumps version in setup.py (defaults to patch), writes
                        out changelog, builds a source distribution, and
                        uploads with twine.
    push                Push changes for branch
    setup               Optional (refer to setup --help). Setup workspace
                        environment. Run from primary workspace directory.
    status (st)         Show status on current product or all products in
                        workspace
    test                Run tests and manage test environments for product.
    update (up)         Update current product or all products in workspace

要配置wst,请参阅Configuration文档。


热门话题
java组织。冬眠hql。内部的阿斯特。QuerySyntaxException:<table\u name>未映射[来自<table\u name>]   异常无法有效使用来自Java的多捕获   java Hibernate Search是Lucene的干净抽象吗?   组织。xml。萨克斯。SAXException:没有针对的反序列化程序{http://www.w3.org/2001/XMLSchema}Java中使用Axis的anyType   java是独立于Eclipse平台的吗?   java PigLatin语句转换器方法给出了“indexoutofboundsexception”错误等   java Spring+Jackson+反序列化泛型对象列表   java获取firefox配置文件的配置文件当配置文件计数超过3(包括默认值)时,我没有选择给定的配置文件   java XPages应用程序无法运行   java为什么字符连接返回“int”和?   java如何以正确的方式从静态助手类中的异步方法返回值?   java如何将字符串值转换为整数数组列表   javajackcess表限制?   java如何使用SMACK API和GTALK发送消息?   java按钮显示在左上角,具有不同的外观和感觉