Calculate changes
To calculate total changes, you can essentially go through all branches named XYZ, get the changes, and add them together. What you need is
- Branch prefix
- Base branch name
- Files to exclude if any
git for-each-ref --format="%(refname:short)" refs/heads | \
grep '$branch_prefix' | `# only get branches from ticket XYZ` \
while read -r line; do
git log \
--numstat --pretty=format:"" `# get addition, deletion, filename` \
"$(git merge-base $line $base_branch_name)..$line" `# from base to tip` \
-- . ':(exclude)excluded/dir/*' `# excluded directories/files` | \
done | \
awk '(files = files + 1) (add = add + $1) (del = del + $2) { } END { print files " " add " " del }' `# add all data`
References
- https://www.baeldung.com/linux/add-column-of-numbers
- https://stackoverflow.com/questions/46195495/how-to-skip-specific-files-while-calculating-lines-of-code
- https://stackoverflow.com/questions/1549146/git-find-the-most-recent-common-ancestor-of-two-branches
- https://git-scm.com/docs/git-for-each-ref
- https://git-scm.com/docs/pretty-formats
- https://stackoverflow.com/questions/1265040/how-to-count-total-lines-changed-by-a-specific-author-in-a-git-repository
- https://stackoverflow.com/questions/5685007/making-git-log-ignore-changes-for-certain-paths
- https://stackoverflow.com/questions/2528111/how-can-i-calculate-the-number-of-lines-changed-between-two-commits-in-git
Last modified: 202407110435