From 55b2bd57bfe90c30f6e8490202d8bb072b76fe3f Mon Sep 17 00:00:00 2001 From: Aleksei Shpakovskii Date: Fri, 3 Aug 2018 16:44:41 +0200 Subject: [PATCH] Fix for pgp signed commits Now, instead of `git cat-file -p $SHA` and skipping through non-empty lines in the commit header, we just run `git log --format=%B -n 1 $SHA` and get commit message directly. Previous method could break if commit header contained empty lines - this is a case for signed commits --- misc/changelog-generator/changelog-generator | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/misc/changelog-generator/changelog-generator b/misc/changelog-generator/changelog-generator index 2269e65734..0fcde6e9c8 100755 --- a/misc/changelog-generator/changelog-generator +++ b/misc/changelog-generator/changelog-generator @@ -110,12 +110,15 @@ else: for repo in repos: os.chdir(repo) - sha_list = subprocess.Popen(["git", "rev-list", "--reverse"] + sys.argv[1:], stdout=subprocess.PIPE) + sha_list = subprocess.Popen( + ["git", "rev-list", "--no-merges", "--reverse"] + sys.argv[1:], + stdout=subprocess.PIPE) for sha in sha_list.stdout: sha = sha.decode().rstrip('\n') - blob = subprocess.Popen(["git", "cat-file", "-p", sha], stdout=subprocess.PIPE) + blob = subprocess.Popen( + ["git", "log", "--format=%B", "-n", "1", sha], + stdout=subprocess.PIPE) - msg_started = False title_fetched = False title = "" commit_msg = "" @@ -125,19 +128,12 @@ for repo in repos: log_entry = "" for line in blob.stdout: line = line.decode().rstrip('\r\n') - if line == "": - if not msg_started: - msg_started = True - continue - if log_entry: - add_entry(sha, log_entry) - log_entry = "" + if line == "" and log_entry: + add_entry(sha, log_entry) + log_entry = "" log_entry_local = False - if not msg_started: - continue - # Tracker reference, remove from string. for match in re.finditer(TRACKER_REGEX, line, re.IGNORECASE): if not SHA_TO_TRACKER.get(sha):