jacogr / atom-git-control

Not maintained :(
MIT License
227 stars 70 forks source link

Push command crashes when branch name has slashes #139

Closed rogeriotaques closed 8 years ago

rogeriotaques commented 8 years ago

Whenever a branch is named using slashes, such as "bugfix/something", "hotfix/something" or "whatever/something", the push command is crashing, cause the wrong branch name is been passed to the command line.

I found the problem on lib/dialogs/push-dialog.coffee at line 38, where the following code is being used:

branch = @toBranch.val().split('/')[1]

What happen here is, whenever we have a branch name with slashes, this line just returns the second part of name (on segment 1) and ignores all the following segments. But the worst part, is that it uses the remote branch as base, instead of my current local branch.

So, if we're working on a local branch, but don't have the same branch published on remote server yet, we will get an error or, will push to a different branch from local to remote.

Then, in order to fix that, I suggest replace line 38 from lib/dialogs/push-dialog.coffee by the following:

branch = git.getLocalBranch()

Also, I suggest you to add a new option for "To branch" field of "Push Dialog" as follows:

# add simple origin branch
@toBranch.append "<option value='origin'>origin</option>"
for remote in remotes
   ...

It makes simple for user to understand that he is going to push its code from local branch to (simply) origin, (same as executing git push origin some-branch), which works perfectly when we have a local branch that wasn't published on remote yet.

And also offers user the option to select any remote branch, which actually will just ignore branches full named and use "origin", as we can see on (original) line 37, as follows:

remote = @toBranch.val().split('/')[0]

Just in case, I'm forking your project and making a pull-request with my suggestions.

rogeriotaques commented 8 years ago

As it is fixed by the merge https://github.com/jacogr/atom-git-control/pull/143, let me close this ticket. Thank you.