Skip to content

Instantly share code, notes, and snippets.

@pronebird
Created September 6, 2016 13:23
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pronebird/d243f4aa1c8569eae12c7eaf677828d2 to your computer and use it in GitHub Desktop.
Save pronebird/d243f4aa1c8569eae12c7eaf677828d2 to your computer and use it in GitHub Desktop.
Custom action for Source Tree app to copy commit URL on GitHub
#!/bin/sh
#
# Custom action for Source Tree app to copy commit URL on GitHub
# Menu caption: Copy Changeset URL on GitHub
# Script to run: ~/bin/github-commit-url
# Parameters: $REPO $SHA
#
if (( $# != 2 ))
then
echo "Usage: github-commit-url {repo-path} {sha}"
exit 1
fi
repo=$1
sha=$2
origin=`cd $repo && git config --get remote.origin.url`
# put everything together
github_url="$origin/commit/$sha"
# replace git@ with https://
github_url=${github_url/git@/https://}
# replace github.com:username with github.com/username
github_url=${github_url/github.com:/github.com/}
# remove .git part
github_url=${github_url/.git/}
echo "REPO: $repo"
echo "SHA: $sha"
echo $github_url | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment