feat: add git file status and enhanced git widgets#208
Open
tejasdc wants to merge 1 commit intosirmalloc:mainfrom
Open
feat: add git file status and enhanced git widgets#208tejasdc wants to merge 1 commit intosirmalloc:mainfrom
tejasdc wants to merge 1 commit intosirmalloc:mainfrom
Conversation
…hind, conflicts, clean status, SHA) Add granular git repository status widgets addressing issue sirmalloc#20: - GitStagedFiles: staged file count (S:N format) - GitUnstagedFiles: unstaged file count (M:N format) - GitUntrackedFiles: untracked file count (A:N format) - GitAheadBehind: upstream ahead/behind tracking (↑N ↓M format) - GitMergeConflicts: merge conflict count (⚠N, hidden when 0) - GitCleanStatus: clean/dirty indicator (✓/✗) - GitSha: short commit SHA All widgets follow existing patterns: Widget interface, git-no-git shared helpers, hideNoGit support, rawValue support, and cross-platform git commands via runGit(). Includes shared getGitFileStatusCounts() utility for the file count widgets. 21 new tests across 7 test files + shared behavior test entries. Closes sirmalloc#20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 7 new git widgets addressing issue #20 ("Add enhanced git status options to git widgets"). These provide granular git repository status information that the current widget set lacks — file-level counts, upstream tracking, conflict detection, clean/dirty status, and commit SHA.
All widgets follow existing patterns exactly: Widget interface,
git-no-gitshared helpers,hideNoGitmetadata support,rawValuemode, and cross-platform git commands viarunGit().Comparable in scope to PR #201 (Skills widget) — 19 files changed, 1,378 lines added.
New Widgets
git-staged-filesS:33git diff --cached --name-onlygit-unstaged-filesM:22git diff --name-onlygit-untracked-filesA:11git ls-files --others --exclude-standardgit-ahead-behind↑2 ↓12 1git rev-list --left-right --count HEAD...@{upstream}git-merge-conflicts⚠11git diff --name-only --diff-filter=Ugit-clean-status✓/✗clean/dirtygit status --porcelaingit-shaa3f2c1dgit rev-parse --short HEADEdge Cases
git-ahead-behindshows(no upstream)or hides viahideNoGitgit-merge-conflictsreturnsnull(hidden) — only visible when conflicts existS:0,M:0,A:0— counts are always meaningfulgit-shaworks normally;git-ahead-behindfalls back to no-upstream behaviorComplementary to PR #153
PR #153 (
git-indicators) adds binary yes/no indicators for staged/unstaged. These widgets provide actual counts and cover additional features (untracked files, ahead/behind, conflicts, clean status, SHA). The two are complementary, not overlapping.Changes
src/widgets/GitStagedFiles.tssrc/widgets/GitUnstagedFiles.tssrc/widgets/GitUntrackedFiles.tssrc/widgets/GitAheadBehind.tssrc/widgets/GitMergeConflicts.tssrc/widgets/GitCleanStatus.tssrc/widgets/GitSha.tssrc/widgets/__tests__/GitStagedFiles.test.tssrc/widgets/__tests__/GitUnstagedFiles.test.tssrc/widgets/__tests__/GitUntrackedFiles.test.tssrc/widgets/__tests__/GitAheadBehind.test.tssrc/widgets/__tests__/GitMergeConflicts.test.tssrc/widgets/__tests__/GitCleanStatus.test.tssrc/widgets/__tests__/GitSha.test.tssrc/utils/git.tsgetGitFileStatusCounts()utility +GitFileStatusCountsinterfacesrc/utils/__tests__/git.test.tssrc/widgets/index.tssrc/utils/widget-manifest.tssrc/widgets/__tests__/GitWidgetSharedBehavior.test.ts14 new files + 5 modified files = 19 files total
Implementation Details
Shared Utility:
getGitFileStatusCounts()Added to
src/utils/git.ts— returns{ staged, unstaged, untracked }counts. Used by the three file count widgets to avoid redundant git command logic.Pattern Compliance
Every widget follows the exact patterns established by existing git widgets:
Widgetinterface fromsrc/types/Widget.tsgit-no-gitshared helpers forhideNoGittoggle and keybindsisInsideGitWorkTree()to gate git operationsrunGit()for all git commands (cross-platform viachild_process.execSync)rawValuemode where applicablenullto hide when appropriate (no git, no upstream, no conflicts)Test Plan
GitAheadBehindadditionally tested for: no-upstream (empty output), no-upstream (throw), invalid output parsingGitMergeConflictstested for: zero conflicts returning null (hidden)getGitFileStatusCounts()utility testedbun run lintpasses (TypeScript type checking + ESLint)Closes #20