Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions add_new_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,21 +684,33 @@ def get_uncommitted_sol_files(self):
print("Git command is not available. Skipping uncommitted file retrieval.")
return []

command = f"git ls-files --others --exclude-standard {self.constants.SRC_TEST_DIR}/**/*.sol"
output = subprocess.check_output(command, shell=True, text=True)
uncommitted_files = output.strip().split("\n")
return uncommitted_files
try:
# Use argument list instead of shell=True for better robustness
args = ["git", "ls-files", "--others", "--exclude-standard", self.constants.SRC_TEST_DIR]
output = subprocess.check_output(args, text=True)
files = output.strip().split("\n")
# Filter for .sol files manually to avoid shell globbing issues
uncommitted_files = [f for f in files if f.endswith(".sol") and f]
return uncommitted_files
except subprocess.CalledProcessError:
return []

def get_recently_committed_sol_files(self) -> list:
"""Get list of recently committed .sol files"""
if not self.is_git_command_available():
print("Git command is not available. Skipping recently committed file retrieval.")
return []

command = f"git diff --name-only HEAD~1 HEAD {self.constants.SRC_TEST_DIR}/**/*.sol"
output = subprocess.check_output(command, shell=True, text=True)
recently_committed_files = output.strip().split("\n")
return recently_committed_files
try:
# Use argument list and specify the directory to restrict the diff
args = ["git", "diff", "--name-only", "HEAD~1", "HEAD", "--", self.constants.SRC_TEST_DIR]
output = subprocess.check_output(args, text=True)
files = output.strip().split("\n")
# Filter for .sol files
recently_committed_files = [f for f in files if f.endswith(".sol") and f]
return recently_committed_files
except subprocess.CalledProcessError:
return []


######################
Expand Down