[debrepatch] 01/01: debpatch: fix --source-version when d/changelog is present

Ximin Luo infinity0 at debian.org
Wed Apr 19 20:21:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository debrepatch.

commit 6575ff9fe36b3b6416d6e9badc6d500509361a36
Author: Ximin Luo <infinity0 at debian.org>
Date:   Wed Apr 19 22:19:54 2017 +0200

    debpatch: fix --source-version when d/changelog is present
---
 debpatch | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/debpatch b/debpatch
index 578392a..f3e006e 100755
--- a/debpatch
+++ b/debpatch
@@ -41,6 +41,7 @@ C = subprocess.check_call
 
 # this can be any valid value, it doesn't appear in the final output
 DCH_DUMMY_TAIL = "\n -- debpatch dummy tool <infinity0 at debian.org>  Thu, 01 Jan 1970 00:00:00 +0000\n\n"
+CHBLOCK_DUMMY_PACKAGE = "debpatch PLACEHOLDER"
 TRY_ENCODINGS = ["utf-8", "latin-1"]
 DISTRIBUTION_DEFAULT = "experimental"
 
@@ -116,17 +117,14 @@ def check_patch(patch_str, *args, **kwargs):
 
 def debpatch(patch, patch_name, args):
     # don't change anything if...
-    dry_run = args.target_version
-
-    with open(args.changelog) as fp:
-        current = Changelog(fp.read())
+    dry_run = args.target_version or args.source_version
 
     changelog = list(filter(lambda x: is_dch(x.path), patch))
     if not changelog:
         logging.info("no debian/changelog in patch: %s" % args.patch_file)
         old_version = None
         target = ChangeBlock(
-            package = current[0].package,
+            package = CHBLOCK_DUMMY_PACKAGE,
             author = "%s <%s>" % (os.getenv("DEBFULLNAME"), os.getenv("DEBEMAIL")),
             date = email.utils.formatdate(time.time(), localtime=True),
             version = None,
@@ -146,6 +144,12 @@ def debpatch(patch, patch_name, args):
             print(old_version)
         return False
 
+    # read this here so --source-version can work even without a d/changelog
+    with open(args.changelog) as fp:
+        current = Changelog(fp.read())
+    if target.package == CHBLOCK_DUMMY_PACKAGE:
+        target.package = current[0].package
+
     if not dry_run:
         patch_str = str(patch)
         if check_patch(patch_str, "-N"):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debrepatch.git



More information about the Reproducible-commits mailing list