Rename regression scripts to enforce certain order
[guilt.git] / gq-push
blob1c515633ae27621931d4795b4b291876115134b3
1 #!/bin/bash
3 # Copyright (c) Josef "Jeff" Sipek, 2006
6 source "`dirname $0`/gq.lib"
8 export GIT_DIR=`find_git_dir`
9 GQ_DIR="$GIT_DIR/patches"
11 branch=`get_branch_verify`
12 series="$GQ_DIR/$branch/series"
13 applied="$GQ_DIR/$branch/status"
15 patch="$1"
17 if [ "$patch" = "--all" -o "$patch" = "-a" ]; then
18 # we are supposed to push all patches, get the last one out of
19 # series
21 eidx=`wc -l < $series`
22 if [ $eidx -eq 0 ]; then
23 echo "There are no patches to push"
24 exit 1
26 elif [ -z "$patch" ]; then
27 # we are supposed to push only the next patch onto the stack
29 eidx=`wc -l < $applied`
30 eidx=`expr $eidx + 1`
31 else
32 # we're supposed to push only up to a patch, make sure the patch is
33 # in the series
35 eidx=`cat $series | grep -ne "^$patch\$" | cut -d: -f1`
36 if [ $eidx -eq 0 ]; then
37 echo "Patch $patch is not in the series"
38 exit 1
42 # make sure that there are no unapplied changes
43 if ! must_commit_first; then
44 echo "Uncommited changes detected. Refresh first."
45 exit 1
48 # now, find the starting patch
49 sidx=`wc -l < $applied`
50 sidx=`expr $sidx + 1`
52 bail=0
53 idx=0
54 for p in `cat $series`; do
55 idx=`expr $idx + 1`
56 [ $idx -lt $sidx ] && continue
57 [ $idx -gt $eidx ] && break
59 echo "Applying patch..$p"
60 if [ ! -f "$GQ_DIR/$branch/$p" ]; then
61 echo "Patch $patch does not exist. Aborting."
62 exit 1
65 push_patch $p
66 bail=$?
68 # mark patch as applied
69 echo $p >> $applied
71 # bail if necessary
72 if [ $bail -eq 0 ]; then
73 echo "Patch applied."
74 else
75 echo "Patch applied with rejects. Fix it up, and refresh."
76 exit 1
78 done