Skip to content

Commit ac2e90a

Browse files
update command for analyzing new item names to use git diff instead of git show (#4939)
1 parent dc15b70 commit ac2e90a

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

ci/coding_guidelines_check.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,17 @@ def analysis_new_item_name(root: Path, commit: str) -> bool:
219219
220220
For any directory name in the repo, it is required to use '-' to replace '_'.
221221
"""
222-
GIT_SHOW_CMD = f"git show --oneline --name-status --diff-filter A {commit}"
222+
GIT_DIFF_CMD = f"git diff --name-status --diff-filter=A {commit}"
223223
try:
224224
invalid_items = True
225225
output = subprocess.check_output(
226-
shlex.split(GIT_SHOW_CMD), cwd=root, universal_newlines=True
226+
shlex.split(GIT_DIFF_CMD), cwd=root, universal_newlines=True
227227
)
228228
if not output:
229229
return True
230230

231-
NEW_FILE_PATTERN = "^A\s+(\S+)"
232-
for line_no, line in enumerate(output.split("\n")):
233-
# bypass the first line, usually it is the commit description
234-
if line_no == 0:
235-
continue
231+
NEW_FILE_PATTERN = r"^A\s+(\S+)"
232+
for line in output.split("\n"):
236233

237234
if not line:
238235
continue

0 commit comments

Comments
 (0)