patch-git: Support more Git trailers in patch-git (RHEL-173109)
The patch-git tool now ignores commonly used Git trailers (Acked-by, Assisted-by, Reviewed-by, Reported-by, Signed-off-by, Suggested-by) instead of rejecting them as unrecognized tags. Resolves: RHEL-173109 Assisted-by: LLM RPM-Changelog: - RPM-Skip-Release: yes
This commit is contained in:
parent
3aadd3fdf3
commit
77ff0a1f13
@ -1207,9 +1207,22 @@ do
|
||||
assert(not b and err == 'Branch must be zstream')
|
||||
end
|
||||
|
||||
-- Parser for ignored tags.
|
||||
local function parse_ignore(tag, s)
|
||||
return true
|
||||
end
|
||||
|
||||
-- These are the recognized trailer tags in Git commit messages.
|
||||
-- (Git calls them keys, see git-interpret-trailers(1).)
|
||||
local recognized_trailer_tags = {
|
||||
['Acked-By']={parse=parse_ignore, duplicates=true},
|
||||
['Assisted-By']={parse=parse_ignore, duplicates=true},
|
||||
['Co-Authored-By']={parse=parse_ignore, duplicates=true},
|
||||
['Reviewed-By']={parse=parse_ignore, duplicates=true},
|
||||
['Reported-By']={parse=parse_ignore, duplicates=true},
|
||||
['Signed-Off-By']={parse=parse_ignore, duplicates=true},
|
||||
['Suggested-By']={parse=parse_ignore, duplicates=true},
|
||||
['Tested-By']={parse=parse_ignore, duplicates=true},
|
||||
['Resolves']={field='tickets',
|
||||
parse=parse_ticket_string,
|
||||
duplicates=true},
|
||||
@ -1234,6 +1247,20 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- Automatically support lower-cased "-by" variants of dev-attribution tags.
|
||||
do
|
||||
local aliases = {}
|
||||
for k, v in pairs(recognized_trailer_tags) do
|
||||
if string.sub(k, -3) == '-By' then
|
||||
aliases[string.sub(k, 1, 1) .. string.lower(string.sub(k, 2))] = v
|
||||
end
|
||||
end
|
||||
-- Second loop to avoid structural mutation while iterating.
|
||||
for k, v in pairs(aliases) do
|
||||
recognized_trailer_tags[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
function parse_trailer(message)
|
||||
-- This holds due to the format of the input file.
|
||||
assert(string.sub(message, #message) == '\n')
|
||||
@ -1467,6 +1494,65 @@ RPM-Release: no
|
||||
]])
|
||||
assert(not t)
|
||||
assert(err == 'malformed line in Git trailer after Resolves tag')
|
||||
|
||||
-- Ignored trailers.
|
||||
t, err = parse_trailer([[Fix memory leak after fdopen seek failure
|
||||
|
||||
- Backport: Remove memory leak in fdopen (bug 31840)
|
||||
|
||||
Resolves: RHEL-108475
|
||||
Signed-Off-By: Signed Off <signedoff@example.com>
|
||||
Acked-by: Acked By <acked@example.com>
|
||||
Assisted-by: Assisted By <assisted@example.com>
|
||||
Co-authored-by: Co Authored <coauthored@example.com>
|
||||
Reviewed-by: Reviewed By <reviewed@example.com>
|
||||
Reviewed-By: Another Reviewed By <anotherreviewed@example.com>
|
||||
Reported-by: Reported By <reported@example.com>
|
||||
Suggested-by: Suggested By <suggested@example.com>
|
||||
Tested-by: Tested By <tested@example.com>
|
||||
Signed-off-by: Another Signed Off <anothersignedoff@example.com>
|
||||
]])
|
||||
assert(t, err)
|
||||
assert(t.tickets)
|
||||
assert(#t.tickets == 1)
|
||||
assert(t.tickets[1] == 'RHEL-108475')
|
||||
assert(t.signed_off_by == true)
|
||||
assert(t.acked_by == true)
|
||||
assert(t.assisted_by == true)
|
||||
assert(t.co_authored_by == true)
|
||||
assert(t.reviewed_by == true)
|
||||
assert(t.reported_by == true)
|
||||
assert(t.suggested_by == true)
|
||||
assert(t.tested_by == true)
|
||||
|
||||
-- Lowercase/incorrect casing for other tags is rejected.
|
||||
t, err = parse_trailer([[Fix memory leak after fdopen seek failure
|
||||
|
||||
resolves: RHEL-108475
|
||||
]])
|
||||
assert(not t)
|
||||
assert(err == 'not a recognized Git trailer tag: resolves')
|
||||
|
||||
t, err = parse_trailer([[Fix memory leak after fdopen seek failure
|
||||
|
||||
acked-by: Acked By <acked@example.com>
|
||||
]])
|
||||
assert(not t)
|
||||
assert(err == 'not a recognized Git trailer tag: acked-by')
|
||||
|
||||
t, err = parse_trailer([[Fix memory leak after fdopen seek failure
|
||||
|
||||
parent: 1234567890abcdef1234567890abcdef12345678
|
||||
]])
|
||||
assert(not t)
|
||||
assert(err == 'not a recognized Git trailer tag: parent')
|
||||
|
||||
t, err = parse_trailer([[Fix memory leak after fdopen seek failure
|
||||
|
||||
Signed-off-By: Signed Off <signedoff@example.com>
|
||||
]])
|
||||
assert(not t)
|
||||
assert(err == 'not a recognized Git trailer tag: Signed-off-By')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user