lite-kits 0.1.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lite_kits/__init__.py +56 -4
- lite_kits/cli.py +782 -189
- lite_kits/core/__init__.py +6 -0
- lite_kits/core/banner.py +1 -1
- lite_kits/core/conflict_checker.py +115 -0
- lite_kits/core/detector.py +177 -0
- lite_kits/core/installer.py +242 -351
- lite_kits/core/manifest.py +146 -146
- lite_kits/core/validator.py +183 -0
- lite_kits/kits/README.md +6 -6
- lite_kits/kits/dev/README.md +241 -241
- lite_kits/kits/dev/{claude/commands → commands/.claude}/audit.md +143 -143
- lite_kits/kits/dev/{claude/commands → commands/.claude}/cleanup.md +2 -2
- lite_kits/kits/{git/claude/commands → dev/commands/.claude}/commit.md +2 -2
- lite_kits/kits/{project/claude/commands → dev/commands/.claude}/orient.md +3 -4
- lite_kits/kits/{git/claude/commands → dev/commands/.claude}/pr.md +1 -1
- lite_kits/kits/{git/claude/commands → dev/commands/.claude}/review.md +202 -202
- lite_kits/kits/{project/claude/commands → dev/commands/.claude}/stats.md +162 -162
- lite_kits/kits/{project/github/prompts → dev/commands/.github}/audit.prompt.md +143 -143
- lite_kits/kits/{git/github/prompts → dev/commands/.github}/cleanup.prompt.md +2 -2
- lite_kits/kits/{git/github/prompts → dev/commands/.github}/commit.prompt.md +2 -2
- lite_kits/kits/dev/{github/prompts → commands/.github}/orient.prompt.md +3 -4
- lite_kits/kits/{git/github/prompts → dev/commands/.github}/pr.prompt.md +1 -1
- lite_kits/kits/{git/github/prompts → dev/commands/.github}/review.prompt.md +202 -202
- lite_kits/kits/dev/{github/prompts → commands/.github}/stats.prompt.md +163 -163
- lite_kits/kits/kits.yaml +497 -180
- lite_kits/kits/multiagent/README.md +6 -6
- lite_kits/kits/multiagent/{claude/commands → commands/.claude}/sync.md +331 -331
- lite_kits/kits/multiagent/{github/prompts → commands/.github}/sync.prompt.md +73 -69
- lite_kits/kits/multiagent/memory/git-worktrees-protocol.md +370 -370
- lite_kits/kits/multiagent/memory/parallel-work-protocol.md +536 -536
- lite_kits/kits/multiagent/memory/pr-workflow-guide.md +275 -275
- lite_kits/kits/multiagent/templates/collaboration-structure/README.md +166 -166
- lite_kits/kits/multiagent/templates/decision.md +79 -79
- lite_kits/kits/multiagent/templates/handoff.md +95 -95
- lite_kits/kits/multiagent/templates/session-log.md +68 -68
- lite_kits-0.3.2.dist-info/METADATA +259 -0
- lite_kits-0.3.2.dist-info/RECORD +41 -0
- {lite_kits-0.1.1.dist-info → lite_kits-0.3.2.dist-info}/licenses/LICENSE +21 -21
- lite_kits/kits/dev/claude/commands/commit.md +0 -612
- lite_kits/kits/dev/claude/commands/orient.md +0 -146
- lite_kits/kits/dev/claude/commands/pr.md +0 -593
- lite_kits/kits/dev/claude/commands/review.md +0 -202
- lite_kits/kits/dev/claude/commands/stats.md +0 -162
- lite_kits/kits/dev/github/prompts/audit.prompt.md +0 -143
- lite_kits/kits/dev/github/prompts/cleanup.prompt.md +0 -382
- lite_kits/kits/dev/github/prompts/commit.prompt.md +0 -591
- lite_kits/kits/dev/github/prompts/pr.prompt.md +0 -603
- lite_kits/kits/dev/github/prompts/review.prompt.md +0 -202
- lite_kits/kits/git/README.md +0 -365
- lite_kits/kits/git/claude/commands/cleanup.md +0 -361
- lite_kits/kits/git/scripts/bash/get-git-context.sh +0 -208
- lite_kits/kits/git/scripts/powershell/Get-GitContext.ps1 +0 -242
- lite_kits/kits/project/README.md +0 -228
- lite_kits/kits/project/claude/commands/audit.md +0 -143
- lite_kits/kits/project/claude/commands/review.md +0 -112
- lite_kits/kits/project/github/prompts/orient.prompt.md +0 -150
- lite_kits/kits/project/github/prompts/review.prompt.md +0 -112
- lite_kits/kits/project/github/prompts/stats.prompt.md +0 -163
- lite_kits-0.1.1.dist-info/METADATA +0 -447
- lite_kits-0.1.1.dist-info/RECORD +0 -58
- {lite_kits-0.1.1.dist-info → lite_kits-0.3.2.dist-info}/WHEEL +0 -0
- {lite_kits-0.1.1.dist-info → lite_kits-0.3.2.dist-info}/entry_points.txt +0 -0
@@ -1,361 +0,0 @@
|
|
1
|
-
---
|
2
|
-
description: Clean up merged branches
|
3
|
-
---
|
4
|
-
|
5
|
-
# Branch Cleanup
|
6
|
-
|
7
|
-
**Purpose**: Safely delete local branches that have been merged, keeping your workspace clean.
|
8
|
-
|
9
|
-
## Usage
|
10
|
-
|
11
|
-
```bash
|
12
|
-
/cleanup # Clean up local branches only
|
13
|
-
/cleanup --remote # Also delete from remote
|
14
|
-
/cleanup --include-current # Include current branch if PR merged
|
15
|
-
```
|
16
|
-
|
17
|
-
## Prerequisites
|
18
|
-
|
19
|
-
- Git repository
|
20
|
-
- On a safe branch (not the branch you want to delete, unless using --include-current)
|
21
|
-
|
22
|
-
## Execution Steps
|
23
|
-
|
24
|
-
### 1. Get Current Branch and Base Branch
|
25
|
-
|
26
|
-
```bash
|
27
|
-
# Get current branch
|
28
|
-
CURRENT_BRANCH=$(git branch --show-current)
|
29
|
-
|
30
|
-
# Determine base branch (develop or main)
|
31
|
-
for base in develop main master; do
|
32
|
-
if git show-ref --verify --quiet refs/heads/$base; then
|
33
|
-
BASE_BRANCH=$base
|
34
|
-
break
|
35
|
-
fi
|
36
|
-
done
|
37
|
-
|
38
|
-
echo "Current branch: $CURRENT_BRANCH"
|
39
|
-
echo "Base branch: $BASE_BRANCH"
|
40
|
-
```
|
41
|
-
|
42
|
-
### 1a. Check if Current Branch Should Be Included
|
43
|
-
|
44
|
-
**If `--include-current` flag is present OR current branch is merged with no uncommitted work**:
|
45
|
-
|
46
|
-
```bash
|
47
|
-
# Check if current branch is merged into base
|
48
|
-
if git merge-base --is-ancestor HEAD origin/$BASE_BRANCH 2>/dev/null; then
|
49
|
-
# Check if there are any commits ahead of base
|
50
|
-
COMMITS_AHEAD=$(git rev-list --count origin/$BASE_BRANCH..HEAD)
|
51
|
-
|
52
|
-
if [ $COMMITS_AHEAD -eq 0 ]; then
|
53
|
-
# PR was merged, current branch is fully in base
|
54
|
-
echo "✓ Current branch PR appears to be merged (no commits ahead of $BASE_BRANCH)"
|
55
|
-
|
56
|
-
# Check for uncommitted changes
|
57
|
-
if git diff-index --quiet HEAD --; then
|
58
|
-
INCLUDE_CURRENT=true
|
59
|
-
echo "⚠️ Current branch can be deleted (will switch to $BASE_BRANCH first)"
|
60
|
-
else
|
61
|
-
echo "⚠️ Current branch has uncommitted changes - won't auto-delete"
|
62
|
-
INCLUDE_CURRENT=false
|
63
|
-
fi
|
64
|
-
fi
|
65
|
-
fi
|
66
|
-
```
|
67
|
-
|
68
|
-
**If current branch should be included**:
|
69
|
-
```
|
70
|
-
⚠️ Your current branch (dev/004-cleanup-command) appears to be merged!
|
71
|
-
|
72
|
-
The PR has been merged into develop with no additional commits.
|
73
|
-
|
74
|
-
Include current branch in cleanup?
|
75
|
-
- Will switch to develop first
|
76
|
-
- Then delete dev/004-cleanup-command
|
77
|
-
|
78
|
-
Include? (y/n): _____
|
79
|
-
```
|
80
|
-
|
81
|
-
**Safety check**:
|
82
|
-
```
|
83
|
-
⚠️ Currently on: dev/004-cleanup-command
|
84
|
-
|
85
|
-
Cleanup will check branches merged into: develop
|
86
|
-
|
87
|
-
Continue? (y/n): _____
|
88
|
-
```
|
89
|
-
|
90
|
-
### 2. Find Merged Branches
|
91
|
-
|
92
|
-
```bash
|
93
|
-
# Get all merged branches (excluding current, base, and protected branches)
|
94
|
-
git branch --merged $BASE_BRANCH | \
|
95
|
-
grep -v "^\*" | \
|
96
|
-
grep -v "$BASE_BRANCH" | \
|
97
|
-
grep -v "main" | \
|
98
|
-
grep -v "master" | \
|
99
|
-
grep -v "develop"
|
100
|
-
```
|
101
|
-
|
102
|
-
**If no merged branches found**:
|
103
|
-
```
|
104
|
-
✓ No merged branches to clean up.
|
105
|
-
|
106
|
-
All branches are either:
|
107
|
-
- Currently active
|
108
|
-
- Protected (main/develop/master)
|
109
|
-
- Unmerged
|
110
|
-
|
111
|
-
Workspace is clean!
|
112
|
-
```
|
113
|
-
|
114
|
-
**If merged branches found**, analyze each:
|
115
|
-
```bash
|
116
|
-
# For each merged branch, get last commit info
|
117
|
-
for branch in $MERGED_BRANCHES; do
|
118
|
-
LAST_COMMIT=$(git log -1 --format="%ar by %an" $branch)
|
119
|
-
LAST_HASH=$(git log -1 --format="%h" $branch)
|
120
|
-
echo "$branch | $LAST_HASH | $LAST_COMMIT"
|
121
|
-
done
|
122
|
-
```
|
123
|
-
|
124
|
-
### 3. Present Branches for Cleanup
|
125
|
-
|
126
|
-
Show branches in a code block with clear formatting:
|
127
|
-
|
128
|
-
```
|
129
|
-
**🧹 Merged Branches Available for Cleanup:**
|
130
|
-
|
131
|
-
**Base branch:** develop
|
132
|
-
|
133
|
-
**Merged branches:**
|
134
|
-
|
135
|
-
1. dev/001-starter-kits
|
136
|
-
Last commit: 5b1ad35 (2 days ago by tmorgan181)
|
137
|
-
|
138
|
-
2. dev/002-installer-polish
|
139
|
-
Last commit: 9cd3690 (1 day ago by tmorgan181)
|
140
|
-
|
141
|
-
3. feature/old-experiment
|
142
|
-
Last commit: abc1234 (2 weeks ago by tmorgan181)
|
143
|
-
|
144
|
-
**Protected branches** (will NOT be deleted):
|
145
|
-
- develop
|
146
|
-
- main
|
147
|
-
- dev/004-cleanup-command (current)
|
148
|
-
|
149
|
-
===========================================================
|
150
|
-
```
|
151
|
-
|
152
|
-
**Ask for confirmation**:
|
153
|
-
- **y** - Delete all listed branches
|
154
|
-
- **n** - Cancel cleanup
|
155
|
-
- **e** - Select specific branches (reply with numbers: e.g., "1 3")
|
156
|
-
|
157
|
-
### 4. Execute Cleanup
|
158
|
-
|
159
|
-
**If current branch should be deleted, switch first**:
|
160
|
-
```bash
|
161
|
-
if [ "$INCLUDE_CURRENT" = true ]; then
|
162
|
-
echo "Switching to $BASE_BRANCH..."
|
163
|
-
git checkout $BASE_BRANCH
|
164
|
-
git pull origin $BASE_BRANCH
|
165
|
-
|
166
|
-
# Add current branch to cleanup list
|
167
|
-
MERGED_BRANCHES="$MERGED_BRANCHES
|
168
|
-
$CURRENT_BRANCH"
|
169
|
-
fi
|
170
|
-
```
|
171
|
-
|
172
|
-
**If user selects specific branches (e.g., "1 3")**:
|
173
|
-
```bash
|
174
|
-
# Parse selection
|
175
|
-
SELECTED="1 3"
|
176
|
-
|
177
|
-
# Delete selected branches
|
178
|
-
for num in $SELECTED; do
|
179
|
-
# Get branch name from list
|
180
|
-
BRANCH=$(echo "$MERGED_BRANCHES" | sed -n "${num}p")
|
181
|
-
|
182
|
-
# Delete local branch
|
183
|
-
git branch -d $BRANCH
|
184
|
-
|
185
|
-
if [ $? -eq 0 ]; then
|
186
|
-
echo "✓ Deleted local: $BRANCH"
|
187
|
-
|
188
|
-
# If --remote flag, also delete from remote
|
189
|
-
if [ "$DELETE_REMOTE" = true ]; then
|
190
|
-
if git ls-remote --heads origin $BRANCH | grep -q $BRANCH; then
|
191
|
-
git push origin --delete $BRANCH
|
192
|
-
if [ $? -eq 0 ]; then
|
193
|
-
echo "✓ Deleted remote: $BRANCH"
|
194
|
-
else
|
195
|
-
echo "✗ Failed to delete remote: $BRANCH"
|
196
|
-
fi
|
197
|
-
fi
|
198
|
-
fi
|
199
|
-
else
|
200
|
-
echo "✗ Failed to delete: $BRANCH"
|
201
|
-
fi
|
202
|
-
done
|
203
|
-
```
|
204
|
-
|
205
|
-
**If user confirms all (y)**:
|
206
|
-
```bash
|
207
|
-
# Delete all merged branches
|
208
|
-
for branch in $MERGED_BRANCHES; do
|
209
|
-
# Delete local branch
|
210
|
-
git branch -d $branch
|
211
|
-
|
212
|
-
if [ $? -eq 0 ]; then
|
213
|
-
echo "✓ Deleted local: $branch"
|
214
|
-
|
215
|
-
# If --remote flag, also delete from remote
|
216
|
-
if [ "$DELETE_REMOTE" = true ]; then
|
217
|
-
if git ls-remote --heads origin $branch | grep -q $branch; then
|
218
|
-
git push origin --delete $branch
|
219
|
-
if [ $? -eq 0 ]; then
|
220
|
-
echo "✓ Deleted remote: $branch"
|
221
|
-
else
|
222
|
-
echo "✗ Failed to delete remote: $branch"
|
223
|
-
fi
|
224
|
-
fi
|
225
|
-
fi
|
226
|
-
else
|
227
|
-
echo "✗ Failed to delete: $branch"
|
228
|
-
fi
|
229
|
-
done
|
230
|
-
```
|
231
|
-
|
232
|
-
### 5. Show Summary
|
233
|
-
|
234
|
-
After cleanup, show what was done:
|
235
|
-
|
236
|
-
```
|
237
|
-
===========================================================
|
238
|
-
✓ Cleanup Complete
|
239
|
-
===========================================================
|
240
|
-
|
241
|
-
**Deleted branches:**
|
242
|
-
✓ dev/001-starter-kits
|
243
|
-
✓ dev/002-installer-polish
|
244
|
-
|
245
|
-
**Kept branches:**
|
246
|
-
- develop (protected)
|
247
|
-
- main (protected)
|
248
|
-
- dev/004-cleanup-command (current)
|
249
|
-
- feature/in-progress (unmerged)
|
250
|
-
|
251
|
-
**Workspace status:**
|
252
|
-
- 2 branches deleted
|
253
|
-
- 4 branches remaining
|
254
|
-
|
255
|
-
===========================================================
|
256
|
-
```
|
257
|
-
|
258
|
-
## Important Notes
|
259
|
-
|
260
|
-
**Safety Features**:
|
261
|
-
- Never deletes current branch (unless `--include-current` and PR is merged)
|
262
|
-
- Never deletes base branches (main, develop, master)
|
263
|
-
- Only deletes branches that are fully merged
|
264
|
-
- Uses `git branch -d` (safe delete, will fail if unmerged changes)
|
265
|
-
- Always asks for confirmation before deletion
|
266
|
-
- Remote deletion is opt-in with `--remote` flag
|
267
|
-
|
268
|
-
**Protected Branches** (never deleted automatically):
|
269
|
-
- Current branch (unless `--include-current` and PR merged with no new commits)
|
270
|
-
- `main`, `master`, `develop` (common base branches)
|
271
|
-
- Any branch that hasn't been merged
|
272
|
-
|
273
|
-
**Flags**:
|
274
|
-
- `--remote`: Also delete branches from remote repository
|
275
|
-
- `--include-current`: Allow deletion of current branch if PR is merged
|
276
|
-
|
277
|
-
**Error Handling**:
|
278
|
-
```bash
|
279
|
-
# If branch has unmerged changes
|
280
|
-
if git branch -d $branch 2>&1 | grep -q "not fully merged"; then
|
281
|
-
echo "⚠️ Branch '$branch' has unmerged changes"
|
282
|
-
echo " Use 'git branch -D $branch' to force delete (destructive!)"
|
283
|
-
echo " Skipping..."
|
284
|
-
fi
|
285
|
-
```
|
286
|
-
|
287
|
-
## Example Workflow
|
288
|
-
|
289
|
-
```bash
|
290
|
-
# User: /cleanup
|
291
|
-
|
292
|
-
# Agent checks current state
|
293
|
-
$ git branch --show-current
|
294
|
-
dev/004-cleanup-command
|
295
|
-
|
296
|
-
# Agent finds merged branches
|
297
|
-
$ git branch --merged develop
|
298
|
-
dev/001-starter-kits
|
299
|
-
dev/002-installer-polish
|
300
|
-
dev/003-git-kit-enhancements
|
301
|
-
|
302
|
-
# Agent presents options
|
303
|
-
Merged branches available for cleanup:
|
304
|
-
1. dev/001-starter-kits (2 days ago)
|
305
|
-
2. dev/002-installer-polish (1 day ago)
|
306
|
-
3. dev/003-git-kit-enhancements (2 hours ago)
|
307
|
-
|
308
|
-
Delete which branches? (y/n/e): e
|
309
|
-
|
310
|
-
# User selects
|
311
|
-
Selection: 1 2
|
312
|
-
|
313
|
-
# Agent deletes
|
314
|
-
$ git branch -d dev/001-starter-kits
|
315
|
-
Deleted branch dev/001-starter-kits (was 5b1ad35)
|
316
|
-
|
317
|
-
$ git branch -d dev/002-installer-polish
|
318
|
-
Deleted branch dev/002-installer-polish (was 9cd3690)
|
319
|
-
|
320
|
-
✓ Cleanup complete: 2 branches deleted
|
321
|
-
```
|
322
|
-
|
323
|
-
## Multi-Agent Considerations
|
324
|
-
|
325
|
-
When working with multiple agents:
|
326
|
-
|
327
|
-
1. **Check collaboration status** (if multiagent-kit installed):
|
328
|
-
```bash
|
329
|
-
# Don't delete branches with active collaboration
|
330
|
-
if [ -d "specs/*/collaboration/active" ]; then
|
331
|
-
# Check for active sessions on branches
|
332
|
-
echo "⚠️ Multi-agent project detected"
|
333
|
-
echo " Checking for active collaboration..."
|
334
|
-
fi
|
335
|
-
```
|
336
|
-
|
337
|
-
2. **Warn about shared branches**:
|
338
|
-
```
|
339
|
-
⚠️ Branch 'feature/shared' may be used by other agents.
|
340
|
-
|
341
|
-
Check collaboration status before deleting.
|
342
|
-
Safe to delete? (y/n): _____
|
343
|
-
```
|
344
|
-
|
345
|
-
3. **Preserve handoff branches**:
|
346
|
-
- Branches with recent handoff documents shouldn't be auto-deleted
|
347
|
-
- Warn user if collaboration files exist
|
348
|
-
|
349
|
-
## When NOT to Use
|
350
|
-
|
351
|
-
**Don't use /cleanup for**:
|
352
|
-
- Deleting unmerged branches (use `git branch -D` manually with caution)
|
353
|
-
- Deleting remote branches (use `git push origin --delete`)
|
354
|
-
- Deleting branches with uncommitted work (stash or commit first)
|
355
|
-
- Cleaning up worktrees (that's a multiagent-kit feature)
|
356
|
-
|
357
|
-
**Use /cleanup for**:
|
358
|
-
- ✅ Removing local branches after PR merge
|
359
|
-
- ✅ Cleaning up old feature branches
|
360
|
-
- ✅ Keeping workspace tidy
|
361
|
-
- ✅ Safe, confirmed deletions only
|
@@ -1,208 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
|
4
|
-
# get-git-context.sh
|
5
|
-
# Gathers comprehensive git repository context for AI agents
|
6
|
-
|
7
|
-
show_help() {
|
8
|
-
cat << EOF
|
9
|
-
Usage: get-git-context.sh [OPTIONS]
|
10
|
-
|
11
|
-
Gathers git status, branch information, recent commits, and change statistics
|
12
|
-
in a structured format suitable for AI agent orientation and commit workflows.
|
13
|
-
|
14
|
-
OPTIONS:
|
15
|
-
-c, --commits NUM Number of recent commits to include (default: 5)
|
16
|
-
-f, --format FORMAT Output format: text, json (default: text)
|
17
|
-
-n, --no-diff Exclude diff statistics
|
18
|
-
-h, --help Show this help message
|
19
|
-
|
20
|
-
EXAMPLES:
|
21
|
-
get-git-context.sh
|
22
|
-
get-git-context.sh --commits 10
|
23
|
-
get-git-context.sh --format json
|
24
|
-
EOF
|
25
|
-
}
|
26
|
-
|
27
|
-
# Default options
|
28
|
-
INCLUDE_COMMITS=5
|
29
|
-
FORMAT="text"
|
30
|
-
INCLUDE_DIFF=true
|
31
|
-
|
32
|
-
# Parse arguments
|
33
|
-
while [[ $# -gt 0 ]]; do
|
34
|
-
case $1 in
|
35
|
-
-c|--commits)
|
36
|
-
INCLUDE_COMMITS="$2"
|
37
|
-
shift 2
|
38
|
-
;;
|
39
|
-
-f|--format)
|
40
|
-
FORMAT="$2"
|
41
|
-
shift 2
|
42
|
-
;;
|
43
|
-
-n|--no-diff)
|
44
|
-
INCLUDE_DIFF=false
|
45
|
-
shift
|
46
|
-
;;
|
47
|
-
-h|--help)
|
48
|
-
show_help
|
49
|
-
exit 0
|
50
|
-
;;
|
51
|
-
*)
|
52
|
-
echo "Unknown option: $1"
|
53
|
-
show_help
|
54
|
-
exit 1
|
55
|
-
;;
|
56
|
-
esac
|
57
|
-
done
|
58
|
-
|
59
|
-
# Check if we're in a git repository
|
60
|
-
if ! git rev-parse --git-dir >/dev/null 2>&1; then
|
61
|
-
echo "Error: Not a git repository" >&2
|
62
|
-
exit 1
|
63
|
-
fi
|
64
|
-
|
65
|
-
# Gather git context
|
66
|
-
BRANCH=$(git branch --show-current)
|
67
|
-
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "")
|
68
|
-
|
69
|
-
# Count file statuses
|
70
|
-
STAGED_COUNT=0
|
71
|
-
UNSTAGED_COUNT=0
|
72
|
-
UNTRACKED_COUNT=0
|
73
|
-
|
74
|
-
while IFS= read -r line; do
|
75
|
-
if [[ -n "$line" ]]; then
|
76
|
-
STATUS="${line:0:2}"
|
77
|
-
|
78
|
-
# Staged files (first character)
|
79
|
-
if [[ "${STATUS:0:1}" =~ [MADRC] ]]; then
|
80
|
-
((STAGED_COUNT++))
|
81
|
-
fi
|
82
|
-
|
83
|
-
# Unstaged files (second character)
|
84
|
-
if [[ "${STATUS:1:1}" =~ [MD] ]]; then
|
85
|
-
((UNSTAGED_COUNT++))
|
86
|
-
fi
|
87
|
-
|
88
|
-
# Untracked files
|
89
|
-
if [[ "$STATUS" == "??" ]]; then
|
90
|
-
((UNTRACKED_COUNT++))
|
91
|
-
fi
|
92
|
-
fi
|
93
|
-
done < <(git status --porcelain)
|
94
|
-
|
95
|
-
# Get remote tracking info
|
96
|
-
TRACKING=$(git rev-parse --abbrev-ref --symbolic-full-name '@{u}' 2>/dev/null || echo "")
|
97
|
-
AHEAD=0
|
98
|
-
BEHIND=0
|
99
|
-
|
100
|
-
if [[ -n "$TRACKING" ]]; then
|
101
|
-
# Get ahead/behind counts
|
102
|
-
AHEAD_BEHIND=$(git rev-list --left-right --count "$TRACKING"..HEAD 2>/dev/null || echo "0 0")
|
103
|
-
AHEAD=$(echo "$AHEAD_BEHIND" | awk '{print $1}')
|
104
|
-
BEHIND=$(echo "$AHEAD_BEHIND" | awk '{print $2}')
|
105
|
-
fi
|
106
|
-
|
107
|
-
# Get remote URL
|
108
|
-
REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "")
|
109
|
-
|
110
|
-
# Get diff statistics
|
111
|
-
INSERTIONS=0
|
112
|
-
DELETIONS=0
|
113
|
-
FILES_CHANGED=0
|
114
|
-
|
115
|
-
if [[ "$INCLUDE_DIFF" == true ]] && [[ $STAGED_COUNT -gt 0 ]]; then
|
116
|
-
while IFS= read -r line; do
|
117
|
-
if [[ -n "$line" ]]; then
|
118
|
-
INS=$(echo "$line" | awk '{print $1}')
|
119
|
-
DEL=$(echo "$line" | awk '{print $2}')
|
120
|
-
|
121
|
-
# Handle binary files (-)
|
122
|
-
[[ "$INS" != "-" ]] && INSERTIONS=$((INSERTIONS + INS))
|
123
|
-
[[ "$DEL" != "-" ]] && DELETIONS=$((DELETIONS + DEL))
|
124
|
-
((FILES_CHANGED++))
|
125
|
-
fi
|
126
|
-
done < <(git diff --cached --numstat)
|
127
|
-
fi
|
128
|
-
|
129
|
-
# Output based on format
|
130
|
-
if [[ "$FORMAT" == "json" ]]; then
|
131
|
-
# JSON output
|
132
|
-
cat << EOF
|
133
|
-
{
|
134
|
-
"branch": "$BRANCH",
|
135
|
-
"commitHash": "$COMMIT_HASH",
|
136
|
-
"status": {
|
137
|
-
"counts": {
|
138
|
-
"staged": $STAGED_COUNT,
|
139
|
-
"unstaged": $UNSTAGED_COUNT,
|
140
|
-
"untracked": $UNTRACKED_COUNT
|
141
|
-
}
|
142
|
-
},
|
143
|
-
"remote": {
|
144
|
-
"tracking": "$TRACKING",
|
145
|
-
"url": "$REMOTE_URL",
|
146
|
-
"ahead": $AHEAD,
|
147
|
-
"behind": $BEHIND
|
148
|
-
},
|
149
|
-
"stats": {
|
150
|
-
"filesChanged": $FILES_CHANGED,
|
151
|
-
"insertions": $INSERTIONS,
|
152
|
-
"deletions": $DELETIONS
|
153
|
-
}
|
154
|
-
}
|
155
|
-
EOF
|
156
|
-
else
|
157
|
-
# Text output
|
158
|
-
echo "==============================================================="
|
159
|
-
echo "📊 Git Status (on: $BRANCH):"
|
160
|
-
echo "==============================================================="
|
161
|
-
echo "Staged: $STAGED_COUNT files"
|
162
|
-
echo "Unstaged: $UNSTAGED_COUNT files"
|
163
|
-
echo "Untracked: $UNTRACKED_COUNT files"
|
164
|
-
|
165
|
-
if [[ -n "$TRACKING" ]]; then
|
166
|
-
echo ""
|
167
|
-
echo "Remote: $TRACKING"
|
168
|
-
if [[ $AHEAD -gt 0 ]]; then
|
169
|
-
echo " Ahead by $AHEAD commit(s)"
|
170
|
-
fi
|
171
|
-
if [[ $BEHIND -gt 0 ]]; then
|
172
|
-
echo " Behind by $BEHIND commit(s)"
|
173
|
-
fi
|
174
|
-
fi
|
175
|
-
|
176
|
-
if [[ $STAGED_COUNT -gt 0 ]]; then
|
177
|
-
echo ""
|
178
|
-
echo "Staged files:"
|
179
|
-
git status --porcelain | grep '^[MADRC]' | while IFS= read -r line; do
|
180
|
-
echo " ${line:0:2} ${line:3}"
|
181
|
-
done
|
182
|
-
fi
|
183
|
-
|
184
|
-
if [[ $UNSTAGED_COUNT -gt 0 ]]; then
|
185
|
-
echo ""
|
186
|
-
echo "Unstaged files:"
|
187
|
-
git status --porcelain | grep '^ [MD]' | while IFS= read -r line; do
|
188
|
-
echo " ${line:0:2} ${line:3}"
|
189
|
-
done
|
190
|
-
fi
|
191
|
-
|
192
|
-
if [[ $UNTRACKED_COUNT -gt 0 ]]; then
|
193
|
-
echo ""
|
194
|
-
echo "Untracked files:"
|
195
|
-
git status --porcelain | grep '^??' | while IFS= read -r line; do
|
196
|
-
echo " ${line:0:2} ${line:3}"
|
197
|
-
done
|
198
|
-
fi
|
199
|
-
|
200
|
-
if [[ $INCLUDE_COMMITS -gt 0 ]]; then
|
201
|
-
echo ""
|
202
|
-
echo "Recent commits:"
|
203
|
-
git log -n "$INCLUDE_COMMITS" --pretty=format:' %h %s (%ar)' --abbrev-commit
|
204
|
-
echo ""
|
205
|
-
fi
|
206
|
-
|
207
|
-
echo "==============================================================="
|
208
|
-
fi
|