(self, args: str, context: CommandContext)
| 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 | |
| 80 | DIFF_COMMAND = DiffCommand( |
nothing calls this directly
no test coverage detected