]> git.xonotic.org Git - xonotic/xonotic.git/blob - all
fb6299e2d6d532f0cab93461d2e0a0412f3126cd
[xonotic/xonotic.git] / all
1 #!/bin/sh
2
3 set -e
4
5 repos="
6         data/xonotic-data.pk3dir
7         data/xonotic-maps.pk3dir
8         data/xonotic-music.pk3dir
9         darkplaces
10 "
11
12 cmd=$1
13 shift
14
15 d0=`pwd`
16 case "$cmd" in
17         update)
18                 base=`git config remote.origin.url`
19                 base=${base%/xonotic.git}
20                 for d in $repos; do
21                         if [ -d "$d0/$d" ]; then
22                                 cd "$d0/$d"
23                                 git config remote.origin.url "$base/${d##*/}.git"
24                                 git pull
25                                 cd "$d0"
26                         else
27                                 git clone "$base/${d##*/}.git" "$d0/$d"
28                         fi
29                 done
30                 ;;
31         checkout)
32                 remote=$1
33                 branch=$2
34                 if [ -z "$branch" ]; then
35                         branch=$remote
36                         remote=origin
37                 fi
38                 exists=false
39                 for d in $repos; do
40                         cd "$d0/$d"
41                         if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
42                                 exists=true
43                                 git checkout "$branch"
44                         elif git rev-parse "refs/remotes/$remote/$branch" >/dev/null 2>&1; then
45                                 exists=true
46                                 git checkout --track -b "$branch" "$remote/$branch"
47                         else
48                                 git checkout master
49                         fi
50                         cd "$d0"
51                 done
52                 "$0" branch
53                 ;;
54         branch)
55                 for d in $repos; do
56                         cd "$d0/$d"
57                         r=`git symbolic-ref HEAD`
58                         r=${r#refs/heads/}
59                         echo "$d is at $r"
60                         cd "$d0"
61                 done
62                 ;;
63         branches)
64                 for d in $repos; do
65                         cd "$d0/$d"
66                         echo "In $d:"
67                         git branch -a | sed 's/^/  /'
68                         cd "$d0"
69                 done
70                 ;;
71         *)
72                 echo "Usage:"
73                 echo "  $0 update"
74                 echo "  $0 branch"
75                 echo "  $0 branches"
76                 echo "  $0 checkout"
77                 ;;
78 esac