Skip to content
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

Remove file from PR #1901

Closed
zephraph opened this issue Apr 1, 2019 · 9 comments · Fixed by #2182
Closed

Remove file from PR #1901

zephraph opened this issue Apr 1, 2019 · 9 comments · Fixed by #2182
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted

Comments

@zephraph
Copy link

zephraph commented Apr 1, 2019

Issuehunt badges

Basically a duplicate of #1127.

Sometimes in a PR file changes slip in that you didn't intend. Maybe you didn't correctly stash, a commit hook made a formatting change, or some other thing happened.

The ultimate result is that you want to undo changes to a particular file in your PR. It'd be nice to have a button on the header of every file in the diff to revert that change.

Something like this...

image

It seems like this was added in #1398, but it's no longer present or working now. At least not in the FF version of the plugin. GitHub added the trashcan icon to actually delete a file... heh, I almost did that >_>.


IssueHunt Summary

fregante fregante has been rewarded.

Backers (Total: $80.00)

Submitted pull Requests


Tips


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

@fregante
Copy link
Member

fregante commented Apr 1, 2019

They’re different.

“Delete file” fully deletes the files, it’s a feature that was added by GitHub.

“Revert all changes in file” is a feature that would indeed be nice to have, arguably this is the only button PRs need 👍

@fregante fregante changed the title Add (or restore) button to remove file from PR Remove file from PR Apr 1, 2019
@hardikmodha
Copy link
Contributor

@bfred-it I would be more than happy to contribute to this. Can you point me towards the starting point? Thanks!

@fregante
Copy link
Member

fregante commented Apr 2, 2019

Honestly I don’t know if there’s an easy way to do this, you’d have to look the API for reverting

@zephraph
Copy link
Author

zephraph commented Apr 2, 2019

Yeahhh... I was looking into this. It's definitely non-trivial.

I think the easiest way to is to follow this path:

  1. Get the base branch of the PR
  2. Use the contents api to grab the base version of the file
  3. Use the contents api to create a new commit of the file as it was at its original state.

@fregante
Copy link
Member

fregante commented Apr 3, 2019

  1. Not the base branch, but the parent commit of the first commit in the PR. The base branch might have changed.
  2. Maybe you can skip this step if you can just checkout the file like you can in git: https://stackoverflow.com/questions/215718/reset-or-revert-a-specific-file-to-a-specific-revision-using-git

@zephraph
Copy link
Author

zephraph commented Apr 3, 2019

GitHub's api doesn't really expose higher level git actions like checkout. We could use the commit api to try to replicate this process, but I'm not sure how to go about doing that.

@fregante
Copy link
Member

fregante commented Apr 4, 2019

The correct API seems to be Contents API

https://developer.github.com/v3/repos/contents/#update-a-file

Use it for steps 2 and 3

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label Jun 24, 2019
@issuehunt-oss
Copy link

issuehunt-oss bot commented Jun 24, 2019

@issuehunt has funded $80.00 to this issue.


@fregante fregante self-assigned this Jun 24, 2019
@fregante fregante mentioned this issue Jun 27, 2019
13 tasks
@fregante fregante removed their assignment Jun 27, 2019
@issuehunt-oss
Copy link

issuehunt-oss bot commented Aug 11, 2019

@sindresorhus has rewarded $72.00 to @fregante. See it on IssueHunt

  • 💰 Total deposit: $80.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $8.00

@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted
3 participants