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
|
# vim: set fileencoding=utf-8 :
"""Test L{Changelog}'s guess_version_from_upstream"""
from . import context
import testutils
from gbp.scripts import dch
class TestGuessDocumentedCommit(testutils.DebianGitTestRepo):
def setUp(self):
self.version = '1.0-1'
self.tagformat = 'debian/%(version)s'
testutils.DebianGitTestRepo.setUp(self)
def test_01_from_snapshot_banner(self):
"""
Guess the commit to start from from the snapshot banner
"""
cp = testutils.MockedChangeLog(self.version,
"*** SNAPSHOT build @12345 ***")
guessed_commit = dch.guess_documented_commit(cp, None, None)
self.assertEqual(guessed_commit, '12345')
def test_02_from_tag(self):
"""
Guess the commit to start from from the tag matching
the topmost version in the changelog
"""
cp = testutils.MockedChangeLog(self.version)
self.add_file('doesnot', 'matter')
tag = self.repo.version_to_tag(self.tagformat,
self.version)
self.repo.create_tag(name=tag,
msg="Debian release %s" % self.version,
sign=False)
commit = self.repo.rev_parse('%s^0' % tag)
guessed_commit = dch.guess_documented_commit(cp,
self.repo,
self.tagformat)
self.assertEqual(guessed_commit, commit)
def test_03_from_changelog_commit(self):
"""
Guess the commit to start from from the commit that
last touched the changelog
"""
cp = testutils.MockedChangeLog(self.version)
self.add_file('debian/changelog', 'foo')
commit = self.repo.head
self.add_file('doesnot', 'matter')
guessed_commit = dch.guess_documented_commit(cp,
self.repo,
self.tagformat)
self.assertEqual(guessed_commit, commit)
def test_04_not_touched(self):
"""
None of the above matched so we want to start from
the beginning of history
"""
cp = testutils.MockedChangeLog(self.version)
self.add_file('doesnot', 'matter')
self.add_file('doesnot', 'mattereither')
guessed_commit = dch.guess_documented_commit(cp,
self.repo,
self.tagformat)
self.assertIsNone(guessed_commit)
|