Skip to content

Commit

Permalink
Add open command for issue URLs
Browse files Browse the repository at this point in the history
The command will read the TM_ISSUE_URL variable from the current environment so you should set this in your project’s .tm_properties file.

The value should use ‘%s’ for where the issue should be inserted. E.g. for TextMate/.tm_properties we set:

    TM_ISSUE_URL = 'https://github.com/textmate/textmate/issues/%s'
  • Loading branch information
sorbits committed Aug 15, 2012
1 parent 10fb149 commit 570d257
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Commands/Open Issue Link.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"
abort "The TM_ISSUE_URL variable is unset for this project.\n\nThis needs to be set to a URL template (using %s) that translates the issue link to one that works in a browser." unless ENV.has_key? 'TM_ISSUE_URL'
link = STDIN.read
if link =~ %r{issue://(.+)}
url = ENV['TM_ISSUE_URL'] % $1
%x{ /usr/bin/open #{e_sh url} }
else
abort "Not an issue link: ‘#{link}’"
end
</string>
<key>fallbackInput</key>
<string>scope</string>
<key>hideFromUser</key>
<string>1</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string></string>
<key>name</key>
<string>Open Issue Link</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>scope</key>
<string>markup.underline.link.issue</string>
<key>uuid</key>
<string>D01C6CD1-A0CF-46AF-AB0E-DF8C5CAB1B36</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>

5 comments on commit 570d257

@skurfer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be nicer to use #157 instead of issue://157? That would allow direct pasting to/from a comment on GitHub and it would all just work. Bonus points if you can add support for GitHub's syntax for links to issues in other repos. :-) i.e. user/Repository#123

@sorbits
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would clash a lot with other uses of the hash-character followed by a number.

Syntax for referring to other repositories might be useful, but personally I don’t need it — when I do, I might add it :)

@skurfer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would clash a lot with other uses of the hash-character followed by a number.

How so? We're just talking about the assigned scope, right? So as long as you don't take away or override an existing scope for those strings, all the existing stuff should continue to work, would it not?

Syntax for referring to other repositories might be useful, but personally I don’t need it — when I do, I might add it :)

We use it quite a bit for Quicksilver (with all the plug-in repos, etc.) Seems like you would to, considering all the bundle repos. :-) In any case, one nice thing about that syntax is that you wouldn't even need to define $TM_ISSUE_URL to make it work. Not that I'm suggesting using that syntax all the time. I'd much rather just type/read #XXX (or even issue://XXX) if that works in the current context.

@sorbits
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for clash, I mean if you have some commented CSS with hex colors (e.g. #000) then that would be underlined as a clickable issue.

As for issue://XXX that does work (i.e. w/o the brackets).

@skurfer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. I think the small distraction with be worth it, but OK.

Please sign in to comment.