Guido,
On Mon, Dec 29, 2008 at 02:53:47PM +0100, Guido Günther wrote:
> I was thinking of adding a simple:
>
> # use author information from git:
> git-author=True/False
>
> to gbp.conf and corresponding --git-author/--no-git-author commandline
> options to git-dch. Making git-author default to False would keep
> existing behaviour.
This would be great. I have just added git-author=True to my ~/.gbp.conf
and so I get the behaviour I need, and nothing can break for anyone
else.
I've implemented this in the same way as --sign-tags as you suggested.
Updated patch below.
---
docs/manpages/git-dch.sgml | 8 ++++++++
gbp/config.py | 3 +++
gbp/git_utils.py | 6 ++++++
git-dch | 15 ++++++++++++---
4 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/docs/manpages/git-dch.sgml b/docs/manpages/git-dch.sgml
index be23906..91a97b6 100644
--- a/docs/manpages/git-dch.sgml
+++ b/docs/manpages/git-dch.sgml
@@ -33,6 +33,7 @@
<arg><option>--meta-closes=bug-close-tags</option></arg>
<arg><option>--snapshot-number=</option><replaceable>expression</replaceable></arg>
<arg><option>--git-log=</option><replaceable>git-log-options</replaceable></arg>
+ <arg><option>--git-author</option></arg>
<arg choice="plain"><replaceable>[path1 path2]</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -178,6 +179,13 @@
all.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--git-author</option>
+ </term>
+ <listitem>
+ <para>Use user.name and user.email from
<application>git-config</application>(1) for changelog trailer</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/gbp/config.py b/gbp/config.py
index 20bb4a9..2787bf5 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -46,6 +46,7 @@ class GbpOptionParser(OptionParser):
'meta-closes' : 'Closes|LP',
'id-length' : '0',
'no-dch' : 'False',
+ 'git-author' : 'False',
}
help = {
'debian-branch':
@@ -64,6 +65,8 @@ class GbpOptionParser(OptionParser):
"use pristine-tar to create .orig.tar.gz, default is
'%(pristine-tar)s'",
'filter':
"files to filter out during import (can be given multiple
times)",
+ 'git-author':
+ "use name and email from git-config for changelog trailer,
default is '%(git-author)s'"
}
config_files = [ '/etc/git-buildpackage/gbp.conf',
os.path.expanduser('~/.gbp.conf'),
diff --git a/gbp/git_utils.py b/gbp/git_utils.py
index da8884e..ce4ebed 100644
--- a/gbp/git_utils.py
+++ b/gbp/git_utils.py
@@ -153,6 +153,12 @@ class GitRepository(object):
GitRm(verbose=verbose)(files)
return not self.is_clean()[0]
+ def get_config(self, name):
+ """Gets the config value associated with name"""
+ self.__check_path()
+ value, ret = self.__git_getoutput('config', [ name ])
+ if ret: raise KeyError
+ return value[0][:-1] # first line with \n ending removed
def create_repo(path):
"""create a repository at path"""
diff --git a/git-dch b/git-dch
index d356422..aee717f 100755
--- a/git-dch
+++ b/git-dch
@@ -82,11 +82,19 @@ def add_changelog_section(msg, distribution, author=None,
email=None, version=No
spawn_dch(msg=msg, newversion= True, version=version, author=author,
email=email, distribution=distribution)
-def fixup_trailer():
+def fixup_trailer(repo, git_author=False):
"""fixup the changelog trailer's comitter and email address - it might
otherwise point to the last git committer instead of the person creating
the changelog"""
- spawn_dch(msg='')
+ author = email = None
+ if git_author:
+ try: author = repo.get_config('user.name')
+ except KeyError: pass
+
+ try: email = repo.get_config('user.email')
+ except KeyError: pass
+
+ spawn_dch(msg='', author=author, email=email)
def head_commit():
@@ -279,6 +287,7 @@ def main(argv):
help="mark as snapshot build")
version_group.add_option("-N", "--new-version", dest="new_version",
help="use this as base for the new version number")
+ version_group.add_config_file_option(option_name="git-author",
dest="git_author", action="store_true")
commit_group.add_config_file_option(option_name="meta", dest="meta",
help="parse meta tags in commit messages, default is
'%(meta)s'", action="store_true")
commit_group.add_config_file_option(option_name="meta-closes",
dest="meta_closes",
@@ -355,7 +364,7 @@ def main(argv):
if commits:
shortlog_to_dch(repo, commits, options)
- fixup_trailer()
+ fixup_trailer(repo, git_author=options.git_author)
elif not first_commit:
print "No changes detected from %s to %s." % (since, until)
--
1.5.6.3
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]