Skip to content

Instantly share code, notes, and snippets.

@spudfkc
Created September 24, 2013 22:05
Show Gist options
  • Save spudfkc/6691969 to your computer and use it in GitHub Desktop.
Save spudfkc/6691969 to your computer and use it in GitHub Desktop.
Clones a repo and sets it up for Gerrit server. Only tested in bash. not super portable, but i find it useful I would recommend putting it in /usr/lib/git-core/
#!/bin/bash
if [ -z $1 ]
then
echo "Must supply a git project."
echo "Usage git gclone <project-url>"
return 1
fi
ORIGIN=$1
REMOTE_NAME=<gerrit_remote_name>
GERRIT_USER=<gerrit_username>
GERRIT_REPO=<gerrit_repo_url>
GERRIT_PORT=<gerrit_port>
TMP=${ORIGIN/ssh*urbancode}
GERRIT=ssh://$GERRIT_USER@$GERRIT_REPO:$GERRIT_PORT/$TMP
GERRIT=${GERRIT/.git}
git clone $ORIGIN
cd $(basename ${ORIGIN/.git})
git remote add $REMOTE_NAME $GERRIT
scp -p -P $GERRIT_PORT $GERRIT_USER@$GERRIT_REPO:hooks/commit-msg .git/hooks/
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment