summaryrefslogtreecommitdiff
path: root/tests/tests/import-dsc
blob: bdd849ca1060e75d8fcff9aac988d5ea94b7a4a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
set -e
. tests/lib
t-tstunt-parsechangelog

t-setup-import examplegit

p=example

check-import () {
	path=$1
	v=$2
	opts=$3
	branch=t.$v

	dsc=${path}/${p}_${v}.dsc
	t-dgit $opts import-dsc $dsc $branch

	git checkout $branch

	check-imported $dsc
}

check-imported () {
	local dsc=$1
	(
	rm -rf ../t.unpack
	mkdir ../t.unpack
	cd ../t.unpack
	dpkg-source -x $dsc
	)

	git checkout HEAD~0
	git branch -D u.$v ||:
	git checkout -b u.$v $branch
	git rm -rf .
	git clean -xdf
	cp -al ../t.unpack/*/. .
	git add -Af .

	git diff --stat --exit-code
}

cd $p

check-import ../mirror/pool/main 1.2

dgit12=`git rev-parse HEAD`

dsc2=../mirror/pool/main/${p}_2.0.dsc

git checkout $branch
t-expect-fail 'is checked out - will not update' \
t-dgit import-dsc $dsc2 $branch

git checkout HEAD~0

t-expect-fail 'Not fast forward' \
t-dgit import-dsc $dsc2 $branch

t-expect-fail 'Not fast forward' \
t-dgit import-dsc $dsc2 ..$branch

t-dgit import-dsc $dsc2 +$branch
check-imported $dsc2

cd ..
mkdir $p.2
cd $p.2

git init

check-import $troot/pkg-srcs 1.0-1

cd ..
v=1.0-1+absurd
rm -f ${p}_*
dsc=$troot/pkg-srcs/${p}_${v}.dsc
cd $p.2

cp $dsc ..
t-expect-fail 'it does not exist' \
check-import .. $v

mkdir ../enoents
cp $dsc ../enoents
t-expect-fail 'No such file or directory' \
check-import ../enoents $v

cd ..
rm -f ${p}_${v}.dsc
dget -du file://$dsc
cd $p.2

check-import .. $v

t-expect-fail "Your git tree does not have that object" \
check-import ../mirror/pool/main 1.2 --no-chase-dsc-distro

check-import ../mirror/pool/main 1.2 --force-import-dsc-with-dgit-field

v=1.0-1.100
dsc2=$troot/pkg-srcs/${p}_${v}.dsc

t-expect-fail E:'Branch.*already exists' \
t-dgit import-dsc $dsc2 $branch

git branch merge-reset
t-dgit import-dsc $dsc2 ..$branch
t-has-ancestor merge-reset $branch

git push . +merge-reset:$branch

t-dgit import-dsc $dsc2 +$branch

mb=$(t-git-merge-base merge-reset $branch)
test "x$mb" = x

t-expect-fail 'signature check failed' \
t-dgit import-dsc --require-valid-signature $dsc2 +$branch

t-ok