Skip to content

Instantly share code, notes, and snippets.

@Iristyle
Created July 26, 2013 19:49
Show Gist options
  • Save Iristyle/6091736 to your computer and use it in GitHub Desktop.
Save Iristyle/6091736 to your computer and use it in GitHub Desktop.
For use during a PR sent to Janky to ensure latest code is pulled
if [[ ! -d './.git' ]]; then
git init
fi
owner=$(echo $JANKY_COMMIT_URL | sed -rn 's/^http(s)?\:\/\/github\.com\/(.*?)\/(.*?)\/?/\2/p')
repo=$(echo $JANKY_COMMIT_URL | sed -rn 's/^http(s)?\:\/\/github\.com\/(.*?)\/(.*?)\/?/\3/p')
url="https://[email protected]/$owner/$repo"
found=$(git remote | grep $owner)
if [[ -z $found ]]; then
echo "Adding remote $owner url as $url"
git remote add $owner $url
else
echo "Setting remote $owner url to $url"
git remote set-url $owner $url
fi
git fetch -v $owner
git reset --hard $JANKY_SHA1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment