Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for Github Enterprise #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,39 @@
<key>ActionParameters</key>
<dict>
<key>source</key>
<string>on run {input, parameters} tell application "Xcode" set activeDocument to document 1 whose name ends with (word -1 of (get name of window 1)) set activeDocumentPath to path of activeDocument set currentLines to selected paragraph range of activeDocument set startLine to get item 1 of currentLines set endLine to get item 2 of currentLines end tell set repositoryUrl to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git remote -v | grep fetch | awk '{print $2}' | sed 's/ssh:\\/\\/git@/https:\\/\\//' | sed 's/git@/https:\\/\\//' | sed 's/com:/com\\//' | sed 's/\\.git//'" set pathToRepositoryDirLocation to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse --show-toplevel " set activeFilePathInRepository to replace_text(activeDocumentPath, pathToRepositoryDirLocation, "") set currentCommit to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse HEAD" set githubUrl to repositoryUrl &amp; "/blob/" &amp; currentCommit &amp; activeFilePathInRepository &amp; "#L" &amp; startLine &amp; "-L" &amp; endLine set the clipboard to replace_text(githubUrl, " ", "%20") return inputend runon replace_text(this_text, search_string, replacement_string) set prevTIDs to AppleScript's text item delimiters set AppleScript's text item delimiters to the search_string set the item_list to every text item of this_text set AppleScript's text item delimiters to the replacement_string set this_text to the item_list as string set AppleScript's text item delimiters to prevTIDs return this_textend replace_text</string>
<string>on run {input, parameters}
tell application "Xcode"
set activeDocument to document 1 whose name ends with (word -1 of (get name of window 1))
set activeDocumentPath to path of activeDocument
set currentLines to selected paragraph range of activeDocument
set startLine to get item 1 of currentLines
set endLine to get item 2 of currentLines
end tell

set repositoryUrl to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git remote -v | grep fetch | awk '{print $2}' | sed -E -e 's,git@,https://,' -e 's,:([^/]),/\\1,' -e 's,.git$,,'"

set pathToRepositoryDirLocation to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse --show-toplevel "

set activeFilePathInRepository to replace_text(activeDocumentPath, pathToRepositoryDirLocation, "")

set currentCommit to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse HEAD"

set githubUrl to repositoryUrl &amp; "/blob/" &amp; currentCommit &amp; activeFilePathInRepository &amp; "#L" &amp; startLine &amp; "-L" &amp; endLine

set the clipboard to replace_text(githubUrl, " ", "%20")

return input
end run

on replace_text(this_text, search_string, replacement_string)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to prevTIDs
return this_text
end replace_text</string>
</dict>
<key>BundleIdentifier</key>
<string>com.apple.Automator.RunScript</string>
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 32 additions & 1 deletion quick-actions/Open on GitHub.workflow/Contents/document.wflow
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,38 @@
<key>ActionParameters</key>
<dict>
<key>source</key>
<string>on run {input, parameters} tell application "Xcode" set activeDocument to document 1 whose name ends with (word -1 of (get name of window 1)) set activeDocumentPath to path of activeDocument set currentLines to selected paragraph range of activeDocument set startLine to get item 1 of currentLines set endLine to get item 2 of currentLines end tell set repositoryUrl to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git remote -v | grep fetch | awk '{print $2}' | sed 's/ssh:\\/\\/git@/https:\\/\\//' | sed 's/git@/https:\\/\\//' | sed 's/com:/com\\//' | sed 's/\\.git//'" set pathToRepositoryDirLocation to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse --show-toplevel " set activeFilePathInRepository to replace_text(activeDocumentPath, pathToRepositoryDirLocation, "") set currentCommit to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse HEAD" set githubUrl to repositoryUrl &amp; "/blob/" &amp; currentCommit &amp; activeFilePathInRepository &amp; "#L" &amp; startLine &amp; "-L" &amp; endLine do shell script "open " &amp; replace_text(githubUrl, " ", "%20") return inputend runon replace_text(this_text, search_string, replacement_string) set prevTIDs to AppleScript's text item delimiters set AppleScript's text item delimiters to the search_string set the item_list to every text item of this_text set AppleScript's text item delimiters to the replacement_string set this_text to the item_list as string set AppleScript's text item delimiters to prevTIDs return this_textend replace_text</string>
<string>on run {input, parameters}
tell application "Xcode"
set activeDocument to document 1 whose name ends with (word -1 of (get name of window 1))
set activeDocumentPath to path of activeDocument
set currentLines to selected paragraph range of activeDocument
set startLine to get item 1 of currentLines
set endLine to get item 2 of currentLines
end tell

set repositoryUrl to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git remote -v | grep fetch | awk '{print $2}' | sed -E -e 's,git@,https://,' -e 's,:([^/]),/\\1,' -e 's,.git$,,'"

set pathToRepositoryDirLocation to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse --show-toplevel "

set activeFilePathInRepository to replace_text(activeDocumentPath, pathToRepositoryDirLocation, "")

set currentCommit to do shell script "cd $(dirname '" &amp; activeDocumentPath &amp; "'); git rev-parse HEAD"

set githubUrl to repositoryUrl &amp; "/blob/" &amp; currentCommit &amp; activeFilePathInRepository &amp; "#L" &amp; startLine &amp; "-L" &amp; endLine

do shell script "open " &amp; replace_text(githubUrl, " ", "%20")
return input
end run

on replace_text(this_text, search_string, replacement_string)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to prevTIDs
return this_text
end replace_text</string>
</dict>
<key>BundleIdentifier</key>
<string>com.apple.Automator.RunScript</string>
Expand Down