chiark / gitweb /
git-debrebase: test suite: gdr-edits: check branch structure after last push
[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-branch-structure () {
16         local state=$1
17         # state should be one of
18         #   laundered
19         #   stitched
20         #   patches
21
22         local etype netype
23
24         case $state in
25         laundered)      etype=Upstream  ;;
26         stitched)       etype=Pseudomerge ;;
27         pushed)         etype=AddPatches; netype=Pseudomerge ;;
28         esac
29
30         t-git-debrebase analyse >../anal.check
31         expect=`git rev-parse HEAD`
32         exec <../anal.check
33         local cid ctype info nparents
34         while read cid ctype info; do
35                 : ===== $cid $ctype $info =====
36                 test $cid = $expect
37                 local cetype=$etype
38                 if [ "x$ctype" = "x$etype" ]; then cetype=SAME; fi
39                 local parents="`git log -n1 --pretty=format:%P $cid`"
40                 expect="$parents"
41                 enparents=1
42                 : "$ctype/$cetype" "$parents"
43                 case "$ctype/$cetype" in
44                 Pseudomerge/SAME)
45                         expect=${info#Contributor=}
46                         expect=${expect%% *}
47                         enparents=2
48                         git diff --quiet $expect..$cid
49                         etype=Upstream
50                         ;;
51                 Packaging/SAME|\
52                 Packaging/Upstream)
53                         git diff --quiet $expect..$cid -- ':.' ':!debian' 
54                         git diff --quiet $expect..$cid -- ':debian/patches'
55                         etype=Packaging
56                         ;;
57                 AddPatches/SAME)
58                         git diff --quiet $expect..$cid -- \
59                                 ':.' ':!debian/patches'
60                         etype=$netype
61                         netype=Upstream
62                         ;;
63                 Changelog/Packaging|\
64                 Changelog/Upstream)
65                         git diff --quiet $expect..$cid -- \
66                                 ':.' ':!debian/changelog'
67                         etype=Packaging
68                         ;;
69                 Upstream/SAME)
70                         git diff --quiet $expect..$cid -- ':debian'
71                         ;;
72                 BreakwaterUpstreamMerge/Upstream| \
73                 BreakwaterUpstreamMerge/Packaging)
74                         break
75                         ;;
76                 *)
77                         fail "etype=$etype ctype=$ctype cetype=$cetype $cid"
78                         ;;
79                 esac
80
81                 local cnparents=`printf "%s" "$parents" | wc -w`
82                 test $cnparents = $enparents
83
84                 case "$parents" in
85                 *"$expect"*)    ;;
86                 *)              fail 'unexpected parent' ;;
87                 esac
88
89         done
90 }