在不使用git命令的情况下,从github存储库中获取更改线
我的目标
我正在python中构建一个只能访问历史git diff补丁的Git Stats脚本,因此基本上文件 像这样
diff --git a/README b/README
index 980a0d5f..fef29374 100644
--- a/README
+++ b/README
@@ -1 +1,3 @@
Hello World!
+
+Hello planet! - DD
\ No newline at end of file
我到底想要什么?
- 将git diff文件的列表作为输入
- 计算计算更改了多少行(可选),在每个diff文件中添加和删除,
- 然后删除它所有的
- 打印“添加了总线= x,删除的总线路= y”等。
约束
运行的系统该脚本无法访问GIT存储库,也没有安装GIT-引入有趣的并发症。
通过Python访问API或编写代码以手动计算内容,我没有问题。我唯一的问题是我上面提到的。
存储库托管在GitHub上,允许使用GitHub特定设施。
我检查过的其他来源
,所以我知道有关此主题有许多类似的问题。我只是难以直接在存储库中找到我在Python中寻找的东西...
那么,有什么想法吗?我认为我只能手动解析每个差异文件并总结一下,但是我希望来自git魔术师的银色子弹!
The goal
I am building a git stats script in Python that can only access the historical git diff patches, so basically files like this
diff --git a/README b/README
index 980a0d5f..fef29374 100644
--- a/README
+++ b/README
@@ -1 +1,3 @@
Hello World!
+
+Hello planet! - DD
\ No newline at end of file
What do I want exactly?
- Take a list of git diff files as input
- Calculate how many lines were changed (optional), added and removed in each diff file
- Sum it all up
- Print "total lines added = X, total lines removed = Y" etc.
Constraints
The system running this script does not have access to the git repository, nor does it have git installed - introducing an interesting complication.
I have no issues with accessing the API through Python or writing code to manually calculate things. The only issue I have is what I mentioned above.
The repository is hosted on GitHub, and usage of GitHub-specific facilities is allowed.
Other sources
I checked, and so I know there were many similar questions on this topic. I'm just having trouble finding what I'm looking for in Python, without using git
in the repository directly... (happy to close this if someone can point me to a solution)
So then, any ideas? I assume I can just manually parse each of the diff files and sum it up, but I'm hoping for a silver bullet from a git magician!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,GitHub API已经提供了这些差异统计数据,而无需安装
git
在本地检查或存储库。github docs
由于这对我的情况已经足够好,所以我将使用它。不过,新答案仍然受到欢迎。
It turns out that GitHub API already offers these diff stats without the need to have
git
installed or repository checked out locally.GitHub Docs
Since this is good enough for my case, I'm going to use it. New answers are still welcome though.