bgreenlee / sublime-github

Sublime Text 2/3 plugin that provides a number of useful commands for GitHub.
MIT License
455 stars 98 forks source link

Github commands fail if current branch has not been pushed to origin #85

Closed edmorley closed 8 years ago

edmorley commented 8 years ago

1) Clone a repo from Github 2) checkout -b my_feature_branch 3) Use one of the Github URL related commands (eg view history for a file), when a colleague asks for an unrelated link on IRC - and you've forgotten you're not on master.

Expected: If my_feature_branch isn't present on origin, then either... a) s/my_feature_branch/master/ in the generated URL b) show a warning and do nothing

(Or some combination of the above, with perhaps a prompt for the user, or the ability to set default behaviour in the prefs)

Actual: The generated URL 404s, since that branch does not exist yet on Github.

bgreenlee commented 8 years ago

Thanks for the report. I don't think (a) is the right behavior—it seems that could lead to confusion, particularly if your file has diverged from master. I will see if I can detect the situation and display an error.

edmorley commented 8 years ago

Yeah the file could possibly have diverged. The only problem is that 99% of the time, I'm not on master - so only showing an error would make much of sublime-github unusable to me. Quite often I'm working on very small changes on feature branches, so most of the time the files I'm looking up (which may or may not be related to the current feature branch) are the same on master - and when they aren't, the filename is the same, but perhaps the line numbers are out slightly.

I don't know what sublime lets you do, but ideally a prompt asking if you want to fall back to master (rather than just an error that does nothing), might be a reasonable compromise? I guess if the line numbers were dropped then much of the time the links would still be valid?

davidrunger commented 8 years ago

I agree with @bgreenlee that it might be a little confusing to have different behavior for the commands, depending upon whether the current branch is present on the remote or not. Might I suggest an alternative: add a few commands specifically dedicated to the master branch, such as GitHub: View on master and GitHub: Blame on master. For me, such a feature would be a major win.

bgreenlee commented 8 years ago

Good call, @davidrunger. X on master and X on current branch

Now if I can just find the time to work on it... :)

davidrunger commented 8 years ago

Maybe this can save you the time and trouble?

https://github.com/bgreenlee/sublime-github/pull/96

bgreenlee commented 8 years ago

My hero! Merged. Thanks!