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