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

URL in path is assuming full folder path #82

Closed robisio closed 9 years ago

robisio commented 9 years ago

The plugin works great but when my GitHub url opens it is including my mac's user directory as well causing the URL to be malformed.

Plugin creates this: https://github.com/gdiindy/gdi-intro-js/blob/master/Users/rweis/sites/gdi-intro-js/lib/handson/handson.css#L12-L19

But the correct URL is: https://github.com/gdiindy/gdi-intro-js/blob/master/lib/handson/handson.css#L12-L19

It seems to be including the full folder path in the URL (/Users/rweis/sites/gdi-intro-js) which is where I cloned the repo to on my machine.

Is this a setting that I am missing?

bgreenlee commented 9 years ago

@robisio - Sorry for the slow response; I was on vacation.

How comfortable are you poking around in python? This is hard for me to troubleshoot without having access to your local repo. I just tried checking out that project and opening that same file and it worked fine for me. See https://github.com/bgreenlee/sublime-github/issues/80#issuecomment-87261418 for an explanation of how the path is created.

Alternatively, if you send me the output of the git commands listed in that comment above, I can try to figure out what's going on.

markschwarz commented 9 years ago

I'm having the same issue on Windows. I see 404 pages in my browser: "Github: Open Remote URL in Browser": Expected browser URL: https://github.com/A/B/blob/develop/C/D/E/F/G/file.sql#L158

Actual browser URL: https://github.com/A/B/blob/developC:/localpath/B/C/D/E/F/G/file.sql

Notice the C:\localpath is included.

markschwarz commented 9 years ago

Another example from a public repo owned by someone else, rather than one owned by my account or my company's.

Github: Open File: Expected: https://github.com/eczarny/spectacle/blob/master/Spectacle/Resources/Property%20Lists/HotKeyNames.plist Actual: https://github.com/eczarny/spectacle/blob/master/HotKeyNames.plist

"Github: Open Remote URL in Browser": Expected: https://github.com/eczarny/spectacle/blob/master/Spectacle/Resources/Property%20Lists/HotKeyNames.plist#L17 Actual: https://github.com/eczarny/spectacle/blob/masterC:/github/spectacle/Spectacle/Resources/Property%20Lists/HotKeyNames.plist#L17

bgreenlee commented 9 years ago

@markschwarz - see my comment above. Could you help w/ some troubleshooting? I don't have access to a Windows machine right now. See https://github.com/bgreenlee/sublime-github/issues/80#issuecomment-87261418

markschwarz commented 9 years ago

Here are the outputs I get, assuming the Spectacle repo. I chose that one because it's neither yours nor mine. Github/Sublime can make no assumptions about namespaces.

view.file_name() 'C:\github\spectacle\Spectacle\Resources\Property Lists\HotKeyNames.plist'

=== Output from git in the git shell: MSchwarz@MSCHWARZ-TPX230 /c/github/spectacle/Spectacle/Resources/Property Lists (master) $ ls BlacklistedApplications.plist Defaults.plist HotKeyNames.plist SpecialHotKeyTranslations.plist Spectacle-Info.plist

MSchwarz@MSCHWARZ-TPX230 /c/github/spectacle/Spectacle/Resources/Property Lists (master) $ git ls-remote --get-url git@github.com:eczarny/spectacle.git

MSchwarz@MSCHWARZ-TPX230 /c/github/spectacle/Spectacle/Resources/Property Lists (master) $ git rev-parse --show-toplevel c:/github/spectacle

MSchwarz@MSCHWARZ-TPX230 /c/github/spectacle/Spectacle/Resources/Property Lists (master) $ git rev-parse --abbrev-ref HEAD master

MSchwarz@MSCHWARZ-TPX230 /c/github/spectacle/Spectacle/Resources/Property Lists (master) $

== Here's the same output from cmd.exe. I expect it's the same as Git's shell, but including to make sure there's no translation going on.

c:\github\spectacle\Spectacle\Resources\Property Lists>dir Volume in drive C is Windows7_OS Volume Serial Number is D656-87D4

Directory of c:\github\spectacle\Spectacle\Resources\Property Lists

06/02/15 09:31

. 06/02/15 09:31 .. 06/02/15 09:31 350 BlacklistedApplications.plist 06/02/15 09:31 7,765 Defaults.plist 06/02/15 09:31 821 HotKeyNames.plist 06/02/15 09:31 2,515 SpecialHotKeyTranslations.plist 06/02/15 09:31 1,359 Spectacle-Info.plist 5 File(s) 12,810 bytes 2 Dir(s) 22,145,622,016 bytes free

c:\github\spectacle\Spectacle\Resources\Property Lists>git ls-remote --get-url git@github.com:eczarny/spectacle.git

c:\github\spectacle\Spectacle\Resources\Property Lists>git rev-parse --show-toplevel c:/github/spectacle

c:\github\spectacle\Spectacle\Resources\Property Lists>git rev-parse --abbrev-ref HEAD master

