- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 git 中的日志信息获取到 python 中。我查看了 pygit2 和 gitpython,但似乎都没有提供类似于 git Shortlog 的高级接口(interface)。是否有一个 python 库提供了这样的接口(interface),或者我应该调用 git 可执行文件?
最佳答案
我假设您的意思是 pygit2
是您查看过的库之一。这是一个较低级别的库,可让您在此基础上编写一个较高级别的库(它已经足够高级了,获取基本日志输出的 3 行代码是否太多了?)。做你想做的事并不难 - 阅读relevant documentation你可以想出类似的东西:
>>> from pygit2 import Repository
>>> from pygit2 import GIT_SORT_TIME
>>> from pygit2 import GIT_SORT_REVERSE
>>> repo = Repository('/path/to/repo')
>>> rev = repo.revparse_single('HEAD').hex
>>> iterator = repo.walk(rev, GIT_SORT_TIME | GIT_SORT_REVERSE)
>>> results = [(commit.committer.name, commit.message.splitlines()[0])
... for commit in iterator]
>>> results
[(u'User', u'first commit.'), (u'User', u'demo file.'), ... (u'User', u'okay?')]
如果你想将输出分组为与 git Shortlog 相同,这也不难,你需要的所有数据都已经在迭代器中,所以只需使用它将数据放入您需要的格式。
关于python - 是否有 git Shortlog 的 python 接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29336832/
我有一个目录,里面有很多 Git repo 子目录,我想积累类似于 git shortlog -sne --no-merges 对于其中的所有 repo 协议(protocol),按用户的所有总提交对
在使用 Jenkins 时遇到一些连线问题, #!/bin/sh set -x #initialize environment export PATH="$HOME/.gem/ruby/2.0.0/b
当我尝试获取以下命令的输出时遇到问题:git shortlog -s -- [文件路径]使用 python 3.6 子进程模块。 这里是代码: import subprocess x = subpro
我正在尝试使用 Git 预提交 Hook 来运行一些样式检查并自动生成一个 AUTHORS 文件,该文件使用 git shortlog 提取所有贡献者的姓名。 我的预提交脚本包括以下内容: #!/bi
我正在尝试将 git 中的日志信息获取到 python 中。我查看了 pygit2 和 gitpython,但似乎都没有提供类似于 git Shortlog 的高级接口(interface)。是否有一
我试图通过这种方式在带有 nodejs 的存储库上获取 git shortlog 的结果: var exec = require('child_process').exec; exec("cd /tm
我试图从 Go 中调用 git shortlog 来获取输出,但我遇到了困难。 这是一个工作示例,说明我如何使用 git log 执行此操作: package main import ( "f
我的场景 在我的 Node 应用程序中,我使用 child_process.spawn从当前存储库查询信息 我构建了一个小函数来返回一个 promise ,该 promise 通过命令的响应来解析:
我想不通。为什么这些行为不同: (shell-command "git log") (shell-command "git shortlog") 第一个按预期工作:返回 0 并将内容打印到 shell
我是一名优秀的程序员,十分优秀!