Git:get changes released to master over time

156 Views Asked by At

as a personal project, I'd like to check different python libraries and projects (be it proprietary or open source) and analyze how the code was changed over time in different releases to gather some info about the technical debt (mainly through static code analysis). I'm doing this using gitpython library. However, I'm struggling to filter the merge commits to the master.

I filter the merge commits using git.log("--merges", "--first-parent", "master") from where I extract the commit hashes and filter these particular commits from all repository commits.

As the second part, I'd like to get all changed files in each merge commit. I'm able to access the blobs via git tree, but I don't know how to get only changed files.

Is there some efficient way how to accomplish this? Thanks!

1

There are 1 best solutions below

0
On

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

Once you have your commit list as you described above, loop over them and run the following:

git diff

Use the git diff with the --name-only flag

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.