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

Automatically change branch name if it already exists #108

Open
DanielVandH opened this issue Oct 1, 2023 · 4 comments
Open

Automatically change branch name if it already exists #108

DanielVandH opened this issue Oct 1, 2023 · 4 comments
Labels

Comments

@DanielVandH
Copy link
Contributor

I had made a PR to someones repo with this tool, and then had to follow up with another PR to include some other file types. Unfortunately, after going through all the corrections it then told me that the branch already exists:

Are you sure you want to create a pull request with these corrections? y, n, h: y
Creating a new branch "fix-typos"...
Error: Error: Command failed: git --work-tree="C:\Users\User\.github-spellcheck\DanielVandH\Manopt.jl" --git-dir="C:\Users\User\.github-spellcheck\DanielVandH\Manopt.jl\.git" branch fix-typos ba8d5cffafdbd65a5f81b72ab40240bec1624a04
fatal: a branch named 'fix-typos' already exists

Exiting...

so I then had to go and do the entire thing again (and again after I didn't realise I should've deleted the branch in the github-spellcheck repo rather than my fork of Manopt.jl, but that's on me).

Would it be a good idea to make the branch name change by default if fix-typos already exists (or, if not, check for the existence of this branch first before any work is done) and, if it does, use e.g. fix-typos-2? (and if fix-typos-n exists, sue fix-typos-n+1.) I'd make a PR to address this myself but I don't know any JavaScript to read any of the code.

@tbroadley tbroadley added the bug label Oct 1, 2023
@tbroadley
Copy link
Owner

tbroadley commented Oct 1, 2023

Thank you for pointing this out, Daniel! Sorry for the annoyance. I do think it'd be a good idea for the tool to detect if the fix-typos branch already exists on the remote repo and pick a different name in this situation. I can't promise I'll put up a fix for this soon, though, to be honest.

@DanielVandH
Copy link
Contributor Author

No worries at all. Would you accept a PR giving a warning about this? e.g. I wrote about this tool here for using it for some Julia packages, and I gave this warning:

WARNING: After you use this tool once for a repository, if you try and use it again for the same repository it will error at the end due to this issue, and you will lose all the changes you have made with no way to recover them. To allow yourself to use the tool again for the same repository, you need to go to ~/.github-spellcheck/UserName/ and delete the folder corresponding to the package. For example, after running the examples below, I then manually delete the folder C:\Users\User.github-spellcheck\DanielVandH\NaturalNeighbours.jl. You also want to delete the branch corresponding to the created pull request (as the GitHub pull request will prompt you to do after the pull request has been merged).

Maybe a more concise version of this warning somewhere in this repo could be appropriate.

@tbroadley
Copy link
Owner

Sure, I would accept such a PR! Thank you for the suggestion.

@tbroadley
Copy link
Owner

Also, thank you for writing about this tool! That's cool to see.

tbroadley added a commit that referenced this issue Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants