Created
February 11, 2019 10:28
-
-
Save terryyounghk/d300cd52ee2db3904ffa8c2558053a30 to your computer and use it in GitHub Desktop.
Atlassian SourceTree Custom Action: "View Commit In Browser"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ----------------------------------------------------------------------------------------------- | |
# | |
# This script is to be used by SourceTree > Action > Custom Action | |
# | |
# (See https://confluence.atlassian.com/sourcetreekb/using-git-in-custom-actions-785323500.html) | |
# | |
# Copy this file into your 'bin' directory, (e.g. ~/.dotfiles/bin/view-commit) | |
# | |
# In Terminal, go to your 'bin' directory and run 'chmod +x view-commit' | |
# | |
# In SourceTree, | |
# | |
# 1. Create a new "Custom Action" | |
# 2. In "Menu Caption", enter "View Commit In Browser" | |
# 3. In "Script to run", enter the path to this file (e.g. ~/.dotfiles/bin/view-commit) | |
# 4. In "Parameters", enter "$REPO $SHA" (without quotes) | |
# 5. Optionally, assign a shortcut for this Custom Action (e.g. ^V) | |
# | |
# ----------------------------------------------------------------------------------------------- | |
# From Sourcetree's $REPO, get the config file and read the baseUrl, then construct the commit URL | |
stconfig=$1/.git/sourcetreeconfig | |
commit=$2 | |
baseUrl=$(sed -n 's/^remoteProjectLink0.baseUrl=//p' $stconfig) | |
identifier=$(sed -n 's/^remoteProjectLink0.identifier=//p' $stconfig) | |
commitUrl=$baseUrl/$identifier/commit/$commit | |
# View in chrome | |
open -a /Applications/Google\ Chrome.app "$commitUrl" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment