Skip to content

Commit

Permalink
Merge pull request #1530 from zregvart/pr/git-tracker-cleanup
Browse files Browse the repository at this point in the history
Correctly compute the diff patch for git tracker
  • Loading branch information
zregvart authored Apr 18, 2024
2 parents af07c33 + 5226d57 commit 6e4f078
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/tracker/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,15 @@ outer:
// a merge commit is a valid commit id for a change on the path we want
// to filter out the merge commits as the default UIs in GitHub
// (GitLab?) do not show the merge commits in the file history views
to, err := c.Parent(0)
parent, err := c.Parent(0)
if err != nil {
return "", err
}
// we get commits that didn't change the path, so filter to only
// those that did
p, _ := c.Patch(to)
p, _ := parent.Patch(c)
for _, f := range p.FilePatches() {
// go-git seems to have reversed from and to, so this differs
// from what is documented there, see:
// https://github.com/go-git/go-git/discussions/1061
to, from := f.Files()
from, to := f.Files()
if (from != nil && to != nil && from.Path() == path) || (to != nil && to.Path() == path) {
// the first commit that did change the file is the latest
// for that file
Expand Down

0 comments on commit 6e4f078

Please sign in to comment.