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

Method run

src/command_system/diff_command.py:54–77  ·  view source on GitHub ↗
(self, args: str, context: CommandContext)

Source from the content-addressed store, hash-verified

52 ``ctx.ui``."""
53
54 async def run(self, args: str, context: CommandContext) -> InteractiveOutcome:
55 # Lazy import so `import src.command_system` doesn't pull the git/utils stack.
56 from src.utils.git import get_repo_root, get_session_diff
57
58 cwd = str(context.cwd)
59 if get_repo_root(cwd) is None:
60 # get_repo_root distinguishes not-a-repo from no-changes (both give "" from
61 # the diff helper otherwise).
62 return InteractiveOutcome("Not a git repository.", display="system")
63
64 # Staged + unstaged = the "uncommitted changes" TS shows via `git diff HEAD`,
65 # rendered as two labeled sections (avoids double-counting and handles a repo
66 # with no commits, which a literal `git diff HEAD` can't). Untracked files are
67 # not shown — matching TS's `git diff HEAD`.
68 staged = get_session_diff(cwd, staged=True)
69 unstaged = get_session_diff(cwd)
70 sections: list[str] = []
71 if (staged.diff_text or "").strip():
72 sections.append(_section("Staged changes", staged))
73 if (unstaged.diff_text or "").strip():
74 sections.append(_section("Unstaged changes", unstaged))
75 if not sections:
76 return InteractiveOutcome("No uncommitted changes.", display="system")
77 return InteractiveOutcome(_cap("\n\n".join(sections)), display="system")
78
79
80DIFF_COMMAND = DiffCommand(

Callers

nothing calls this directly

Calls 7

get_repo_rootFunction · 0.90
get_session_diffFunction · 0.90
InteractiveOutcomeClass · 0.85
_sectionFunction · 0.85
_capFunction · 0.85
joinMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected