summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-07-12 20:20:25 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2012-07-12 20:20:25 +0200
commitee23f1f16d963a8553fd608da814cfe44ab851c5 (patch)
tree461a6a2f4c01b6e52a3cf6e1c6dbf8efc6aeff88
parentGithub syncer should work with github api v3. (diff)
downloadGitTools-ee23f1f16d963a8553fd608da814cfe44ab851c5.tar.xz
GitTools-ee23f1f16d963a8553fd608da814cfe44ab851c5.zip
Make script pretty.
-rwxr-xr-xuploadNewGit.sh31
1 files changed, 17 insertions, 14 deletions
diff --git a/uploadNewGit.sh b/uploadNewGit.sh
index a4c7ec8..c2e6867 100755
--- a/uploadNewGit.sh
+++ b/uploadNewGit.sh
@@ -1,34 +1,37 @@
#!/bin/sh
+set -e
GITOLITE_ADMIN="$HOME/Projects/gitolite-admin"
-gitdir=$(readlink -f "$(pwd)")
-name=`basename "$gitdir" | cut -d / -f 2 | cut -d ' ' -f 1`
+gitdir="$(readlink -f "$(pwd)")"
+name="$(basename "$gitdir" | cut -d / -f 2 | cut -d ' ' -f 1)"
description="$1"
if [ ! -d "$gitdir/.git" ]; then
- echo Not a git repo.
+ echo "$0 must be run at the root of a git repository."
exit 1
fi
if [ -z "$description" ]; then
- echo You need to specify a description argument.
+ echo "Usage: $0 DESCRIPTION"
exit 1
fi
-pushd "$GITOLITE_ADMIN/conf" > /dev/null
+cd "$GITOLITE_ADMIN/conf"
echo "Writing config.."
-(echo
-echo " repo $name"
-echo " RW+CD = $(whoami)"
-echo " R = @all"
-echo " owner = \"$(git config --get user.name)\""
-echo " desc = \"$description\"") >> gitolite.conf
+cat >> gitolite.conf <<_EOF
+
+ repo $name
+ RW+CD = $(whoami)
+ R = @all
+ owner = "$(git config --get user.name)"
+ desc = "$description"
+_EOF
git commit -a -m "Adding $name to repository."
git push
-popd > /dev/null
+cd - > /dev/null
-url=`git --git-dir=$GITOLITE_ADMIN/.git remote -v | grep push | cut -f 2 | cut -d ' ' -f 1 | sed "s/$(basename $GITOLITE_ADMIN)/$name/"`
-git remote rm origin 2> /dev/null
+url="$(git --git-dir="$GITOLITE_ADMIN/.git" remote -v | grep push | cut -f 2 | cut -d ' ' -f 1 | sed "s/$(basename "$GITOLITE_ADMIN")/$name/")"
+git remote rm origin 2> /dev/null || true
git remote add origin $url
git push -u --all
git push --tags