Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 72 lines (63 sloc) 2.139 kb
fccc685 Initial open-source release
MLstate authored
1 #!/bin/bash -e
2
3 help () (
4 echo "$0:"
5 echo " - Initialise some sane standard git config"
6 echo " - Possibly setup for linking with extra repositories"
7 echo "Options:"
8 echo " --extra-repo <name> add the given repo inside ./repos/"
9 echo " --link [dir] link to existing repositories in [dir] (by default, ../)"
10 echo " instead of cloning a fresh repo"
11 echo " --help display this help message"
12 echo
13 )
14
15 # This is used for e.g. ./init.sh --extra-repo git://github.com/MLstate/tictactopa.git
16 # Do not remove this, we actually use it
17 get_repo_name() { x=${1##*:}; x=${x##*/}; x=${x%.git}; echo $x; }
18
19 REPOS=()
20 LINK=""
21 LINKDIR=".."
22
23 while [ $# -gt 0 ]; do
24 case $1 in
25 --help|-h)
26 help; exit 0;;
27 --extra-repo)
28 if [ $# -lt 2 ]; then echo "Error: option $1 requires an argument"; exit 1; fi
29 shift
30 REPOS[${#REPOS[@]}]=$1
31 ;;
32 --link)
33 if [ $# -ge 2 ] && [ "${2#-}" = "$2" ]; then shift; LINKDIR=$1; fi
34 LINK=1
35 ;;
36 *) echo "Error: unknown option $1"
37 esac
38 shift
39 done
40
41 git config branch.master.rebase true
42 git config --global branch.autosetuprebase always
43
44 echo "OK: git setup complete"
45
46 mkdir -p repos
47
48 # don't forget to add those to .gitignore to avoid conflicts
49 for repo_link in "${REPOS[@]}"; do
50 r=$(get_repo_name $repo_link)
51 if [ -e "repos/$r" ]; then
52 echo "repo $r is already there, skipping"
53 elif [ -n "$LINK" ]; then
54 if [ ! -d "$LINKDIR/$r/.git" ]; then
55 echo "Error: could not find a valid git repo at $LINKDIR/$r"
56 else
57 RELLINK=$LINKDIR
58 if [ "${RELLINK#/}" = "$RELLINK" ]; then RELLINK="../$RELLINK"; fi
59 ln -s "$RELLINK/$r" repos/
60 echo "OK: repo $r linked in repos/"
61 fi
62 else
63 cd repos
64 # we assume the full link is given, like github repository,
65 # e.g. git://github.com/MLstate/tictactopa.git used by passtracker
66 CLONE_PATH="$repo_link"
67 git clone $CLONE_PATH
68 cd ..
69 echo "OK: repo $r cloned in repos/"
70 fi
71 done
Something went wrong with that request. Please try again.