gitrefresh

Easily export, reinitialize and update all git repositories in a file hierarchy
git clone git://git.defalsify.org/gitrefresh.git
Info | Log | Files | Refs | README | LICENSE

gitadd.sh (915B)


      1 while test $# != 0; do
      2 	case "$1" in
      3 		-v)
      4 			_debug=1
      5 			_level=1
      6 			shift
      7 			;;
      8 		-d)
      9 			shift
     10 			description=$1
     11 			shift
     12 			;;
     13 		-o)
     14 			shift
     15 			owner=$1
     16 			shift
     17 			;;
     18 		*)
     19 			break
     20 			;;
     21 	esac
     22 done
     23 
     24 . bdbg.sh
     25 
     26 p=$1
     27 if [ -z $1 ]; then
     28 	dbg 4 "missing remote repo"
     29 	exit 1
     30 fi
     31 
     32 . common.sh
     33 
     34 if [ ! -z $description ]; then
     35 	dbg 2 "using git repo description: $description"
     36 fi
     37 
     38 if [ ! -z $owner ]; then
     39 	dbg 2 "using git repo owner: $owner"
     40 fi
     41 
     42 b=${GIT_BASE:-.}
     43 set +e
     44 
     45 t=$(mktemp)
     46 chomp_git_path $p $t
     47 read -r pc < $t
     48 dbg 2 "using git repo path: $b/$pc for $p"
     49 
     50 pushd $b
     51 git clone --bare $p $pc
     52 popd
     53 
     54 if [ ! -z $description ]; then
     55 	echo -n $description > $pc/description
     56 fi
     57 
     58 if [ ! -z $owner ]; then
     59 	grep -e "^[owner]" $pc/config
     60 	if [ $? -eq "0" ]; then
     61 		>&2 echo "owner already set in config, skip, edit manually if you really want"
     62 	else
     63 		cat <<EOF >> $pc/config
     64 [gitweb]
     65 	owner = $owner
     66 EOF
     67 	fi
     68 fi
     69 
     70 set -e