chiark / gitweb /
d6d33f7851e568ff0bcf64ea1c69dd3d2f872f1c
[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         #   patches
22
23         git diff --quiet ${beforetag-t.before} -- ':.' ':!debian/patches'
24
25         local etype netype
26
27         case $state in
28         laundered)      etype=Upstream  ;;
29         stitched)       etype=Pseudomerge ;;
30         pushed)         etype=AddPatches; netype=Pseudomerge ;;
31         esac
32
33         t-git-debrebase analyse >../anal.check
34         expect=`git rev-parse HEAD`
35         exec <../anal.check
36         local cid ctype info nparents
37         while read cid ctype info; do
38                 : ===== $cid $ctype $info =====
39                 test $cid = $expect
40                 local cetype=$etype
41                 if [ "x$ctype" = "x$etype" ]; then cetype=SAME; fi
42                 local parents="`git log -n1 --pretty=format:%P $cid`"
43                 expect="$parents"
44                 enparents=1
45                 : "$ctype/$cetype" "$parents"
46                 case "$ctype/$cetype" in
47                 Pseudomerge/SAME)                       ;;
48                 Packaging/SAME)                         ;;
49                 Packaging/Upstream)                     ;;
50                 AddPatches/SAME)                        ;;
51                 Changelog/Packaging)                    ;;
52                 Changelog/Upstream)                     ;;
53                 Upstream/SAME)                          ;;
54                 BreakwaterUpstreamMerge/Upstream)       ;;
55                 BreakwaterUpstreamMerge/Packaging)      ;;
56                 *)
57                         fail "etype=$etype ctype=$ctype cetype=$cetype $cid"
58                         ;;
59                 esac
60
61                 case "$ctype" in
62                 Pseudomerge)
63                         expect=${info#Contributor=}
64                         expect=${expect%% *}
65                         enparents=2
66                         git diff --quiet $expect..$cid
67                         etype=Upstream
68                         ;;
69                 Packaging)
70                         git diff --quiet $expect..$cid -- ':.' ':!debian' 
71                         git diff --quiet $expect..$cid -- ':debian/patches'
72                         etype=Packaging
73                         ;;
74                 AddPatches)
75                         git diff --quiet $expect..$cid -- \
76                                 ':.' ':!debian/patches'
77                         etype=$netype
78                         netype=Upstream
79                         ;;
80                 Changelog)
81                         git diff --quiet $expect..$cid -- \
82                                 ':.' ':!debian/changelog'
83                         etype=Packaging
84                         ;;
85                 Upstream/SAME)
86                         git diff --quiet $expect..$cid -- ':debian'
87                         ;;
88                 BreakwaterUpstreamMerge)
89                         break
90                         ;;
91                 esac
92
93                 local cnparents=`printf "%s" "$parents" | wc -w`
94                 test $cnparents = $enparents
95
96                 case "$parents" in
97                 *"$expect"*)    ;;
98                 *)              fail 'unexpected parent' ;;
99                 esac
100
101         done
102 }
103
104 t-some-changes () {
105         local token=$1
106
107         echo >>debian/zorkmid "// debian $token"
108         git add debian/zorkmid
109         git commit -m "DEBIAN add zorkmid ($token)"
110
111         echo >>src.c "// upstream $token"
112         git commit -a -m "UPSTREAM edit src.c ($token)"
113
114         for f in debian/zorkmid src.c; do
115                 echo "// both! $token" >>$f
116                 git add $f
117         done
118         git commit -m "MIXED add both ($token)"
119 }
120
121 t-make-new-upstream-tarball () {
122         local uv=$1
123         git checkout make-upstream
124         # leaves ust set to filename of orig tarball
125         echo "upstream $uv" >>docs/README
126         git commit -a -m "upstream $uv tarball"
127         ust=example_$uv.orig.tar.gz
128         git archive -o ../$ust --prefix=example-2.0/ make-upstream
129 }