summaryrefslogblamecommitdiffstats
path: root/uploadNewGit.sh
blob: c2e6867fa22f16ec0db921f1ae810363135c230e (plain) (tree)
1
2
3
4
5
6
7
8
9
         
      
 

                                              

                                                              

                
                                
                                                              


                              
                                    
              

  
                         
                       







                                                       

                                              
                
 

                                                                                                                                               
                          
                 
               
#!/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)"
description="$1"

if [ ! -d "$gitdir/.git" ]; then
	echo "$0 must be run at the root of a git repository."
	exit 1
fi
if [ -z "$description" ]; then
	echo "Usage: $0 DESCRIPTION"
	exit 1
fi

cd "$GITOLITE_ADMIN/conf"
echo "Writing config.."
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
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 || true
git remote add origin $url
git push -u --all
git push --tags