Skip to main content

gwalk 是一系列用于管理 Git 仓库的命令行小工具,帮助开发者对大批量的 Git 仓库进行日常维护。

Project description

gwalk

gwalk 是一系列用于管理 Git 仓库的命令行小工具,帮助开发者对大批量的 Git 仓库进行日常维护。

安装

1. pip

  1. python -m pip install pygwalk

2. build from source

  1. git clone https://github.com/ZeroKwok/gwalk.git
  2. cd gwalk
  3. python -m pip install .

使用

1. gl

gl.pygit fetch 以及 git pull 操作的快捷工具。

# 从远程仓库拉取代码并合并到当前分支, 等价于下面的命令 
# 1. git fetch {all remotes}
# 2. git pull {origin 或 第一个remotes} {当前分支}
gl

# git fetch and git pull {origin 或 第一个remotes} {当前分支} --rebase
gl --rebase

# git pull {origin 或 第一个remotes}
gl -q

2. gcp

gcp.py 是用于执行 git commitgit push 操作快捷工具。

# 添加未跟踪的文件以及已修改的文件,并提交到远程仓库, 等价于下面的命令 
# git add -u && git commit -m "fix some bugs" && git push
gcp "fix some bugs"

# 仅推送当前分支到所有远程仓库,不进行提交
gcp -p

3. gwalk

gwalk.pygwalk 工具的主要组件,提供了以下功能:

  • 列出目录下的所有 Git 仓库,支持过滤条件、黑名单、白名单和目录递归。
  • 显示列出的仓库的状态信息,支持输出信息的简短或冗长格式。
  • 在每个列出的仓库中执行一个操作。如运行自定义命令: 类似于子仓库操作 git submodule foreach 'some command' 但更加灵活。
# 列出当前目录下所有的'脏'的 Git 仓库
gwalk

# 递归列出当前目录下所有的 Git 仓库
gwalk -rf all

# 在列出的每个仓库中执行命令: git pull origin
gwalk -rf all -a "run git pull origin"

4. gapply

gapply.py 应用补丁文件并使用补丁中携带的信息创建提交。

# 应用单个补丁文件
gapply fix-bug.patch

# 批量应用多个补丁
gapply patches/*.patch

# 应用带编号前缀的补丁(自动去除编号前缀作为提交信息)
gapply 001-feature.patch

# 使用详细输出模式应用补丁
gapply -v *.patch

使用技巧

# 在所有 gwalk 列出的仓库中, 执行 gl 工具(git pull)
gwalk -rf all -a run gl

# 在所有 gwalk 列出的仓库中, 执行 git push 操作 {ab} 表示 当前分支(ActiveBranch)
gwalk -rf all -a run git push second {ab}

# 批量手动处理(交互模式)
# 在列出的所有 '包含未提交的修改' 的仓库中, 启动一个 bash shell 来接受用户的操作
gwalk -rf modified --a bash

# 批量推送
# 在列出的所有 '包含未提交的修改 且 不再黑名单中' 的仓库中, 运行 gcp 工具, 推送当前分支到所有远程仓库
gwalk -rf modified --blacklist gwalk.blacklist --a "gcp -p"

# 批量打标签
# 在列出的所有 白名单 gwalk.whitelist 匹配的仓库中, 运行 git tag v1.5.0
gwalk -rf all --whitelist gwalk.whitelist -a run git tag v1.5.0

# 批量查看目录下所有仓库的最近3次提交
gwalk -f all -l none -a run "git log --oneline -n3"

# 批量替换 origin 远程仓库的地址, 从 github.com 替换成 gitee.com
# 在所有 gwalk 列出的仓库中, 执行自定义命令
gwalk -rf all -a run git remote set-url origin `echo \`git remote get-url origin\` | python -c "print(input().replace('github.com', 'gitee.com'))"`

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygwalk-0.2.2b1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygwalk-0.2.2b1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file pygwalk-0.2.2b1.tar.gz.

File metadata

  • Download URL: pygwalk-0.2.2b1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for pygwalk-0.2.2b1.tar.gz
Algorithm Hash digest
SHA256 4dd2b3494ef5487826780d4e2eec5bdaea7c19c4796cb873df1ed1e3053a072b
MD5 973a197ef60ebf224e6d367adaebe9ea
BLAKE2b-256 e40ae495f07946b970e84165ffb319938ecbf313df2806d3facd7cb3e087009e

See more details on using hashes here.

File details

Details for the file pygwalk-0.2.2b1-py3-none-any.whl.

File metadata

  • Download URL: pygwalk-0.2.2b1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for pygwalk-0.2.2b1-py3-none-any.whl
Algorithm Hash digest
SHA256 bf83e00299f845dd09b1e3ce1b4db3d0b3a6688927a9b81a03c3afcd4f941687
MD5 4b07485016c5ae149ccdb39b5c487ea2
BLAKE2b-256 87e2927fbe86a489a474f22b07b29fe13a22fe3b6163b9de965b13bb608ab7dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page