]> git.xonotic.org Git - xonotic/xonotic.git/blob - all
make ./all push work
[xonotic/xonotic.git] / all
1 #!/bin/sh
2
3 set -e
4
5 repos="
6         .
7         data/xonotic-data.pk3dir
8         data/xonotic-maps.pk3dir
9         data/xonotic-music.pk3dir
10         darkplaces
11 "
12
13 if [ "$#" = 0 ]; then
14         set -- help
15 fi
16 cmd=$1
17 shift
18
19 d0=`pwd`
20 case "$cmd" in
21         update|pull)
22                 base=`git config remote.origin.url`
23                 base=${base%/xonotic.git}
24                 for d in $repos; do
25                         if [ -d "$d0/$d" ]; then
26                                 cd "$d0/$d"
27                                 git config remote.origin.url "$base/${d##*/}.git"
28                                 git pull
29                                 cd "$d0"
30                         else
31                                 git clone "$base/${d##*/}.git" "$d0/$d"
32                         fi
33                 done
34                 ;;
35         checkout)
36                 remote=$1
37                 branch=$2
38                 if [ -z "$branch" ]; then
39                         branch=$remote
40                         remote=origin
41                 fi
42                 exists=false
43                 for d in $repos; do
44                         cd "$d0/$d"
45                         if git rev-parse "refs/heads/$branch" >/dev/null 2>&1; then
46                                 exists=true
47                                 git checkout "$branch"
48                         elif git rev-parse "refs/remotes/$remote/$branch" >/dev/null 2>&1; then
49                                 exists=true
50                                 git checkout --track -b "$branch" "$remote/$branch"
51                         else
52                                 git checkout master
53                         fi
54                         cd "$d0"
55                 done
56                 "$0" branch
57                 ;;
58         branch)
59                 remote=$1
60                 branch=$2
61                 if [ -z "$branch" ]; then
62                         branch=$remote
63                         remote=origin
64                 fi
65                 if [ -z "$branch" ]; then
66                         for d in $repos; do
67                                 cd "$d0/$d"
68                                 r=`git symbolic-ref HEAD`
69                                 r=${r#refs/heads/}
70                                 echo "$d is at $r"
71                                 cd "$d0"
72                         done
73                 else
74                         for d in $repos; do
75                                 cd "$d0/$d"
76                                 a=
77                                 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
78                                         echo "Branch in $d?"
79                                         read -r a
80                                 done
81                                 if [ x"$a" = x"y" ]; then
82                                         git push "$remote" HEAD:"$branch"
83                                         git checkout --track -b "$branch" "$remote/$branch"
84                                 fi
85                                 cd "$d0"
86                         done
87                         "$0" branch
88                 fi
89                 ;;
90         branches)
91                 for d in $repos; do
92                         cd "$d0/$d"
93                         echo "In $d:"
94                         git branch -a | sed 's/^/  /'
95                         cd "$d0"
96                 done
97                 ;;
98         push)
99                 for d in $repos; do
100                         cd "$d0/$d"
101                         r=`git symbolic-ref HEAD`
102                         r=${r#refs/heads/}
103                         a=
104                         if git log "origin/$r".."$r" | grep .; then
105                                 while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
106                                         echo "Push $r in $d?"
107                                         read -r a
108                                 done
109                                 if [ x"$a" = x"y" ]; then
110                                         git push `git config "branch.$r.remote" || echo origin` HEAD
111                                 fi
112                         fi
113                         cd "$d0"
114                 done
115                 ;;
116         *)
117                 echo "Usage:"
118                 echo "  $0 pull"
119                 echo "  $0 push"
120                 echo "  $0 branches"
121                 echo "  $0 branch"
122                 echo "  $0 checkout"
123                 ;;
124 esac