You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
restore-file occasionally restores the wrong commit #4679
changed the title [-]`restore-file` is not compatible with force-pushed branches[/-][+]`restore-file` occasionally restores the wrong commit[/+]on Sep 4, 2021
Activity
[-]`restore-file` is not compatible with force-pushed branches[/-][+]`restore-file` occasionally restores the wrong commit[/+]fregante commentedon Sep 4, 2021
Maybe it's not even due to force pushes. There were no force pushes in npmhub/npmhub#141, but this "Restore" commit is incorrect:
7485182(#141)The issue specifically is that it "correctly" fetched the file from the base branch (
main), but GitHub still shows the file as a "change" in the PR (even though when merged nothing will actually change): https://github.com/npmhub/npmhub/pull/141/files#diff-719f723e7f36f1f0192a75b8750569dcb1319113ea7e038109894895d2ea7d74You can try restoring the same file multiple times but that's what you get.
In short, I think we should fetch the file not from the base branch but from the base commit.
I think the repro is:
Merge branch 'main' into fix/refined-github#4679
fregante commentedon May 12, 2023
"merge base" is what we're looking for: https://stackoverflow.com/q/1549146/288906
v3 seems to have
merge_base_commit, which is likely what we want: https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commitsIt seems that it also exists on v4 as
baseTarget, I'll try it{ repository(owner: "refined-github", name: "sandbox") { pullRequest(number: 68) { baseRefOid mergeable viewerCanEditFiles headRef { compare(headRef: "default-a") { status aheadBy baseTarget { oid } } } } } }Edit: no. Both
baseTargetandheadTargetjust show the latest commit on either branch, regardless of the comparison.