summaryrefslogtreecommitdiffstats
path: root/uploadNewGit.sh
blob: a4c7ec852779cd2610481ae7f3e273391f995c11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

GITOLITE_ADMIN="$HOME/Projects/gitolite-admin"

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.
	exit 1
fi
if [ -z "$description" ]; then
	echo You need to specify a description argument.
	exit 1
fi

pushd "$GITOLITE_ADMIN/conf" > /dev/null
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
git commit -a -m "Adding $name to repository."
git push
popd > /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
git remote add origin $url
git push -u --all
git push --tags