MCPcopy
hub / github.com/ChinaGodMan/UserScripts / is_file_changed_in_last_commit

Function is_file_changed_in_last_commit

utils/helper.py:45–57  ·  view source on GitHub ↗
(file_path)

Source from the content-addressed store, hash-verified

43
44# 比较提交记录
45def is_file_changed_in_last_commit(file_path):
46 try:
47 result = subprocess.run(
48 ['git', 'diff', '--name-only', 'HEAD^', 'HEAD'],
49 capture_output=True,
50 text=True,
51 check=True
52 )
53 changed_files = result.stdout.splitlines()
54 return file_path in changed_files
55 except subprocess.CalledProcessError as e:
56 print(f"Error occurred while running git command: {e}")
57 return False
58
59
60def is_file_modified(file_path):

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected