MCPcopy Create free account
hub / github.com/Louisym/MiniCC / read_git_status

Function read_git_status

tutorials/06_system_prompt_builder.py:190–202  ·  view source on GitHub ↗

读取 git status 快照

(cwd: str)

Source from the content-addressed store, hash-verified

188# 这样 AI 就知道你当前改了哪些文件、有没有未提交的修改。
189
190def read_git_status(cwd: str) -> Optional[str]:
191 """读取 git status 快照"""
192 try:
193 result = subprocess.run(
194 ["git", "--no-optional-locks", "status", "--short", "--branch"],
195 cwd=cwd, capture_output=True, text=True, timeout=5,
196 )
197 if result.returncode != 0:
198 return None
199 output = result.stdout.strip()
200 return output if output else None
201 except (subprocess.TimeoutExpired, FileNotFoundError):
202 return None
203
204
205def read_git_diff(cwd: str) -> Optional[str]:

Callers 1

discover_with_gitMethod · 0.70

Calls 1

runMethod · 0.80

Tested by

no test coverage detected