chiark / gitweb /
Avoid use of "my $_", which is not portable
[dgit.git] / tests / tests / trustingpolicy-replay
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-tstunt-parsechangelog
6
7 t-dsd
8 t-policy dgit-repos-policy-trusting
9 t-prep-newpackage example 1.0
10
11 cd $p
12 revision=1
13 git tag start
14
15 t-dgit build
16 t-dgit push --new
17
18 t-commit 'Prep v1.1 which will be rewound'
19 t-dgit build
20 t-dgit push
21
22 t-rm-dput-dropping
23 git checkout debian/1.0
24 t-dgit build
25 t-dgit push --deliberately-fresh-repo
26
27 remote="`git config dgit-distro.test-dummy.git-url`/$p.git"
28
29 t-expect-push-fail 'Replay of previously-rewound upload' \
30 git push "$remote" \
31         debian/1.1 \
32         debian/1.1~0:refs/dgit/sid
33
34 git checkout master
35
36
37 : "More subtle replay prevention checks"
38
39 prepare-replay () {
40         delib=$1
41
42         # We have to stop the pushes succeeding because if they work they
43         # record the tag, which prevents the replays.  We are simulating
44         # abortive pushes (since we do want to avoid a situation where
45         # dangerous old signed tags can exist).
46         t-policy false
47
48         t-commit "request with $delib that we will replay"
49         t-dgit build
50         t-expect-push-fail E:'policy-hook.*No such file or directory' \
51         t-dgit push $delib
52
53         t-policy dgit-repos-policy-trusting
54
55         replayv=$v
56 }
57
58 attempt-replay () {
59         local mpat=$1
60         git show debian/$replayv | grep -e $delib
61         t-expect-push-fail "$mpat" \
62         git push "$remote" \
63                 debian/$replayv \
64                 +debian/$replayv~0:refs/dgit/sid
65 }
66
67 prepare-replay --deliberately-fresh-repo
68
69 # simulate some other thing that we shouldn't delete
70 git push $tmp/git/$p.git +master:refs/heads/for-testing
71
72 attempt-replay 'does not declare previously heads/for-testing'
73
74 prepare-replay --deliberately-not-fast-forward
75
76 t-commit 'later version to stop not fast forward rewinding'
77 t-dgit build
78 t-dgit push
79
80 attempt-replay "does not declare previously tags/debian/$v"
81
82
83 echo ok.