gitbash 1.4.0 → 1.6.0
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.
- package/commands/branch.sh +9 -15
- package/commands/pr.sh +51 -0
- package/commands/stale.sh +10 -11
- package/commands/stashes.sh +9 -15
- package/commands/status.sh +22 -13
- package/commands/switch.sh +3 -1
- package/commands/unstash.sh +6 -6
- package/package.json +9 -1
package/commands/branch.sh
CHANGED
|
@@ -152,25 +152,19 @@ EOF
|
|
|
152
152
|
# -----------------------------
|
|
153
153
|
case "$selection" in
|
|
154
154
|
"$create_option")
|
|
155
|
-
#
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
fi
|
|
159
|
-
create
|
|
155
|
+
# Find gitbash root directory
|
|
156
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
157
|
+
"$GITBASH_ROOT/bin/gitbash" create
|
|
160
158
|
;;
|
|
161
159
|
"$switch_option")
|
|
162
|
-
#
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
fi
|
|
166
|
-
switch
|
|
160
|
+
# Find gitbash root directory
|
|
161
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
162
|
+
"$GITBASH_ROOT/bin/gitbash" switch
|
|
167
163
|
;;
|
|
168
164
|
"$update_option")
|
|
169
|
-
#
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
fi
|
|
173
|
-
update
|
|
165
|
+
# Find gitbash root directory
|
|
166
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
167
|
+
"$GITBASH_ROOT/bin/gitbash" update
|
|
174
168
|
;;
|
|
175
169
|
"$abort_label")
|
|
176
170
|
echo "Aborted."
|
package/commands/pr.sh
CHANGED
|
@@ -71,6 +71,57 @@ EOF
|
|
|
71
71
|
return 1
|
|
72
72
|
fi
|
|
73
73
|
|
|
74
|
+
# Check for uncommitted changes or untracked files
|
|
75
|
+
local has_changes=false
|
|
76
|
+
if ! git diff-index --quiet HEAD -- 2>/dev/null || [[ -n "$(git ls-files --others --exclude-standard)" ]]; then
|
|
77
|
+
has_changes=true
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
if [[ "$has_changes" == true ]]; then
|
|
81
|
+
echo "You have uncommitted changes or untracked files."
|
|
82
|
+
echo ""
|
|
83
|
+
|
|
84
|
+
# Source _utils.sh for prompt_read
|
|
85
|
+
if ! declare -f prompt_read >/dev/null 2>&1; then
|
|
86
|
+
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
87
|
+
source "$SOURCE_DIR/_utils.sh"
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
prompt_read "Would you like to commit them first? (Y/n): " commit_answer
|
|
91
|
+
case "$commit_answer" in
|
|
92
|
+
[nN][oO]|[nN])
|
|
93
|
+
echo "Continuing without committing..."
|
|
94
|
+
;;
|
|
95
|
+
*)
|
|
96
|
+
# Find gitbash root directory (two levels up from commands/)
|
|
97
|
+
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
98
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
99
|
+
|
|
100
|
+
# Run status command for interactive staging and committing
|
|
101
|
+
"$GITBASH_ROOT/bin/gitbash" status
|
|
102
|
+
if [[ $? -ne 0 ]]; then
|
|
103
|
+
echo "Commit cancelled or failed. Aborting PR creation."
|
|
104
|
+
return 1
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# If -p wasn't specified, offer to push the fresh commit
|
|
108
|
+
if [[ "$should_push" != true ]]; then
|
|
109
|
+
echo ""
|
|
110
|
+
prompt_read "Push the fresh commit to origin? (Y/n): " push_answer
|
|
111
|
+
case "$push_answer" in
|
|
112
|
+
[nN][oO]|[nN])
|
|
113
|
+
echo "Continuing without pushing..."
|
|
114
|
+
;;
|
|
115
|
+
*)
|
|
116
|
+
should_push=true
|
|
117
|
+
;;
|
|
118
|
+
esac
|
|
119
|
+
fi
|
|
120
|
+
;;
|
|
121
|
+
esac
|
|
122
|
+
echo ""
|
|
123
|
+
fi
|
|
124
|
+
|
|
74
125
|
# Remote URL (e.g. git@github.com:user/repo.git or https://github.com/user/repo.git)
|
|
75
126
|
remote=$(git config --get remote.origin.url)
|
|
76
127
|
|
package/commands/stale.sh
CHANGED
|
@@ -237,12 +237,12 @@ EOF
|
|
|
237
237
|
echo "$str"
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
# Build JSON from stale
|
|
240
|
+
# Build JSON from branches (all or stale based on --all flag)
|
|
241
241
|
{
|
|
242
242
|
while IFS='|' read -r branch rel_date author_name author_email timestamp; do
|
|
243
243
|
[[ -z "$branch" ]] && continue
|
|
244
|
-
#
|
|
245
|
-
if [[ "$timestamp" -lt "$threshold_ago" ]]; then
|
|
244
|
+
# Include based on all_mode flag
|
|
245
|
+
if [[ "$all_mode" == true ]] || [[ "$timestamp" -lt "$threshold_ago" ]]; then
|
|
246
246
|
local name="${branch#origin/}"
|
|
247
247
|
# Remove angle brackets from email
|
|
248
248
|
author_email="${author_email#<}"
|
|
@@ -273,10 +273,14 @@ EOF
|
|
|
273
273
|
local stale_file=$(mktemp)
|
|
274
274
|
local all_file=$(mktemp)
|
|
275
275
|
local state_file=$(mktemp)
|
|
276
|
+
local toggle_script=$(mktemp)
|
|
277
|
+
|
|
278
|
+
# Ensure cleanup on exit
|
|
279
|
+
trap 'rm -f "$stale_file" "$all_file" "$state_file" "$toggle_script"' EXIT INT TERM
|
|
276
280
|
|
|
277
281
|
# Write stale branches with header
|
|
278
282
|
{
|
|
279
|
-
echo "══ Stale branches (>${stale_months}mo, oldest first) ══"
|
|
283
|
+
echo "══ Stale branches (>${stale_months}mo, oldest first) ══ [TAB] select | [Ctrl-A] toggle all/stale | [Enter] delete | [ESC] exit"
|
|
280
284
|
if [[ -n "$stale_branch_list" ]]; then
|
|
281
285
|
echo "$stale_branch_list"
|
|
282
286
|
fi
|
|
@@ -285,7 +289,7 @@ EOF
|
|
|
285
289
|
|
|
286
290
|
# Write all branches with header
|
|
287
291
|
{
|
|
288
|
-
echo "══ All branches (oldest first) ══"
|
|
292
|
+
echo "══ All branches (oldest first) ══ [TAB] select | [Ctrl-A] toggle all/stale | [Enter] delete | [ESC] exit"
|
|
289
293
|
if [[ -n "$all_branch_list" ]]; then
|
|
290
294
|
echo "$all_branch_list"
|
|
291
295
|
fi
|
|
@@ -305,8 +309,7 @@ EOF
|
|
|
305
309
|
local stale_count=$(echo "$stale_branch_list" | grep -c . || echo "0")
|
|
306
310
|
local all_count=$(echo "$all_branch_list" | grep -c . || echo "0")
|
|
307
311
|
|
|
308
|
-
# Create toggle script
|
|
309
|
-
local toggle_script=$(mktemp)
|
|
312
|
+
# Create toggle script
|
|
310
313
|
cat > "$toggle_script" << TOGGLE_EOF
|
|
311
314
|
#!/bin/bash
|
|
312
315
|
state=\$(cat "$state_file" | tr -d '\n')
|
|
@@ -338,7 +341,6 @@ TOGGLE_EOF
|
|
|
338
341
|
-i \
|
|
339
342
|
--reverse \
|
|
340
343
|
--border \
|
|
341
|
-
--header="[TAB] select | [Ctrl-A] toggle all/stale | [Enter] delete | [ESC] exit" \
|
|
342
344
|
--header-lines=1 \
|
|
343
345
|
--multi \
|
|
344
346
|
--delimiter=$'\t' \
|
|
@@ -361,9 +363,6 @@ TOGGLE_EOF
|
|
|
361
363
|
--preview-window=right:35% \
|
|
362
364
|
< "$initial_input_file"
|
|
363
365
|
) </dev/tty || true
|
|
364
|
-
|
|
365
|
-
# Cleanup temp files
|
|
366
|
-
rm -f "$stale_file" "$all_file" "$state_file" "$toggle_script" "$prompt_script" "$header_script"
|
|
367
366
|
|
|
368
367
|
# ESC or Ctrl-C
|
|
369
368
|
if [[ -z "$selection" ]]; then
|
package/commands/stashes.sh
CHANGED
|
@@ -151,25 +151,19 @@ EOF
|
|
|
151
151
|
# -----------------------------
|
|
152
152
|
case "$selection" in
|
|
153
153
|
"$stash_option")
|
|
154
|
-
#
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
fi
|
|
158
|
-
stash
|
|
154
|
+
# Find gitbash root directory
|
|
155
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
156
|
+
"$GITBASH_ROOT/bin/gitbash" stash
|
|
159
157
|
;;
|
|
160
158
|
"$unstash_option")
|
|
161
|
-
#
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
fi
|
|
165
|
-
unstash
|
|
159
|
+
# Find gitbash root directory
|
|
160
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
161
|
+
"$GITBASH_ROOT/bin/gitbash" unstash
|
|
166
162
|
;;
|
|
167
163
|
"$cleanup_option")
|
|
168
|
-
#
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
fi
|
|
172
|
-
cleanstash
|
|
164
|
+
# Find gitbash root directory
|
|
165
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
166
|
+
"$GITBASH_ROOT/bin/gitbash" cleanstash
|
|
173
167
|
;;
|
|
174
168
|
"$abort_label")
|
|
175
169
|
echo "Aborted."
|
package/commands/status.sh
CHANGED
|
@@ -131,20 +131,31 @@ EOF
|
|
|
131
131
|
bat --color=always --style=numbers --theme=\"GitHub\" "$file" 2>/dev/null || cat "$file" 2>/dev/null || echo "Cannot preview file";
|
|
132
132
|
elif [[ "$file_status" =~ ^[MAC] ]]; then
|
|
133
133
|
# Staged file - show cached diff
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
staged_diff=$(git diff --cached --color=always "$file" 2>/dev/null);
|
|
135
|
+
unstaged_diff=$(git diff --color=always "$file" 2>/dev/null);
|
|
136
|
+
|
|
137
|
+
# Only show staged section if there are staged changes
|
|
138
|
+
if [[ -n "$staged_diff" ]]; then
|
|
139
|
+
echo "=== STAGED CHANGES ===";
|
|
138
140
|
echo;
|
|
141
|
+
echo "$staged_diff" | delta --light 2>/dev/null || echo "$staged_diff";
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
# Only show unstaged section if there are unstaged changes
|
|
145
|
+
if [[ -n "$unstaged_diff" ]]; then
|
|
146
|
+
[[ -n "$staged_diff" ]] && echo;
|
|
139
147
|
echo "=== UNSTAGED CHANGES ===";
|
|
140
148
|
echo;
|
|
141
|
-
|
|
149
|
+
echo "$unstaged_diff" | delta --light 2>/dev/null || echo "$unstaged_diff";
|
|
142
150
|
fi
|
|
143
151
|
else
|
|
144
152
|
# Unstaged changes
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
unstaged_diff=$(git diff --color=always "$file" 2>/dev/null);
|
|
154
|
+
if [[ -n "$unstaged_diff" ]]; then
|
|
155
|
+
echo "=== UNSTAGED CHANGES ===";
|
|
156
|
+
echo;
|
|
157
|
+
echo "$unstaged_diff" | delta --light 2>/dev/null || echo "$unstaged_diff";
|
|
158
|
+
fi
|
|
148
159
|
fi
|
|
149
160
|
' \
|
|
150
161
|
--preview-window=right:60% \
|
|
@@ -295,12 +306,10 @@ EOF
|
|
|
295
306
|
echo "Ready to commit and push staged changes."
|
|
296
307
|
echo "Press Ctrl+C to abort."
|
|
297
308
|
echo
|
|
298
|
-
#
|
|
299
|
-
|
|
300
|
-
source "$SOURCE_DIR/commit.sh"
|
|
301
|
-
fi
|
|
309
|
+
# Find gitbash root directory (two levels up from commands/)
|
|
310
|
+
GITBASH_ROOT="$(cd "$SOURCE_DIR/.." && pwd)"
|
|
302
311
|
# Directly prompt for commit message (user can Ctrl+C to abort)
|
|
303
|
-
commit -s -p
|
|
312
|
+
"$GITBASH_ROOT/bin/gitbash" commit -s -p
|
|
304
313
|
break
|
|
305
314
|
fi
|
|
306
315
|
done
|
package/commands/switch.sh
CHANGED
|
@@ -110,7 +110,9 @@ EOF
|
|
|
110
110
|
local matching_branches
|
|
111
111
|
matching_branches=$(echo "$branch_list" | grep -iv '───' | grep -i "$filter" || true)
|
|
112
112
|
local match_count
|
|
113
|
-
match_count=$(echo "$matching_branches" | grep -c . || echo "0")
|
|
113
|
+
match_count=$(echo "$matching_branches" | grep -c . 2>/dev/null || echo "0")
|
|
114
|
+
# Ensure match_count is numeric
|
|
115
|
+
[[ -z "$match_count" ]] && match_count=0
|
|
114
116
|
|
|
115
117
|
if [[ "$match_count" -eq 1 ]]; then
|
|
116
118
|
# Single match - skip fzf
|
package/commands/unstash.sh
CHANGED
|
@@ -146,17 +146,17 @@ EOF
|
|
|
146
146
|
fi
|
|
147
147
|
|
|
148
148
|
# -----------------------------
|
|
149
|
-
# 6. Confirm before dropping
|
|
149
|
+
# 6. Confirm before dropping (default: Yes)
|
|
150
150
|
# -----------------------------
|
|
151
151
|
echo
|
|
152
|
-
prompt_read "Drop $stash_id now? (
|
|
152
|
+
prompt_read "Drop $stash_id now? (Y/n): " drop_ans
|
|
153
153
|
case "$drop_ans" in
|
|
154
|
-
[
|
|
155
|
-
echo "
|
|
156
|
-
git stash drop "$stash_id"
|
|
154
|
+
[nN][oO]|[nN])
|
|
155
|
+
echo "Stash NOT dropped."
|
|
157
156
|
;;
|
|
158
157
|
*)
|
|
159
|
-
echo "
|
|
158
|
+
echo "Dropping $stash_id ..."
|
|
159
|
+
git stash drop "$stash_id"
|
|
160
160
|
;;
|
|
161
161
|
esac
|
|
162
162
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitbash",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Opinionated git utilities for bash with fzf-powered menus",
|
|
5
5
|
"author": "jaggli",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,5 +39,13 @@
|
|
|
39
39
|
],
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=14"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"changeset": "changeset",
|
|
45
|
+
"version": "changeset version",
|
|
46
|
+
"release": "npm run version && VERSION=$(node -p \"require('./package.json').version\") && git tag \"v$VERSION\" && ./bin/gitbash commit -p \"chore: release v$VERSION\" && git push --tags && npm publish"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@changesets/cli": "^2.29.8"
|
|
42
50
|
}
|
|
43
51
|
}
|