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