c:\github\spectacle\Spectacle\Resources\Property Lists>

=== Other notes: I found an issue with Logstash the other day where C:\ and c:\ were causing issues with resolving paths. https://logstash.jira.com/browse/LOGSTASH-430. This looks to be VERY similar. It it a simple case issue in the drive letter?

bgreenlee commented 9 years ago

Thanks for the awesome debugging info! I'm sure the case difference was the problem. I just pushed a fix. Give it a try and let me know.

markschwarz commented 9 years ago

Thanks! I'm having trouble being sure the change is active. This is my first time working with sublime package code.

I followed instructions at http://docs.sublimetext.info/en/latest/extensibility/packages.html#overriding-packages, but I think I'm still not seeing the new code. I faced Package Control wiping out my files with a package-control.cleanup marker ( https://github.com/wbond/package_control/blob/master/package_control/package_cleanup.py). I managed to stop that, but now I think it's simply ignoring my new package in C:\Users\MSchwarz\AppData\Roaming\Sublime Text 3\Packages\sublime-github.sublime-package\sublime_github.py. I added a "blah" string to the end of the relative URL, but it's not appending that string.

What's a quick/sure way to make sure I'm testing your patch? I'm glad to read up if there's a doc you like.

Mark

On Tue, Jun 2, 2015 at 1:22 PM, Brad Greenlee notifications@github.com wrote:

Thanks for the awesome debugging info! I'm sure the case differences was the problem. I just pushed a fix. Give it a try and let me know.

— Reply to this email directly or view it on GitHub https://github.com/bgreenlee/sublime-github/issues/82#issuecomment-108042817 .

bgreenlee commented 9 years ago

Probably the easiest thing to do is set the auto_upgrade_frequency setting in the Package Control settings to 0, and then restart Sublime.

I just pushed a change that adds a VERSION number. To check, open the sublime console (⌃^), and type:

import sublime_github
print(sublime_github.VERSION)

If you get AttributeError: 'module' object has no attribute 'VERSION', you've got a version of sublime-github from before the VERSION was added. The current version is 118.

markschwarz commented 9 years ago

OK. I'll give that a shot tonight or in the morning. Thanks!

On Tue, Jun 2, 2015 at 3:37 PM, Brad Greenlee notifications@github.com wrote:

Probably the easiest thing to do is set the auto_upgrade_frequency setting in the Package Control settings https://packagecontrol.io/docs/settings to 0, and then restart Sublime.

I just pushed a change https://github.com/bgreenlee/sublime-github/commit/9c7eb8ac99a232913352a140da3b9f408cf90050 that adds a VERSION number. To check, open the sublime console (⌃^), and type:

import sublime_github print(sublime_github.VERSION)

If you get AttributeError: 'module' object has no attribute 'VERSION', you've got a version of sublime-github from before the VERSION was added. The current version is 118.

— Reply to this email directly or view it on GitHub https://github.com/bgreenlee/sublime-github/issues/82#issuecomment-108091189 .

markschwarz commented 9 years ago

It worked! Thanks!

It took me about 4 reads through the options at https://packagecontrol.io/docs/customizing_packages#Git-Hg_Clone to figure out that git clone to Packages/Users would not do what I wanted, but git clone to Packages/ would. Once I figured that out, no other changes were needed to test this fix.

I also realized that "Github: Open" was another package, not this one. I uninstalled it.

Console shows the correct version:

>>> import sublime_github
>>> sublime_github.VERSION
118
>>> sublime_github.__file__
'C:\\Users\\MSchwarz\\AppData\\Roaming\\Sublime Text 3\\Packages\\sublime-github\\sublime_github.py'

"Github: Open Remote URL in Browser" works well now. https://github.com/eczarny/spectacle/blob/master/Spectacle/Resources/Property%20Lists/HotKeyNames.plist#L5

Thanks for the fix!

I'll stay on the cloned version for a while until this fix is pulled back into packagecontrol.io's main channel. Will that be soon?

bgreenlee commented 9 years ago

Package Control will automatically update packages on start. The auto_upgrade_frequency setting controls how often it will check. Default is 6 hours.

Thank you for your help!

markschwarz commented 9 years ago

Hm, ok. I didn't see your change come through package control last night when I was testing, which I assume was intentional. It looks like a pull request into packagecontrol.io is needed to push this change out to everyone. I'll stay on my Github-cloned version.

bgreenlee commented 9 years ago

I pushed a new tag. I think that's all I need to do to get package control to pick it up.

markschwarz commented 9 years ago

Yes, I see 1.0.1, now. Thanks!

[image: Inline image 1]

On Wed, Jun 3, 2015 at 12:54 PM, Brad Greenlee notifications@github.com wrote:

I pushed a new tag. I think that's all I need to do to get package control to pick it up.

— Reply to this email directly or view it on GitHub https://github.com/bgreenlee/sublime-github/issues/82#issuecomment-108546482 .