aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-12-27 19:50:45 +0100
committerGuido Günther <agx@sigxcpu.org>2011-12-28 10:31:34 +0100
commit0a462f437763014123b75f9784f4bf17cfc809cd (patch)
tree0e33e248671b7bec9f1300554de786d09685f3cc /gbp/scripts
parent6850005ea0652a314a154e978f3dbe793801d57c (diff)
dch: Split guessing of upstream version into separate function
Diffstat (limited to 'gbp/scripts')
-rw-r--r--gbp/scripts/dch.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index ed6a3aaf..2d4a8ed4 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -102,25 +102,33 @@ def add_changelog_entry(msg, author, email, dch_options):
spawn_dch(msg=msg, author=author, email=email, dch_options=dch_options)
+def guess_version_from_upstream(repo, upstream_tag_format, cp):
+ """
+ Guess the version based on the latest version on the upstream branch
+ """
+ pattern = upstream_tag_format.replace('%(version)s', '*')
+ try:
+ tag = repo.find_tag('HEAD', pattern=pattern)
+ upstream = repo.tag_to_version(tag, upstream_tag_format)
+ if upstream:
+ gbp.log.debug("Found upstream version %s." % upstream)
+ new_version = "%s-1" % upstream
+ if compare_versions(upstream, cp.version) > 0:
+ return new_version
+ except GitRepositoryError:
+ gbp.log.debug("No tag found matching pattern %s." % pattern)
+ return None
+
+
def add_changelog_section(msg, distribution, repo, options, cp,
- author=None, email=None, version=None, dch_options=''):
+ author=None, email=None, version={}, dch_options=''):
"""Add a new section to the changelog"""
- # If no version(change) was specified guess the new version based on the
- # latest upstream version on the upstream branch
if not version and not cp.is_native():
- pattern = options.upstream_tag.replace('%(version)s', '*')
- try:
- tag = repo.find_tag('HEAD', pattern=pattern)
- upstream = repo.tag_to_version(tag, options.upstream_tag)
- if upstream:
- gbp.log.debug("Found %s." % upstream)
- new_version = "%s-1" % upstream
- if compare_versions(upstream, cp['Version']) > 0:
- version['version'] = new_version
- except GitRepositoryError:
- gbp.log.debug("No tag found matching pattern %s." % pattern)
- spawn_dch(msg=msg, newversion=True, version=version, author=author, email=email,
- distribution=distribution, dch_options=dch_options)
+ v = guess_version_from_upstream(repo, options.upstream_tag, cp)
+ if v:
+ version['version'] = v
+ spawn_dch(msg=msg, newversion=True, version=version, author=author,
+ email=email, distribution=distribution, dch_options=dch_options)
def get_author_email(repo, use_git_config):