chiark / gitweb /
git-debrebase: Rename new-upstream-v0 command to new-upstream
[dgit.git] / tests / tests / import-dsc
1 #!/bin/bash
2 set -e
3 . tests/lib
4 t-tstunt-parsechangelog
5
6 t-setup-import examplegit
7
8 p=example
9
10 check-import () {
11         path=$1
12         v=$2
13         opts=$3
14         branch=t.$v
15
16         dsc=${path}/${p}_${v}.dsc
17         t-dgit $opts import-dsc $dsc $branch
18
19         git checkout $branch
20
21         check-imported $dsc
22 }
23
24 check-imported () {
25         local dsc=$1
26         (
27         rm -rf ../t.unpack
28         mkdir ../t.unpack
29         cd ../t.unpack
30         dpkg-source -x $dsc
31         )
32
33         git checkout HEAD~0
34         git branch -D u.$v ||:
35         git checkout -b u.$v $branch
36         git rm -rf .
37         git clean -xdf
38         cp -al ../t.unpack/*/. .
39         git add -Af .
40
41         git diff --stat --exit-code
42 }
43
44 cd $p
45
46 check-import ../mirror/pool/main 1.2
47
48 dgit12=`git rev-parse HEAD`
49
50 dsc2=../mirror/pool/main/${p}_2.0.dsc
51
52 git checkout $branch
53 t-expect-fail 'is checked out - will not update' \
54 t-dgit import-dsc $dsc2 $branch
55
56 git checkout HEAD~0
57
58 t-expect-fail 'Not fast forward' \
59 t-dgit import-dsc $dsc2 $branch
60
61 t-expect-fail 'Not fast forward' \
62 t-dgit import-dsc $dsc2 ..$branch
63
64 t-dgit import-dsc $dsc2 +$branch
65 check-imported $dsc2
66
67 cd ..
68 mkdir $p.2
69 cd $p.2
70
71 git init
72
73 check-import $troot/pkg-srcs 1.0-1
74
75 cd ..
76 v=1.0-1+absurd
77 rm -f ${p}_*
78 dsc=$troot/pkg-srcs/${p}_${v}.dsc
79 cd $p.2
80
81 cp $dsc ..
82 t-expect-fail 'it does not exist' \
83 check-import .. $v
84
85 mkdir ../enoents
86 cp $dsc ../enoents
87 t-expect-fail 'No such file or directory' \
88 check-import ../enoents $v
89
90 cd ..
91 rm -f ${p}_${v}.dsc
92 dget -du file://$dsc
93 cd $p.2
94
95 check-import .. $v
96
97 t-expect-fail "Your git tree does not have that object" \
98 check-import ../mirror/pool/main 1.2 --no-chase-dsc-distro
99
100 check-import ../mirror/pool/main 1.2 --force-import-dsc-with-dgit-field
101
102 v=1.0-1.100
103 dsc2=$troot/pkg-srcs/${p}_${v}.dsc
104
105 t-expect-fail E:'Branch.*already exists' \
106 t-dgit import-dsc $dsc2 $branch
107
108 git branch merge-reset
109 t-dgit import-dsc $dsc2 ..$branch
110 t-has-ancestor merge-reset $branch
111
112 git push . +merge-reset:$branch
113
114 t-dgit import-dsc $dsc2 +$branch
115
116 mb=$(t-git-merge-base merge-reset $branch)
117 test "x$mb" = x
118
119 t-expect-fail 'signature check failed' \
120 t-dgit import-dsc --require-valid-signature $dsc2 +$branch
121
122 t-ok