Skip to content

Instantly share code, notes, and snippets.

@a7madgamal
Created December 21, 2016 14:29
Show Gist options
  • Save a7madgamal/ab6e82c7490379be6427245ce95e3420 to your computer and use it in GitHub Desktop.
Save a7madgamal/ab6e82c7490379be6427245ce95e3420 to your computer and use it in GitHub Desktop.
Sourcetree action - Open commit in Gitlab
#!/bin/sh
# a sourcetree custom action to open the selected commit in gitlab (easy to change to a similar url)
# 1- download this file somewhere and make sure it's executable
# 2- sourcetree > prefreances > custom actions > add > 'Open commit in gitlab' as title > select script > $SHA in params
#
# Ahmed Hassanein - Tickaroo
gitRemote=$(git config --get remote.origin.url)
if [ "$gitRemote" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
fi
re=':(.*)\.git'
if [[ $gitRemote =~ $re ]]
then
giturl=https://git.tickaroo.com/${BASH_REMATCH[1]}/commit/$(echo $1|tr -d '\n')
open "$giturl"
else
echo "Git URL does not match: $gitRemote"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment