gue*_*tli 8 python git gitpython
我使用库gitpython
如果本地git位于签出的标记上,我想获取标记的名称.
repo=git.Repo(repo_dir)
repo.tag # --> tags. But which is the current?
Run Code Online (Sandbox Code Playgroud)
在命令行上,git工具知道它.例
user@host> git status
HEAD detached at release/1.2.3
Run Code Online (Sandbox Code Playgroud)
我想通过gitpython获取字符串"release/1.2.3".
您可以遍历标记并将每个标记提交与当前头部提交进行比较:
next((tag for tag in repo.tags if tag.commit == repo.head.commit), None)
Run Code Online (Sandbox Code Playgroud)
看起来你可以通过GitCmd调用得到你想要的东西describe.
g = Git(git_dir)
rval = g.describe()
Run Code Online (Sandbox Code Playgroud)
我没有看到任何直接访问此信息的方法.
| 归档时间: |
|
| 查看次数: |
3663 次 |
| 最近记录: |