Tools: set the renameLimit for git_log to avoid warnings
Generating credits/authors would print warnings from commits that renamed many files, increase the diff.renameLimit to account for this and suppress the warning.
This commit is contained in:
@@ -57,17 +57,24 @@ class GitCommit:
|
||||
self.files
|
||||
self.files_status
|
||||
|
||||
def _log_format(self, format: str, args: Tuple[Union[str, bytes], ...] = ()) -> bytes:
|
||||
def _log_format(
|
||||
self,
|
||||
format: str,
|
||||
*,
|
||||
args_prefix: Tuple[Union[str, bytes], ...] = (),
|
||||
args_suffix: Tuple[Union[str, bytes], ...] = (),
|
||||
) -> bytes:
|
||||
# sha1 = self.sha1.decode('ascii')
|
||||
cmd: Tuple[Union[str, bytes], ...] = (
|
||||
"git",
|
||||
*args_prefix,
|
||||
"--git-dir",
|
||||
self._git_dir,
|
||||
"log",
|
||||
"-1", # only this rev
|
||||
self.sha1,
|
||||
"--format=" + format,
|
||||
*args,
|
||||
*args_suffix,
|
||||
)
|
||||
|
||||
# print(" ".join(cmd))
|
||||
@@ -141,7 +148,13 @@ class GitCommit:
|
||||
def files(self) -> List[bytes]:
|
||||
ret = self._files
|
||||
if ret is None:
|
||||
ret = [f for f in self._log_format("format:", args=("--name-only",)).split(b"\n") if f]
|
||||
ret = [
|
||||
f for f in self._log_format(
|
||||
"format:",
|
||||
args_prefix=("-c", "diff.renameLimit=10000"),
|
||||
args_suffix=("--name-only",),
|
||||
).split(b"\n") if f
|
||||
]
|
||||
self._files = ret
|
||||
return ret
|
||||
|
||||
@@ -149,7 +162,14 @@ class GitCommit:
|
||||
def files_status(self) -> List[List[bytes]]:
|
||||
ret = self._files_status
|
||||
if ret is None:
|
||||
ret = [f.split(None, 1) for f in self._log_format("format:", args=("--name-status",)).split(b"\n") if f]
|
||||
ret = [
|
||||
f.split(None, 1) for f in self._log_format(
|
||||
"format:",
|
||||
args_prefix=("-c", "diff.renameLimit=10000"),
|
||||
args_suffix=("--name-status",),
|
||||
).split(b"\n")
|
||||
if f
|
||||
]
|
||||
self._files_status = ret
|
||||
return ret
|
||||
|
||||
@@ -157,7 +177,11 @@ class GitCommit:
|
||||
def diff(self) -> str:
|
||||
ret = self._diff
|
||||
if ret is None:
|
||||
content = self._log_format("", args=("-p",))
|
||||
content = self._log_format(
|
||||
"",
|
||||
args_prefix=("-c", "diff.renameLimit=10000"),
|
||||
args_suffix=("-p",),
|
||||
)
|
||||
ret = content.decode("utf8", errors="ignore")
|
||||
self._diff = ret
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user