Skip to content

Instantly share code, notes, and snippets.

@itspriddle
Created January 23, 2012 20:26
Show Gist options
  • Save itspriddle/1665370 to your computer and use it in GitHub Desktop.
Save itspriddle/1665370 to your computer and use it in GitHub Desktop.
#!/bin/bash
#/ Usage: git travis
#/
#/ Open a browser on travis-ci.org/GITHUB_NAME/REPO_NAME
#/
#/ Ex:
#/ git://github.com/rails/rails.git => http://travis-ci.org/rails/rails
usage() {
grep '^#/' <"$0" | cut -c4-
exit 0
}
die() {
echo $1
exit 1
}
if [[ $# -gt 0 ]]; then
usage
fi
REMOTE_NAME=$(git remote 2> /dev/null)
REMOTE_URL=$(git config remote.$REMOTE_NAME.url 2> /dev/null)
REMOTE_URL=${REMOTE_URL/.git/}
if [[ $REMOTE_URL == git@github.com* ]]; then
PATTERN="git@github.com:"
elif [[ $REMOTE_URL == git://github.com* ]]; then
PATTERN="git://github.com/"
else
die "Not a github URL"
fi
TRAVIS_URL="http://travis-ci.org/${REMOTE_URL/$PATTERN/}"
open $TRAVIS_URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment