From aaabaa1b35df5de428ad1a70b46263dfe71205c7 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 13 Nov 2026 14:40:06 +0200 Subject: [PATCH] Fail the license header check when git merge-file errors --- .../main/python/license-headers/check_license_headers.py | 2 +- .../python/license-headers/test_check_license_headers.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/src/main/python/license-headers/check_license_headers.py b/tools/src/main/python/license-headers/check_license_headers.py index a01d776e43..20d99d52dc 100644 --- a/tools/src/main/python/license-headers/check_license_headers.py +++ b/tools/src/main/python/license-headers/check_license_headers.py @@ -231,7 +231,7 @@ def merged_ce_bases(repo, head, baseline): def merge_blobs(repo, ours, base, theirs): - result = run(["git", "merge-file", "-p", "--object-id", ours, base, theirs], repo, ok=range(0, 256)) + result = run(["git", "merge-file", "-p", "--object-id", ours, base, theirs], repo, ok=range(0, 128)) return result.stdout if result.returncode == 0 else None diff --git a/tools/src/main/python/license-headers/test_check_license_headers.py b/tools/src/main/python/license-headers/test_check_license_headers.py index 9989f5b2ec..68f0526267 100644 --- a/tools/src/main/python/license-headers/test_check_license_headers.py +++ b/tools/src/main/python/license-headers/test_check_license_headers.py @@ -663,6 +663,14 @@ class GitHistoryTests(unittest.TestCase): self.assertEqual(b"ONE\ntwo\nthree\nfour\nFIVE\n", p.merge_blobs(git.root, ours, base, theirs)) self.assertIsNone(p.merge_blobs(git.root, ours, base, blob("uno\ntwo\nthree\nfour\nfive\n"))) + def test_merge_blobs_fails_when_git_cannot_merge(self): + git = GitFixture(temporary_directory(self), "main") + git.write("File.java", "one\n") + git.commit("base") + blob = git("rev-parse", "HEAD:File.java") + with self.assertRaises(p.Failure): + p.merge_blobs(git.root, blob, blob, "no-such-object") + def test_ignore_filter_keeps_tracked_and_unignored_files(self): repo = temporary_directory(self) p.git(repo, "init")