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