chiark / gitweb /
929153b3aa72d31632aaf3d3613deb289c7f730b
[dgit.git] / tests / tests / tagupl
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-dependencies DEBORIG git-debpush
6
7 t-debpolicy
8
9 t-archive-none example
10 t-git-none
11 t-worktree 1.0
12
13 v=1.0-1
14
15 t-tagupl-settings
16
17 cd $p
18 git checkout -b native 
19
20 git checkout --orphan upstream quilt-tip-2
21 git rm -rf debian
22 git commit -m 'pseudo-upstream'
23 git tag upstream/1.0
24
25 git checkout -B master quilt-tip-2
26
27 upstream=$(git rev-parse upstream/1.0~0)
28 tagname=test-dummy/$v
29
30 t-tagupl-test --no-push --quilt=gbp
31
32 # xxx test pushing
33
34 # todo: test each miss/rejection
35
36 ident=ok
37
38 git cat-file tag $tagname >../basetag
39 v=1.0-2
40 tagname=test-dummy/$v
41
42 perl -i -ne '
43         next if $.==1../^$/;
44         next if m/^----/..0;
45         s/\b1\.0-1\b/1.0-2/g;
46         print or die $!;
47 ' ../basetag
48
49 mv-ident () {
50         local f=$tmp/$1
51         if test -e $f; then
52                 mv $f $f--$ident
53         fi
54 }
55
56 next-mangle () {
57         mv-ident tagupl/overall.log
58         mv-ident sendmail.log
59         ident=$1
60 }
61
62 with-mangled () {
63         local perl=$1
64         perl <../basetag >../badtag-$ident -pe "$perl"
65         git tag -u Senatus -f -s -m "$(cat ../badtag-$ident)" "$tagname"
66
67         t-tagupl-run-drs
68 }
69
70 expect-quit () {
71         next-mangle "$1"
72         local perl=$2
73         local mstring=$3
74         with-mangled "$perl"
75         grep ": $mstring" ../tagupl/overall.log
76 }
77
78 expect-email () {
79         next-mangle "$1"
80         local perl=$2
81         local mstring=$3
82         with-mangled "$perl"
83         grep 'Was not successful' ../sendmail.log
84         grep "$mstring" ../sendmail.log
85         grep ": failed, emailed" ../tagupl/overall.log
86 }
87
88 tagname=test-dummy/1.2
89 t-expect-fail E:'failed command: git fetch' \
90 t-tagupl-run-drs
91
92 tagname=splorf/$v     ; expect-quit baddistro '' 'tag name not for us'
93 tagname=test-dummy/1,2; expect-quit badver    '' 'tag name not for us'
94 tagname=test-dummy/$v
95
96 expect-quit noplease s/please-upload/plunk/ 'tag missing please-upload'
97
98 expect-email vermatch 's/^example release /$&3/' 'reject: version mismatch'
99
100 expect-email unkinfo 's/^\[dgit please-upload/$& Rejectme/' \
101         'unknown dgit info in tag'
102
103 expect-quit unkdistro 's/test-dummy/ubuntu/ if m/^\[dgit/' \
104         'not for this distro'
105
106 expect-email notsplit 's/ split / no-split /' 'reject: missing "split"'
107
108 expect-email upsnot1 's/ upstream=/ uxstream=/' \
109         'reject: upstream tag and not commitish'
110
111 expect-email upsnot2 's/ upstream-tag=/ uxstream-tag=/' \
112         'reject: upstream tag and not commitish'
113
114 expect-email bupstag1 's/ upstream-tag=/$&:/' \
115         "failed command: git check-ref-format"
116
117 expect-email bupstag2 's/ upstream-tag=/$&x/' \
118         "Couldn't find remote ref refs/tags/xupstream"
119
120 expect-email upsmism 's/ upstream=/$&3/' \
121         "but tag refers to"
122
123 # we are going to trash $p because it will contain corrupted objects
124 # which makes our end-of-test fsck fail
125 cp -al ../$p ../$p.save
126 cd ../$p
127
128 next-mangle badtagger
129 git cat-file tag test-dummy/1.0-1 | perl -pe '
130         s/\+\d+$/xyz/ if m/^tagger /;
131         exit 0 if m/^$/;
132 ' >../tagobj-$ident
133 echo >>../tagobj-$ident
134 cat ../basetag >>../tagobj-$ident
135 git update-ref $tagname $(git hash-object -w -t tag ../tagobj-$ident)
136
137 cd ..
138 rm -rf $p
139 mv $p.save $p
140
141 t-ok