Browse Source

Keep log.follow and log.showSignature from changing the license check history walks

pull/16341/head
Viacheslav Klimov 2 months ago
parent
commit
920109463f
Failed to extract signature
  1. 12
      tools/src/main/python/license-headers/check_license_headers.py
  2. 12
      tools/src/main/python/license-headers/test_check_license_headers.py

12
tools/src/main/python/license-headers/check_license_headers.py

@ -259,8 +259,8 @@ class Change:
def history(repo, revision, *options):
raw = git(repo, "log", "--first-parent", "--diff-merges=first-parent", "--root", "--raw", "--no-abbrev",
"--no-renames", "-z", "--format=%x1e%H", *options, revision, "--")
raw = git(repo, "log", "--no-show-signature", "--first-parent", "--diff-merges=first-parent", "--root", "--raw",
"--no-abbrev", "--no-renames", "-z", "--format=%x1e%H", *options, revision, "--")
return list(parse_history(raw))
@ -906,8 +906,8 @@ class RenameChain:
def ce_renames(repo, head, bases, ce_paths):
# The relicensing squash pairs deleted CE files with similar PE files; that is not a rename.
raw = git(repo, "log", "-M", "-l0", "--raw", "--no-abbrev", "-z", "--diff-filter=R", "--format=%x1e%H",
head, "--not", *bases, "--")
raw = git(repo, "log", "--no-show-signature", "-M", "-l0", "--raw", "--no-abbrev", "-z", "--diff-filter=R",
"--format=%x1e%H", head, "--not", *bases, "--")
hops = {(change.commit, change.path): change for change in parse_history(raw) if change.commit != RELICENSING_COMMIT}
sources = defaultdict(set)
for hop in hops.values():
@ -958,8 +958,8 @@ def in_ce_history(repo, revision, bases, path):
def creations(repo, revision, bases, path):
return git(repo, "--literal-pathspecs", "log", "--topo-order", "--no-renames", "--diff-filter=A", "--format=%H",
revision, "--not", *bases, "--", path).decode().split()
return git(repo, "--literal-pathspecs", "log", "--no-show-signature", "--no-follow", "--topo-order", "--no-renames",
"--diff-filter=A", "--format=%H", revision, "--not", *bases, "--", path).decode().split()
def comparable_ce_files(comparison, names):

12
tools/src/main/python/license-headers/test_check_license_headers.py

@ -624,6 +624,18 @@ class GitHistoryTests(unittest.TestCase):
lineage = p.Lineage.load(git.root, git("rev-parse", "HEAD"), [base])
self.assertEqual({"B.java": ("A.java", "ce")}, rename_origins(lineage))
def test_lineage_ignores_log_settings_of_the_user(self):
git = GitFixture(temporary_directory(self), "ce")
git.write("A.java", "".join(f"CE line {index}\n" for index in range(20)))
base = git.commit("CE base")
git("checkout", "-b", "downstream")
git("mv", "A.java", "B.java")
git.commit("rename")
git("config", "log.follow", "true")
git("config", "log.showSignature", "true")
self.assertEqual({"B.java": ("A.java", "ce")},
rename_origins(p.Lineage.load(git.root, git("rev-parse", "HEAD"), [base])))
def test_lineage_follows_the_side_of_a_merge_that_kept_the_file(self):
git = GitFixture(temporary_directory(self), "ce")
body = "".join(f"CE line {index}\n" for index in range(20))

Loading…
Cancel
Save