chiark / gitweb /
c7396c4306540f2894d9c38c0092a55fbd1d9aa4
[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 cd $p
16 git checkout -b native 
17
18 git checkout --orphan upstream quilt-tip-2
19 git rm -rf debian
20 git commit -m 'pseudo-upstream'
21 git tag upstream/1.0
22
23 git checkout -B master quilt-tip-2
24
25 t-tagupl-settings
26
27 tagname=test-dummy/$v
28
29 t-tagupl-test --quilt=gbp
30
31 # todo: test each miss/rejection
32
33 ident=ok
34
35 git cat-file tag $tagname >../basetag
36 v=1.0-2
37 tagname=test-dummy/$v
38
39 perl -i -ne '
40         next if $.==1../^$/;
41         next if m/^----/..0;
42         s/\b1\.0-1\b/1.0-2/g;
43         print or die $!;
44 ' ../basetag
45
46 mv-ident () {
47         local f=$tmp/$1
48         if test -e $f; then
49                 mv $f $f--$ident
50         fi
51 }
52
53 next-mangle () {
54         mv-ident tagupl/overall.log
55         mv-ident sendmail.log
56         ident=$1
57 }
58
59 with-mangled () {
60         local perl=$1
61         perl <../basetag >../badtag-$ident -pe "$perl"
62         git tag -u Senatus -f -s -m "$(cat ../badtag-$ident)" "$tagname"
63
64         t-tagupl-run-drs $tmp/$p
65 }
66
67 expect-quit () {
68         next-mangle "$1"
69         local perl=$2
70         local mstring=$3
71         with-mangled "$perl"
72         grep ": $mstring" ../tagupl/overall.log
73 }
74
75 expect-email () {
76         next-mangle "$1"
77         local perl=$2
78         local mstring=$3
79         with-mangled "$perl"
80         grep 'Was not successful' ../sendmail.log
81         grep "$mstring" ../sendmail.log
82         grep ": failed, emailed" ../tagupl/overall.log
83 }
84
85 raw-mangled () {
86         git update-ref refs/tags/$tagname \
87                 $(git hash-object -w -t tag ../tagobj-$ident)
88         t-tagupl-run-drs $tmp/$p
89 }
90
91 tagname=test-dummy/1.2
92 t-expect-fail E:'failed command: git fetch' \
93 t-tagupl-run-drs $tmp/$p
94
95 tagname=splorf/$v     ; expect-quit baddistro '' 'tag name not for us'
96 tagname=test-dummy/1,2; expect-quit badver    '' 'tag name not for us'
97 tagname=test-dummy/$v
98
99 expect-quit noplease s/please-upload/plunk/ 'tag missing please-upload'
100
101 expect-email vermatch 's/^example release /$&3/' 'reject: version mismatch'
102
103 expect-email unkinfo 's/^\[dgit please-upload/$& Rejectme/' \
104         'unknown dgit info in tag'
105
106 expect-quit unkdistro 's/test-dummy/ubuntu/ if m/^\[dgit/' \
107         'not for this distro'
108
109 expect-email notsplit 's/ split / no-split /' 'reject: missing "split"'
110
111 expect-email upsnot1 's/ upstream=/ uxstream=/' \
112         'reject: upstream tag and not commitish'
113
114 expect-email upsnot2 's/ upstream-tag=/ uxstream-tag=/' \
115         'reject: upstream tag and not commitish'
116
117 expect-email bupstag1 's/ upstream-tag=/$&:/' \
118         "failed command: git check-ref-format"
119
120 expect-email bupstag2 's/ upstream-tag=/$&x/' \
121         "Couldn't find remote ref refs/tags/xupstream"
122
123 expect-email wrongver '' 'mismatch: changelog Version'
124
125 v=1.0-2
126
127 t-dch-commit -v $v -m bump
128
129 expect-email upsmism 's/ upstream=/$&3/' \
130         "but tag refers to"
131
132 expect-email wrongpkg 's/^example /explosive /' 'mismatch: changelog Source'
133
134 # we are going to trash $p because it will contain corrupted objects
135 # which makes our end-of-test fsck fail
136 cp -al ../$p ../$p.save
137 cd ../$p
138
139 git cat-file tag $tagname >../raw-base
140
141 next-mangle sigfail
142 perl -pe <../raw-base >../tagobj-$ident 's/ split / split ignoreme /'
143 raw-mangled
144 grep 'gpgv: BAD signature' ../sendmail.log
145
146 next-mangle nosig
147 perl -ne <../raw-base >../tagobj-$ident 'print unless m/^-----/..0'
148 raw-mangled
149 grep 'missing signature' ../sendmail.log
150
151 git cat-file tag test-dummy/1.0-1 >../raw-base
152
153 next-mangle badtagger
154 perl -pe <../raw-base '
155         s/\+\d+$/xyz/ if m/^tagger /;
156         exit 0 if m/^$/;
157 ' >../tagobj-$ident
158 echo >>../tagobj-$ident
159 cat ../basetag >>../tagobj-$ident
160 raw-mangled
161 grep 'failed to fish tagger out of tag' ../tagupl/overall.log
162
163 cd ..
164 rm -rf $p
165 mv $p.save $p
166
167 t-ok