From b37741885c18dae927faaba08a7849ca21d35b7c Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 19 Dec 2025 22:05:31 +0100 Subject: [PATCH] patch-git: Address issues identified in automated code review Resolves: RHEL-137213 RPM-Changelog: - RPM-Skip-Release: yes --- patch-git.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/patch-git.lua b/patch-git.lua index c975eb7..6d20c54 100644 --- a/patch-git.lua +++ b/patch-git.lua @@ -644,7 +644,7 @@ local function parse_commits() break end local l = string.match(line, remove_indent) - if not l then break + if not l then -- No longer the commit message. break end @@ -1681,9 +1681,7 @@ local function parse_commit_messages() -- A Patch-Git-Version commit on its own does not tell us how to -- interpret previous history. The first commit setting version/release -- must also set the patch-git version. - if patchgit_version - and patchgit_version and release_known and changelog_known - then + if patchgit_version and release_known and changelog_known then start_commit = i break end @@ -1717,14 +1715,16 @@ do Dec=12, } function git_date_to_rpm_date(s) - local wd, mon, d, y = string.match( - s, '^([A-z][a-z][a-z]) ([A-Z][a-z][a-z]) (%d+) %d%d:%d%d:%d%d (%d+)') - assert(y, s) - local m = assert(months[mon], s) - local rpmdate = string.format('%s %s %02d %04d', wd, mon, d, y) - local ymd = string.format('%04d-%02d-%02d', y, m, d) - return rpmdate, ymd + local wd, mon, d, y = string.match( + s, '^([A-Z][a-z][a-z]) ([A-Z][a-z][a-z]) (%d+) %d%d:%d%d:%d%d (%d+)') + assert(y, s) + local m = assert(months[mon], s) + local rpmdate = string.format('%s %s %02d %04d', wd, mon, d, y) + local ymd = string.format('%04d-%02d-%02d', y, m, d) + return rpmdate, ymd end + assert_eq({git_date_to_rpm_date('Fri Dec 5 14:39:48 2025 +0100')}, + {'Fri Dec 05 2025', '2025-12-05'}) end -- Tests for git_date_to_rpm_date. do @@ -2028,7 +2028,7 @@ else print('FAIL: term=' .. term .. ', status=' .. status) end end - if fail then + if failure then os.exit(1) end end