diff options
-rw-r--r-- | docs/manpages/gbp-dch.xml | 13 | ||||
-rw-r--r-- | gbp/config.py | 1 | ||||
-rw-r--r-- | gbp/scripts/dch.py | 9 | ||||
-rw-r--r-- | tests/component/deb/test_dch.py | 9 |
4 files changed, 31 insertions, 1 deletions
diff --git a/docs/manpages/gbp-dch.xml b/docs/manpages/gbp-dch.xml index e85cb777..82a98334 100644 --- a/docs/manpages/gbp-dch.xml +++ b/docs/manpages/gbp-dch.xml @@ -73,6 +73,7 @@ <arg><option>--commit</option></arg> </group> <arg><option>--customizations=</option><replaceable>customization-file</replaceable></arg> + <arg><option>--postedit=</option><replaceable>COMMAND</replaceable></arg> <arg rep='repeat'><option>--dch-opt=</option><replaceable>dch-options</replaceable></arg> <arg><option>--verbose</option></arg> <arg choice="plain"><replaceable><optional>path1 path2</optional></replaceable></arg> @@ -503,6 +504,18 @@ </listitem> </varlistentry> <varlistentry> + <term><option>--postedit=</option><replaceable>COMMAND</replaceable> + </term> + <listitem> + <para> + Run<replaceable>COMMAND</replaceable> after changes to the changelog + file have been finalized, That is, after dch has been run and + possible text editor has been exited, but, before changes are + (possibly) committed to git. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--dch-opt=</option><replaceable>dch-option</replaceable> </term> <listitem> diff --git a/gbp/config.py b/gbp/config.py index afd11408..d63754ea 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -156,6 +156,7 @@ class GbpOptionParser(OptionParser): 'pbuilder-options': '', 'postbuild': '', 'postclone': '', + 'postedit': '', 'postexport': '', 'postimport': '', 'posttag': '', diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index a086464c..0087166a 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -31,6 +31,7 @@ from gbp.deb.source import DebianSource, DebianSourceError from gbp.deb.git import GitRepositoryError, DebianGitRepository from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.scripts.common import ExitCodes, maybe_debug_raise +from gbp.scripts.common.hook import Hook user_customizations = {} snapshot_re = re.compile("\s*\*\* SNAPSHOT build @(?P<commit>[a-z0-9]+)\s+\*\*") @@ -423,6 +424,9 @@ def build_parser(name): custom_group.add_config_file_option(option_name="customizations", dest="customization_file", help=help_msg) + custom_group.add_config_file_option(option_name="postedit", dest="postedit", + help="Hook to run after changes to the changelog file" + "have been finalized default is '%(postedit)s'") return parser @@ -572,6 +576,11 @@ def main(argv): if editor_cmd: gbpc.Command(editor_cmd, ["debian/changelog"])() + if options.postedit: + cp = ChangeLog(filename=changelog) + Hook('Postimport', options.postedit, + extra_env={'GBP_DEBIAN_VERSION': cp.version})() + if options.commit: # Get the version from the changelog file (since dch might # have incremented it, there's no way we can already know diff --git a/tests/component/deb/test_dch.py b/tests/component/deb/test_dch.py index 3d969b14..96c5d5a1 100644 --- a/tests/component/deb/test_dch.py +++ b/tests/component/deb/test_dch.py @@ -25,7 +25,7 @@ from tests.component.deb.fixtures import RepoFixtures import gbp.scripts.dch from gbp.scripts.dch import main as dch -from nose.tools import ok_ +from nose.tools import eq_, ok_ def _dsc_file(pkg, version, dir='dsc-3.0'): @@ -61,3 +61,10 @@ class TestDch(ComponentTestBase): cl = f.read() ok_('* testentry\n' in cl) del gbp.scripts.dch.user_customizations['format_changelog_entry'] + + @RepoFixtures.native() + def test_postedit_hook(self, repo): + os.chdir(repo.path) + eq_(dch(['arg0', '-N', '1.2.3', '--postedit', 'echo $GBP_DEBIAN_VERSION > foo.txt']), 0) + with open('foo.txt') as f: + eq_(f.read(), '1.2.3\n') |