chiark / gitweb /
test suite: lib-import-chk: Test commit authorship
[dgit.git] / tests / lib-import-chk
1
2 t-import-chk-authorship () {
3         perl -ne 'print $1,"\n" if m/^ -- (\S.*\>)  /' debian/changelog \
4                 | sort -u \
5                 > $tmp/authorship.changelog
6         git log --pretty=format:'%an <%ae>%n%cn <%ce>' \
7                 | sort -u \
8                 > $tmp/authorship.commits
9         diff $tmp/authorship.{changelog,commits}
10 }
11
12 t-import-chk1 () {
13         p=$1
14         v=$2
15
16         t-archive $p $v
17 }
18 t-import-chk2() {
19         t-git-none
20         rm -rf $p
21         t-dgit --no-rm-on-error clone $p
22
23         # And now we make an update using the same orig tarball, and
24         # check that the orig import is stable.
25
26         cd $p
27
28         t-import-chk-authorship
29
30         git branch first-import
31
32         m='Commit for import check'
33         echo "$m" >>import-check
34
35         v=${v%-*}-99
36         dch -v $v -D unstable -m "$m"
37
38         git add import-check debian/changelog
39         git commit -m "$m"
40
41         t-dgit -wgf quilt-fixup
42         t-dgit -wgf build-source
43
44         # The resulting .dsc does not have a Dgit line (because dgit push
45         # puts that in).  So we just shove it in the archive now
46
47         ln ../${p}_${v}.* $tmp/mirror/pool/main/
48         t-archive-query
49
50         t-dgit fetch
51
52         git branch first-2nd-import remotes/dgit/dgit/sid
53
54         t-git-next-date
55
56         git update-ref refs/remotes/dgit/dgit/sid first-import
57
58         t-dgit fetch
59
60         t-refs-same-start
61         t-ref-same refs/remotes/dgit/dgit/sid
62         t-ref-same refs/heads/first-2nd-import
63
64         for orig in ../${p}_${v%-*}.orig*.tar.*; do
65                 tar -atf $orig | LC_ALL=C sort >../files.o
66                 pfx=$(perl <../files.o -ne '
67                         while (<>) {
68                                 m#^([^/]+/)# or exit 0;
69                                 $x //= $1;
70                                 $x eq $1 or exit 0;
71                         }
72                         print "$x\n";
73                 ')
74                 perl -i~ -pe '
75                         s#^\Q'"$pfx"'\E##;
76                         $_="" if m/^$/ || m#/$# || m#^\.git/#;
77                 ' ../files.o
78                 orig=${orig#../}
79                 pat="^Import ${orig//./\\.}\$"
80                 t-refs-same-start
81                 for start in first-import first-2nd-import; do
82                         git log --pretty='tformat:%H' --grep "$pat" $start \
83                                 >../t.imp
84                         test $(wc -l <../t.imp) = 1
85                         imp=$(cat ../t.imp)
86                         t-ref-same-val "$orig $start" "$imp"
87                 done
88                 git ls-tree -r --name-only "$t_ref_val:" \
89                         | sort >../files.g
90                 diff ../files.{o,g}
91         done
92         cd ..
93 }
94
95 t-import-chk() { t-import-chk1 "$@"; t-import-chk2; }
96