chiark / gitweb /
git-debrebase: test suite: add some t-git-next-date
[dgit.git] / tests / lib-gdr
1 #
2
3 : ${GDR_TEST_DEBUG=-D}
4 export GDR_TEST_DEBUG
5
6 t-git-debrebase () {
7         local gdr=${DGIT_GITDEBREBASE_TEST-git-debrebase}
8         : '
9 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
10         $gdr    $GDR_TEST_OPTS $GDR_TEST_DEBUG $t_gdr_xopts "$@"
11         : '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
12 '
13 }
14
15 t-gdr-good () {
16         local state=$1
17         local beforetag=$2 # say HEAD to skip this check
18         # state should be one of
19         #   laundered
20         #   stitched
21         #   pushed
22
23         git diff --quiet ${beforetag-t.before} -- ':.' ':!debian/patches'
24
25         local etype netype bwtip
26
27         case $state in
28         laundered)
29                         etype=Upstream
30                         bwtip=Y:`t-git-debrebase breakwater`
31                 ;;
32         stitched)       etype=Pseudomerge ;;
33         pushed)         etype=AddPatches; netype=Pseudomerge ;;
34         esac
35
36         t-git-debrebase analyse >../anal.check
37         expect=`git rev-parse HEAD`
38         exec <../anal.check
39         local cid ctype info nparents
40         while read cid ctype info; do
41                 : ===== $cid $ctype $info =====
42                 test $cid = $expect
43                 local cetype=$etype
44                 if [ "x$ctype" = "x$etype" ]; then cetype=SAME; fi
45                 local parents="`git log -n1 --pretty=format:%P $cid`"
46                 expect="$parents"
47                 enparents=1
48                 : "$ctype/$cetype" "$parents"
49
50                 case "$ctype/$cetype" in
51                 Pseudomerge/SAME)                       ;;
52                 Packaging/SAME)                         ;;
53                 Packaging/Upstream)                     ;;
54                 AddPatches/SAME)                        ;;
55                 Changelog/Packaging)                    ;;
56                 Changelog/Upstream)                     ;;
57                 Upstream/SAME)                          ;;
58                 Anchor/Upstream)                        ;;
59                 Anchor/Packaging)                       ;;
60                 *)
61                         fail "etype=$etype ctype=$ctype cetype=$cetype $cid"
62                         ;;
63                 esac
64
65                 case "$ctype/$etype" in
66                 Packaging/Upstream|\
67                 Changelog/Upstream)
68                         if [ "x$bwtip" != x ]; then
69                                 test "$bwtip" = "Y:$cid"
70                                 bwtip=''
71                         fi
72                 esac
73
74                 case "$ctype" in
75                 Pseudomerge)
76                         expect=${info#Contributor=}
77                         expect=${expect%% *}
78                         enparents=2
79                         git diff --quiet $expect..$cid
80                         etype=Upstream
81
82                         : 'reject pointless pseudomerges'
83                         local overwritten=${parents/$expect/}
84                         overwritten=${overwritten// /}
85                         t-git-debrebase analyse $overwritten >../anal.overwr
86                         local ocid otype oinfo
87                         read <../anal.overwr ocid otype oinfo
88                         case "$otype" in
89                         Pseudomerge) test "x$info" != "x$oinfo" ;;
90                         esac
91                         ;;
92                 Packaging)
93                         git diff --quiet $expect..$cid -- ':.' ':!debian' 
94                         git diff --quiet $expect..$cid -- ':debian/patches'
95                         etype=Packaging
96                         ;;
97                 AddPatches)
98                         git diff --quiet $expect..$cid -- \
99                                 ':.' ':!debian/patches'
100                         etype=$netype
101                         netype=Upstream
102                         ;;
103                 Changelog)
104                         git diff --quiet $expect..$cid -- \
105                                 ':.' ':!debian/changelog'
106                         etype=Packaging
107                         ;;
108                 Upstream/SAME)
109                         git diff --quiet $expect..$cid -- ':debian'
110                         ;;
111                 Anchor)
112                         break
113                         ;;
114                 esac
115
116                 local cnparents=`printf "%s" "$parents" | wc -w`
117                 test $cnparents = $enparents
118
119                 local cndparents=`
120         for f in $parents; do echo $f; done | sort -u | wc -w
121                                 `
122                 test $cndparents = $cnparents
123
124                 case "$parents" in
125                 *"$expect"*)    ;;
126                 *)              fail 'unexpected parent' ;;
127                 esac
128
129         done
130 }
131
132 t-some-changes () {
133         local token=$1
134
135         t-git-next-date
136
137         echo >>debian/zorkmid "// debian $token"
138         git add debian/zorkmid
139         git commit -m "DEBIAN add zorkmid ($token)"
140
141         echo >>src.c "// upstream $token"
142         git commit -a -m "UPSTREAM edit src.c ($token)"
143
144         for f in debian/zorkmid src.c; do
145                 echo "// both! $token" >>$f
146                 git add $f
147         done
148         git commit -m "MIXED add both ($token)"
149
150         t-git-next-date
151 }
152
153 t-make-new-upstream-tarball () {
154         local uv=$1
155         git checkout make-upstream
156         # leaves ust set to filename of orig tarball
157         echo "upstream $uv" >>docs/README
158         git commit -a -m "upstream $uv tarball"
159         ust=example_$uv.orig.tar.gz
160         git archive -o ../$ust --prefix=example-2.0/ make-upstream
161 }
162
163 t-nmu-upload-1 () {
164         # usage:
165         #  v=<full version>
166         #  nmu-upload-1 <nmubranch>
167         #  gbp pq import or perhaps other similar things
168         #  nmu-upload-2
169         #  maybe make some dgit-covertible commits
170         #  nmu-upload-3
171
172         t-git-next-date
173         nmubranch=$1
174         git checkout -f -b $nmubranch
175         t-git-debrebase
176         t-git-debrebase convert-to-gbp
177         t-git-next-date
178         # now we are on a gbp patched-unapplied branch
179 }
180
181
182 t-nmu-upload-2 () {
183         t-git-next-date
184         t-dch-commit -v $v -m "nmu $nmubranch $v"
185 }
186
187 t-nmu-upload-3 () {
188         t-dch-commit -r sid
189
190         t-dgit -wgf build-source
191
192         cd ..
193         c=${p}_${v}_source.changes
194         debsign -kBCD22CD83243B79D3DFAC33EA3DBCBC039B13D8A $c
195         dput -c $tmp/dput.cf test-dummy $c
196
197         t-archive-process-incoming sid
198         t-git-next-date
199         cd $p
200         git checkout master
201 }
202
203 t-nmu-commit-an-upstream-change () {
204         echo >>newsrc.c "// more upstream"
205         git add newsrc.c
206         git commit -m 'UPSTREAM NMU'
207 }
208
209 t-maintainer-commit-some-changes () {
210         t-dch-commit -v$v -m "start $v"
211
212         t-some-changes "maintainer $v"
213         t-git-debrebase
214         t-git-debrebase stitch
215
216         git branch did.maintainer
217
218         t-git-next-date
219 }
220
221 t-nmu-causes-ff-fail () {
222         t-dgit fetch
223
224         t-expect-fail E:'Not.*fast-forward' \
225         git merge --ff-only dgit/dgit/sid
226
227         t-expect-fail E:'-fdiverged.*refs/remotes/dgit/dgit/sid' \
228         t-git-debrebase
229 }
230
231 t-nmu-reconciled-good () {
232         local nmutree=$1
233
234         : 'check that what we have is what is expected'
235
236         git checkout -b compare.nmu origin/master~0
237         git checkout $nmutree .
238         git rm -rf debian/patches
239         git commit -m 'rm patches nmu'
240
241         git checkout -b compare.maintainer origin/master~0
242         git checkout did.maintainer .
243         git rm -rf --ignore-unmatch debian/patches
244         git commit --allow-empty -m 'rm patches maintainer'
245
246         git merge compare.nmu
247         git diff --quiet master
248
249         : 'check that dgit still likes it'
250
251         git checkout master
252         t-dgit -wgf quilt-fixup
253 }