bgreenlee / sublime-github

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

Allow users to customize the opened url #83

Closed pcg79 closed 9 years ago

pcg79 commented 9 years ago

While the hostname of the URL is pulled from the git ls-remote command, the protocol is hardcoded to "https" and the remote used is hardcoded to nothing (which defaults to origin). This allows customizing both of those if the github host (say, an Enterprise installation) is using a different protocol and if you don't want to show origin but a different branch.

My specific example is that my company's GitHub Enterprise installation is over "http" (with 443 turned off). Additionally I usually want to show my coworkers the files on our main repo, not my fork of it. So I have the settings as:

        "LivingSocial": {
            "base_uri": "http://code.livingsocial.net",
            "protocol": "http",
            "remote": "upstream"
        }

Please understand that Python isn't my native tongue so if I've messed up syntax, I apologize and am open to comments. Additionally, I don't use too many other commands on this plugin so I don't know if I've broken anything else and I didn't see any tests.

bgreenlee commented 9 years ago

Thanks! This looks good at first glance, although I think remote should be repo-specific. I realize there's no way yet to have a repo-specific setting, but it might be worth adding one. I can probably just merge your PR in the meantime, then add that myself (unless you feel up to it).

pcg79 commented 9 years ago

I can see repo-specific making more sense. Perhaps that can override account settings?

How would the repo work? Parse the results of git ls-remote --url? SO answers say to use git rev-parse --show-toplevel but from personal experience I can say that directory doesn't always match repo.

pcg79 commented 9 years ago

Anything more you want on this one?

bgreenlee commented 9 years ago

Gah, sorry, work and life have gotten in the way of me looking at this. I will look at it soon, I promise.

pcg79 commented 9 years ago

Nah, don't be sorry. I just wanted to make sure what else I can do.

bgreenlee commented 9 years ago

Merged. Sorry that took so long.

Also, I figured I'd hold off on doing any more work on it until the need arose.

pcg79 commented 9 years ago

No problem. If you come up w/ a decent solution to how to get the current repo, I'd love to hear it.

And thanks for merging this and the whole repo in general. I use it all the time.