On Tue, Apr 17, 2012 at 10:17:20PM +0200, Matthijs Kooijman wrote:
> Thanks: Matthijs Kooijman
> Closes: #669145
> ---
> I think this patch adds some value for some people, at least myself.
> Feel free to change the default for import-msg, I've just used the
> format I'm used to, but I'm not sure if there is any de facto standard
> for it.

I've always been using this:

$ alias do_release
alias do_release='DIST=`dpkg-parsechangelog | awk "/^Distribution:/{ print 
\\\$2; }"` && VERSION=`dpkg-parsechangelog | awk "/^Version:/{ print \\\$2; }"` 
&& [ -n "$VERSION" -a "$DIST" != "UNRELEASED" ] && git-commit -m"Document 
changes and release $VERSION" debian/changelog || echo "Error commiting 
changelog of $VERSION in $DIST"'

Cheers,
 -- Guido

> 
> I considered always popping up an editor to allow reviewing the commit
> message by passing --edit to git commit, but I didn't think it was worth
> the trouble (requires modifications to gbp.git.repository as well).
> 
> I'm not completely sure if the option name "commit-msg" is perfect.
> Seeing it in the list of options in gbp/config.py, it seems too generic.
> However, since it is valid only for gbp and thus will be used in the
> [gpb] section or as an argument to git-dch, where the name is not too
> generic, this is only really an issue within gbp/config.py, and only if
> another command wants to use commit-msg as well. I also guess the real
> issue is that the list of config options (and defaults and help texts)
> in gbp/config.py is global, instead of (optionally) per-command. So I'm
> not sure if this is a problem, I guess not (yet).
> 
>  docs/manpages/git-dch.sgml |   20 ++++++++++++++++++++
>  gbp/config.py              |    5 ++++-
>  gbp/scripts/dch.py         |   19 ++++++++++++++++++-
>  3 files changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/docs/manpages/git-dch.sgml b/docs/manpages/git-dch.sgml
> index 3059f8d..0d9487c 100644
> --- a/docs/manpages/git-dch.sgml
> +++ b/docs/manpages/git-dch.sgml
> @@ -37,6 +37,8 @@
>        <arg><option>--[no-]git-author</option></arg>
>        <arg><option>--[no-]multimaint-merge</option></arg>
>        <arg><option>--spawn-editor=[always|snapshot|release]</option></arg>
> +      
> <arg><option>--commit-msg=</option><replaceable>msg-format</replaceable></arg>
> +      <arg><option>--commit</option></arg>
>        <arg choice="plain"><replaceable>[path1 path2]</replaceable></arg>
>      </cmdsynopsis>
>    </refsynopsisdiv>
> @@ -221,6 +223,24 @@
>         when doing a release.</para>
>          </listitem>
>        </varlistentry>
> +      <varlistentry>
> +        
> <term><option>--commit-msg=</option><replaceable>msg-format</replaceable>
> +        </term>
> +        <listitem>
> +       <para>use this format string for the commit message when
> +       committing the generated changelog file (when
> +       <option>--commit</option> is given). Default is
> +       <replaceable>Update changelog for %(version)s
> +       release</replaceable></para>
> +        </listitem>
> +      </varlistentry>
> +      <varlistentry>
> +        <term><option>--commit</option>
> +        </term>
> +        <listitem>
> +       <para>Commit the generated changelog.</para>
> +        </listitem>
> +      </varlistentry>
>      </variablelist>
>    </refsect1>
>    <refsect1>
> diff --git a/gbp/config.py b/gbp/config.py
> index 35c78b4..d406d1e 100644
> --- a/gbp/config.py
> +++ b/gbp/config.py
> @@ -86,6 +86,7 @@ class GbpOptionParser(OptionParser):
>                   'debian-tag'      : 'debian/%(version)s',
>                   'upstream-tag'    : 'upstream/%(version)s',
>                   'import-msg'      : 'Imported Upstream version %(version)s',
> +                 'commit-msg'      : 'Update changelog for %(version)s 
> release',
>                   'filter'          : [],
>                   'snapshot-number' : 'snapshot + 1',
>                   'git-log'         : '--no-merges',
> @@ -144,7 +145,9 @@ class GbpOptionParser(OptionParser):
>               'keyid':
>                    "GPG keyid to sign tags with, default is '%(keyid)s'",
>               'import-msg':
> -                  "format string for commit message, default is 
> '%(import-msg)s'",
> +                  "format string for git-import-orig commit message, default 
> is '%(import-msg)s'",
> +             'commit-msg':
> +                  "format string for git-dch commit message, default is 
> '%(commit-msg)s'",
>               'pristine-tar':
>                    "use pristine-tar to create orig tarball, default is 
> '%(pristine-tar)s'",
>               'pristine-tar-commit':
> diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
> index 3a4a02a..14dff29 100644
> --- a/gbp/scripts/dch.py
> +++ b/gbp/scripts/dch.py
> @@ -246,7 +246,6 @@ def do_snapshot(changelog, repo, next_snapshot):
>      mangle_changelog(changelog, cp, commit)
>      return snapshot, commit
>  
> -
>  def parse_commit(repo, commitid, opts, last_commit=False):
>      """Parse a commit and return message, author, and author email"""
>      commit_info = repo.get_commit_info(commitid)
> @@ -324,6 +323,10 @@ def process_editor_option(options):
>          return None
>  
>  
> +def changelog_commit_msg(options, version):
> +    return options.commit_msg % dict(version=version)
> +
> +
>  def main(argv):
>      ret = 0
>      changelog = 'debian/changelog'
> @@ -392,6 +395,10 @@ def main(argv):
>      commit_group.add_boolean_config_file_option(option_name="multimaint", 
> dest="multimaint")
>      
> commit_group.add_boolean_config_file_option(option_name="multimaint-merge", 
> dest="multimaint_merge")
>      commit_group.add_config_file_option(option_name="spawn-editor", 
> dest="spawn_editor")
> +    parser.add_config_file_option(option_name="commit-msg",
> +                      dest="commit_msg")
> +    parser.add_option("-c", "--commit", action="store_true", dest="commit", 
> default=False,
> +                      help="commit changelog file after generating")
>  
>      help_msg = ('Load Python code from CUSTOMIZATION_FILE.  At the moment,'
>                  ' the only useful thing the code can do is define a custom'
> @@ -516,6 +523,16 @@ def main(argv):
>          if editor_cmd:
>              gbpc.Command(editor_cmd, ["debian/changelog"])()
>  
> +        if options.commit:
> +            # Get the version from the changelog file (since dch might
> +            # have incremented it, there's no way we can already know
> +            # the version).
> +            version = ChangeLog(filename=changelog).version
> +            # Commit the changes to the changelog file
> +            msg = changelog_commit_msg(options, version)
> +            repo.commit_files([changelog], msg)
> +            gbp.log.info("Changelog has been committed for version %s" % 
> version)
> +
>      except (GbpError, GitRepositoryError, NoChangeLogError), err:
>          if len(err.__str__()):
>              gbp.log.err(err)
> -- 
> 1.7.9.5
> 
> 
> 



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to