-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fallback to git diff command #1714
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
It's cool and interesting idea to get merge-base commit with GitHub API.
This looks great! |
} | ||
} | ||
|
||
for _, sha := range []string{mergeBaseSha, headSha} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to fetch headSha
?
It didn't work without fetching it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/reviewdog/reviewdog/actions/runs/8746978073/job/24004712656?pr=1717 ( a5a03bd )
reviewdog: fail to get diff: failed to run git diff: exit status 128
It look like the above if I don't fetch the head sha.
This is probably because actions/checkout
only gets
the commit that merged base ref into head ref by default.
https://github.com/reviewdog/reviewdog/actions/runs/8746978073/job/24004712656?pr=1717 ( a5a03bd )
/usr/bin/git checkout --progress --force refs/remotes/pull/1717/merge
...
HEAD is now at f62528f Merge a5a03bda8166923b674c24eab300385361b41225 into e34989bf40a5fa7aa4cf5d9f45f3f2e5d1edd3c9
/usr/bin/git log -1 --format='%H'
'f62528f5a35c3964b6441798dae6f9081d8773d7'
In the above example, a5a03bd is head sha, e34989b is base sha and f62528f is merged commit sha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good idea to get the head sha using /usr/bin/git log -1 --format='%H'
instead of GitHub API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thank you for the investigation and explanation!
I'm fine with leaving it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💯
} | ||
} | ||
|
||
for _, sha := range []string{mergeBaseSha, headSha} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thank you for the investigation and explanation!
I'm fine with leaving it as is.
Fix #1696
I fix the fallback to git diff command as follows:
git fetch
command to get merge base and head commits