python - Git:随着时间的推移,获取发布到 master 的更改

标签 python git gitpython technical-debt

作为一个个人项目,我想检查不同的 python 库和项目(无论是专有的还是开源的)并分析代码在不同版本中如何随着时间的推移而变化,以收集有关技术债务的一些信息(主要通过静态代码分析)。我正在使用 gitpython 库来执行此操作。但是,我正在努力过滤对 master 的 merge 提交。

我使用 git.log("--merges", "--first-parent", "master") 过滤 merge 提交,从中提取提交哈希值并过滤这些特定提交来自所有存储库提交。

作为第二部分,我想在每次 merge 提交中获取所有更改的文件。我可以通过 git 树访问 blob,但我不知道如何仅获取已更改的文件。

有什么有效的方法可以实现这一点吗?谢谢!

最佳答案

... I'd like to get all changed files in each merge commit. ... but I don't know how to get only changed files.

一旦你有了上面描述的提交列表,循环它们并运行以下命令:

git diff

git diff--name-only 标志一起使用

enter image description here

<小时/>

git diff

--name-only
Show only names of changed files.

--name-status
Show only the names and status of changed files. See the description of the --diff-filter option on what the status letters mean.

关于python - Git:随着时间的推移,获取发布到 master 的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53234954/

相关文章:

python - 如何使用 GitPython 获取提交中文件的源代码?

python如何附加到zip存档中的文件

python - 在 Django 模板中使用字典字典效果不佳

git - 在两个 Git 存储库之间同步单个文件

python - GitPython:获取尚未应用的远程提交列表

python - gitpython:git commit 的命令语法

python - 在 GDB python 接口(interface)下导入 wx 失败,R6034 : An application has made an attempt to load the C runtime library incorrectly

python - 如何将 PySpark Dataframe 转换为 R 可以在 DataBricks 中识别的内容?

git - 如何排除在执行 'git status' 命令时显示的不需要的文件夹内容

Git:将提交从一个仓库导入到另一个仓库