Skip to content

Commit 1be5834

Browse files
committed
Normalize the Merge: hash hash line
Git by default abbreviates SHA-1 commit hashes to a short form that is long enough to be unambiguous within that repository clone. This change normalizes the number of characters that we check to 8.
1 parent c5c9068 commit 1be5834

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

common.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def getReleaseLog (report, ctsPath, releaseTagStr):
9393

9494
pushWorkingDir(ctsPath)
9595
checkoutReleaseTag(report, releaseTagStr)
96-
gitlog = git('log', '-1', '--decorate=no', releaseTagStr)
96+
gitlog = git('log', '-1', '--decorate=no', '--abbrev=12', releaseTagStr)
9797
releaseLog[0] = sanitizeReleaseLog(gitlog)
9898

9999
if isKCCTSRelease(releaseTagStr):
@@ -307,6 +307,22 @@ def sanitizePackageLog(log, report = None):
307307
slog = slog.rstrip('\n')
308308
return slog
309309

310+
MERGE_LINE_RE = re.compile(r'^Merge:\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)$')
311+
312+
def normalizeMergeLine(line):
313+
"""
314+
Normalize 'Merge:' lines by truncating each commit hash to 8 characters.
315+
Example:
316+
'Merge: d822ba6124fb 4ccd715fb1e4'
317+
→ 'Merge: d822ba61 4ccd715f'
318+
"""
319+
match = MERGE_LINE_RE.match(line.strip())
320+
if match:
321+
short1 = match.group(1)[:8]
322+
short2 = match.group(2)[:8]
323+
return f"Merge: {short1} {short2}"
324+
return line
325+
310326
def normalizeWhitespace(text):
311327
"""
312328
Normalize whitespace in text to handle formatting differences between
@@ -326,6 +342,7 @@ def normalizeWhitespace(text):
326342
for line in lines:
327343
# Replace multiple whitespace characters with single space
328344
normalized_line = ' '.join(line.split())
345+
normalized_line = normalizeMergeLine(normalized_line)
329346
normalized_lines.append(normalized_line)
330347

331348
# Join lines back together, removing empty lines at the end

0 commit comments

Comments
 (0)