chiark / gitweb /
test suite: gdr-new-upstream: Test updating existing clog entry
[dgit.git] / tests / tests / gdr-newupstream
1 #!/bin/bash
2 set -e
3 autoimport=
4 . tests/lib
5
6 t-dependencies NO-DGIT GDR
7
8 t-tstunt-parsechangelog
9 t-setup-import gdr-convert-gbp-noarchive
10
11 cd $p
12
13 : 'upstream hat'
14
15 t-gdr-prep-new-upstream 2.1
16
17 : 'maintainer hat'
18
19 git branch startpoint
20 v=2.1-1
21
22 git checkout master
23
24 t-expect-fail F:'Could not determine appropriate upstream commitish' \
25 t-git-debrebase new-upstream $v
26
27 git tag v2.1 upstream
28
29 git branch before-new-upstream
30
31 clog-check-1 () {
32         before=$1
33         date=$(git log --format=%aD -n1 debian/changelog)
34         date=$(date -R -d "$date")
35         git show $before:debian/changelog >../clog.before
36         m="  * Update to new upstream version ${v%-*}."
37         e="dgit test git user <dgit-test@debian.example.net>  $date"
38 }
39 clog-check-2 () {
40         diff -u ../clog.expected debian/changelog
41 }
42
43 : ----- ordinary new upstream test -----
44
45 t-git-debrebase new-upstream ${v%-*}
46
47 clog-check-1 before-new-upstream
48 cat - <<END ../clog.before >../clog.expected
49 example ($v) UNRELEASED; urgency=medium
50
51 $m
52
53  -- $e
54
55 END
56 clog-check-2
57
58 t-gdr-good laundered
59 git reflog | egrep 'debrebase new-upstream.*checkout'
60
61 t-git-debrebase stitch
62 t-gdr-good stitched
63
64 git branch ordinary
65
66 : ----- 'with --anchor' -----
67
68 git checkout -b with-anchor startpoint
69
70 t-git-debrebase analyse >../anal.anch
71 anchor=$(perl <../anal.anch -ne '
72         next unless m/^(\w+) Anchor\s/;
73         print $1,"\n";
74         exit;
75 ')
76
77 GIT_REFLOG_ACTION='STUNT-RLA' \
78 t-git-debrebase --anchor=$anchor -fanchor-treated new-upstream $v upstream
79 t-gdr-good laundered
80 git reflog | egrep 'STUNT-RLA: debrebase new-upstream'
81 git reflog | egrep 'STUNT-RLA: debrebase: launder for new upstream'
82
83 t-git-debrebase stitch
84 t-gdr-good stitched
85
86 git diff --quiet ordinary
87
88 : ----- with pre-existing changes -----
89
90 git checkout -b with-preexisting before-new-upstream
91
92 t-dch-commit drivel-in-changelog
93 git branch before-new-upstream-with-changes
94
95 t-git-next-date
96
97 t-git-debrebase new-upstream ${v%-*}
98
99 clog-check-1 before-new-upstream-with-changes
100 perl -pe <../clog.before >../clog.expected '
101         BEGIN { ($m,$e,@ARGV) = @ARGV; }
102         next unless 1..m/^ --/;
103         s/\([^()]+\)/('$v')/ if m/^example /;
104         $_ .= "$m\n" if m/^  \* drivel-in-changelog/;
105         $_ = " -- $e\n" if m/^ -- /;
106 ' "$m" "$e"
107 clog-check-2
108
109 t-ok