MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / format_git_status

Function format_git_status

src/context_system/git_context.py:197–226  ·  view source on GitHub ↗

Format git context as a string for the systemContext.gitStatus key. Mirrors TS getGitStatus output format from context.ts.

(ctx: GitContextSnapshot)

Source from the content-addressed store, hash-verified

195# ---------------------------------------------------------------------------
196
197def format_git_status(ctx: GitContextSnapshot) -> str:
198 """
199 Format git context as a string for the systemContext.gitStatus key.
200
201 Mirrors TS getGitStatus output format from context.ts.
202 """
203 if not ctx.available:
204 return ""
205
206 parts: list[str] = []
207 parts.append("Git repository detected.")
208
209 if ctx.branch:
210 parts.append(f"Current branch: {ctx.branch}")
211 if ctx.default_branch:
212 parts.append(f"Default branch: {ctx.default_branch}")
213 if ctx.user_name:
214 parts.append(f"User: {ctx.user_name}")
215
216 if ctx.status:
217 parts.append(f"\nStatus:\n{ctx.status}")
218 if ctx.status_truncated:
219 parts.append("(Status output was truncated)")
220 else:
221 parts.append("\nWorking tree clean.")
222
223 if ctx.recent_commits:
224 parts.append(f"\nRecent commits:\n{ctx.recent_commits}")
225
226 return "\n".join(parts)

Callers 6

test_unavailableMethod · 0.90
test_full_contextMethod · 0.90
test_clean_treeMethod · 0.90
test_truncated_statusMethod · 0.90
_build_git_sectionFunction · 0.85
get_system_contextFunction · 0.85

Calls 2

joinMethod · 0.80
appendMethod · 0.45

Tested by 4

test_unavailableMethod · 0.72
test_full_contextMethod · 0.72
test_clean_treeMethod · 0.72
test_truncated_statusMethod · 0.72