--- Begin Message ---
Package: git-buildpackage
Version: 0.6.0~git20120404
Severity: wishlist
File: /usr/bin/git-dch
Dear Maintainer,
In my attempts to automate my debian packaging handling by git workflow,
I attach a preview patch to get some comments.
My wish is to let git-dch handle debian/changelog automatically and let
that file out of my way (it's present only on tagged debian version).
This works nice with a preexisting package, to release a new version:
1. I never edit myself debian/changelog, nor run git-dch or dch on my
packaging development branch
2. when I want to build a new package, I checkout the previous tagged
debian version in my "debian_branch"
3. I merge my packaging development branch in the "debian_branch"
4. I run "git-dch -a --spawn-editor=none debian/", this calculate the new
version number
based on upstream tag
When I start a new package, I want:
1. dh_make to get things mostly done
2. rm debian/changelog
3. edit debian/* and commit that
4. do the same as above for preexisting packages
My current caveats are:
- Pass the package name to dch
- Pass the distribution to dch[1]
- Make the "dch --create" silent according to git-dch --spawn-editor
option
To be noted when removing the debian/changelog from an existing package
to handle it this way:
git-dch do not get to the "git rm debian/changelog" commit
So, to avoid loosing commit messages:
1. all commit logs before the "git rm debian/changelog" must be packaged
(with a tagged debian version for point 2 in my release workflow)
2. the "git rm debian/changelog" commit must be "alone" or the commit
message will be lost.
Regards.
diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index 3a4a02a..2b060d1 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -112,9 +112,9 @@ def guess_version_from_upstream(repo, upstream_tag_format, cp):
version = repo.tag_to_version(tag, upstream_tag_format)
if version:
gbp.log.debug("Found upstream version %s." % version)
- if cp.has_epoch():
+ if hasattr(cp, 'has_epoch') and cp.has_epoch():
version = "%s:%s" % (cp.epoch, version)
- if compare_versions(version, cp.version) > 0:
+ if compare_versions(version, cp['Version']) > 0:
return "%s-1" % version
except GitRepositoryError:
gbp.log.debug("No tag found matching pattern %s." % pattern)
@@ -124,7 +124,7 @@ def guess_version_from_upstream(repo, upstream_tag_format, cp):
def add_changelog_section(msg, distribution, repo, options, cp,
author=None, email=None, version={}, dch_options=''):
"""Add a new section to the changelog"""
- if not version and not cp.is_native():
+ if not version and not (hasattr(cp,'is_native') and cp.is_native()):
v = guess_version_from_upstream(repo, options.upstream_tag, cp)
if v:
version['version'] = v
@@ -270,7 +270,7 @@ def guess_snapshot_commit(cp, repo, options):
# If the current topmost changelog entry has already been tagged rely on
# the version information only. The upper level relies then on the version
# info anyway:
- if repo.find_version(options.debian_tag, cp.version):
+ if repo.find_version(options.debian_tag, cp['Version']):
return None
# If we didn't find a snapshot header we look at the point the changelog
# was last touched.
@@ -416,7 +416,12 @@ def main(argv):
gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch))
raise GbpError, "Use --ignore-branch to ignore or --debian-branch to set the branch name."
- cp = ChangeLog(filename=changelog)
+ try:
+ cp = ChangeLog(filename=changelog)
+ except NoChangeLogError, err:
+ gbp.log.info("No debian/changelog: create a new one")
+ cp = {'Changes': '', 'Version': ''}
+ dch_options += " --create"
if options.since:
since = options.since
@@ -429,7 +434,7 @@ def main(argv):
found_snapshot_header = True
else:
gbp.log.info("Couldn't find snapshot header, using version info")
- if not since:
+ if dch_options.find(" --create") == -1 and not since:
since = repo.find_version(options.debian_tag, cp['Version'])
if not since:
raise GbpError, "Version %s not found" % cp['Version']
@@ -441,14 +446,14 @@ def main(argv):
commits.reverse()
# add a new changelog section if:
- if options.new_version or options.bpo or options.nmu or options.qa:
+ if options.new_version or options.bpo or options.nmu or options.qa or dch_options.find(" --create") != -1:
if options.bpo:
version_change['increment'] = '--bpo'
elif options.nmu:
version_change['increment'] = '--nmu'
elif options.qa:
version_change['increment'] = '--qa'
- else:
+ elif dch_options.find(" --create") == -1:
version_change['version'] = options.new_version
# the user wants to force a new version
add_section = True
@@ -484,6 +489,8 @@ def main(argv):
cp=cp)
# Adding a section only needs to happen once.
add_section = False
+ # Like creating new changelog
+ dch_options = dch_options.replace(' --create', '')
else:
add_changelog_entry(commit_msg, commit_author, commit_email, dch_options)
@@ -516,7 +523,7 @@ def main(argv):
if editor_cmd:
gbpc.Command(editor_cmd, ["debian/changelog"])()
- except (GbpError, GitRepositoryError, NoChangeLogError), err:
+ except (GbpError, GitRepositoryError), err:
if len(err.__str__()):
gbp.log.err(err)
ret = 1
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (90, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.2.4+hati.1+ (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages git-buildpackage depends on:
ii devscripts 2.11.6
ii git 1:1.7.9.5-1
ii python 2.7.2-10
ii python-dateutil 1.5-1
ii python2.6 2.6.7-4
ii python2.7 2.7.3~rc2-2
Versions of packages git-buildpackage recommends:
ii cowbuilder <none>
ii pristine-tar 1.24
Versions of packages git-buildpackage suggests:
ii python-notify 0.1.1-3
ii unzip 6.0-6
-- no debconf information
Footnotes:
[1] http://bugs.debian.org/646684
--
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF
pgpqS1xK9QIVW.pgp
Description: PGP signature
--- End Message ---