Skip to content

Instantly share code, notes, and snippets.

@mnot
Created March 15, 2014 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnot/9574440 to your computer and use it in GitHub Desktop.
Save mnot/9574440 to your computer and use it in GitHub Desktop.
Git alias handler for github
#!/bin/sh
# Github Handler
#
# Add to your .gitconfig like this:
#
# [alias]
# hub = !"github"
ROOT=`git rev-parse --show-toplevel 2>/dev/null`
GITHUB_REPO=$( git remote -v 2>/dev/null | grep "(fetch)" | grep "github.com" | cut -d ":" -f 2 | cut -d " " -f 1)
REPO=${GITHUB_REPO%.*}
COMMAND=$1
if [ ! $ROOT ] ; then
echo "FATAL: Not a git repository.";
exit 1;
fi;
if [ ! $REPO ] ; then
echo "FATAL: Can't find a github.com fetch remote."
exit 1;
fi;
case "$COMMAND" in
"issues")
echo "Downloading issues for ${REPO}..."
curl https://api.github.com/repos/${REPO}/issues > ${ROOT}/issues.json
;;
*)
echo "FATAL: unknown command. Try: issues"
exit 1;
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment