sindresorhus/refined-github

Do you want to work on this issue?

You can request for a bounty in order to promote it!

`restore-file` occasionally restores the wrong commit #4679

fregante posted onGitHub

Please ensure:

  • The bug is caused by Refined GitHub. It doesn't happen if I disable the extension.

Description

Rare occurrence but:

  1. Create X branch from main
  2. Force-push main to something else
  3. Create PR from branch X

Now you'll have a PR with the changes that the force-push made.

  1. Click "Restore file" on one of the files in the PR

You'll notice that the feature "succeeds" but the commits are empty. This is a live example: 419c37c (#4677)

Example URL

https://github.com/sindresorhus/refined-github/pull/4677, before it was rebased

Browser(s) used

Safari


Maybe it's not even due to force pushes. There were no force pushes in https://github.com/npmhub/npmhub/pull/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-719f723e7f36f1f0192a75b8750569dcb1319113ea7e038109894895d2ea7d74

You 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:

  1. Create PR with file X
  2. Change the same file X from the PR directly on the base branch
  3. Restore file X in the PR
posted by fregante over 3 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests