Skip to content

Add revert-file feature - #2182

Merged
fregante merged 43 commits into
masterfrom
revert-file
Aug 10, 2019
Merged

fregante merged 43 commits into
masterfrom
revert-file

Conversation

@fregante

@fregante fregante commented Jun 27, 2019 •

Copy link
Copy Markdown
Member

Closes #1901

asdasd

Test

  • Works for text files
  • Avoids binary files
  • Deletes new files
  • Handle renamed files: Yes, but as 2 operations (delete new file, revert old)
  • Works for files in folders
  • Works for files with spaces
  • Works for initially-empty files
  • Works in repos without push access
  • Works when the base branch has changed the content of the same file
  • Works when the the PR contains merges or rebases
  • Works on private repos
  • Reverts file deletions
  • Works in Chrome and Firefox

IssueHunt Summary

Referenced issues

This pull request has been submitted to:


IssueHunt has been backed by the following sponsors. Become a sponsor

@fregante
fregante marked this pull request as ready for review June 27, 2019 15:26
@fregante

fregante commented Jun 27, 2019 •

Copy link
Copy Markdown
Member Author

This seems to work correctly, except it doesn't work on repos you don't have push rights to 😬 which sucks.

A workaround is to submit the changes through the form on the /edit/ page instead of the API.

Alternatives? Am I doing anything wrong in the API? The PUT requests receives a 404 when trying to revert the first file on https://github.com/sindresorhus/refined-github/pull/2146/files

Comment thread source/features/revert-file.tsx Resolved
@just-be-dev

just-be-dev commented Jun 28, 2019 •

Copy link
Copy Markdown

I'm gonna restate the problem just so I'm sure I really understand what's happening.

Scenarios when it works

  1. When you revert a file from a PR that's on a branch in the current repo and you have push access to the repo
  2. When you revert a file from a fork PR, but you have push access to the underlying fork

Scenarios when it fails

  1. When you try to revert when you don't have push access (expected)
  2. When you try to revert when you're granted upstream push access by the PR fork owner (for the scope of that PR), but you don't have push access to the whole fork repo. (unexpected)

The second failure case is what we're talking about, right? If so, I bet you've found a bug. If the edit form works, that's an option (as gross as it may be). I can't think of another way of doing it short of hooking in isomorphic-git and just doing a full blown commit.

@fregante

Copy link
Copy Markdown
Member Author

Yeah I think the bug here is that the API doesn’t follow the “Allow changes from maintainers” checkbox. We had this issue on other features.

Best case scenario is that someone already found a solution to this or I’m doing something wrong. Even if I report it to GitHub it’s not gonna be fixed for a while, I bet I’m not the first one to notice it.

isomorphic-git requires cloning the whole repo, we can’t do that for a one-off operation.

Comment thread source/features/revert-file.tsx Resolved
@just-be-dev

This comment has been minimized.

@fregante

Copy link
Copy Markdown
Member Author

If you haven't filed an issue yet, I'd still do it. This is enough of a corner case that I doubt many folks have encountered it.

I'm swamped at the moment, could you test and report that?

@fregante

fregante commented Jul 14, 2019 •

Copy link
Copy Markdown
Member Author

@fregante fregante changed the title Add revert-file feature (WIP, broken) Add revert-file feature Aug 1, 2019
@fregante fregante changed the title Add revert-file feature Add revert-file feature (WIP, broken in Firefox) Aug 1, 2019
@fregante fregante changed the title Add revert-file feature (WIP, broken in Firefox) Add revert-file feature Aug 1, 2019
@fregante
fregante requested a review from sindresorhus August 1, 2019 18:20
@fregante

This comment has been minimized.

@fregante

fregante commented Aug 10, 2019 •

Copy link
Copy Markdown
Member Author

I'm merging this

(The Reverted! state is only in the gif because it's not clear without it)

@fregante
fregante merged commit cf45c61 into master Aug 10, 2019
@fregante
fregante deleted the revert-file branch August 10, 2019 19:37
@fregante fregante mentioned this pull request Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Remove file from PR

3 participants