gitbash 1.9.0 → 2.0.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/README.md +100 -89
- package/bin/gitbash +345 -723
- package/commands/_utils.sh +485 -157
- package/commands/branch.sh +9 -12
- package/commands/cleanstash.sh +47 -122
- package/commands/cleanup.sh +305 -441
- package/commands/commit.sh +136 -172
- package/commands/commits.sh +81 -114
- package/commands/create.sh +231 -314
- package/commands/pr.sh +158 -146
- package/commands/stale.sh +137 -277
- package/commands/stash.sh +11 -39
- package/commands/stashes.sh +10 -13
- package/commands/status.sh +197 -250
- package/commands/switch.sh +186 -256
- package/commands/unstash.sh +45 -109
- package/commands/update.sh +123 -142
- package/docs/CONTRIBUTING.md +16 -5
- package/docs/SECURITY.md +14 -3
- package/package.json +5 -3
package/commands/branch.sh
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC2155
|
|
3
2
|
|
|
4
3
|
# Source common utilities
|
|
5
|
-
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]
|
|
4
|
+
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
5
|
# shellcheck source=_utils.sh
|
|
7
6
|
source "$SOURCE_DIR/_utils.sh"
|
|
8
7
|
|
|
@@ -92,8 +91,7 @@ Actions:
|
|
|
92
91
|
⬆️ Update - Update current branch with latest main/master
|
|
93
92
|
|
|
94
93
|
Requirements:
|
|
95
|
-
- fzf (fuzzy finder)
|
|
96
|
-
- create, switch, and update functions must be available
|
|
94
|
+
- fzf (fuzzy finder)
|
|
97
95
|
|
|
98
96
|
See also:
|
|
99
97
|
create -h Show help for create command
|
|
@@ -131,20 +129,19 @@ EOF
|
|
|
131
129
|
# 3. Run fzf menu
|
|
132
130
|
# -----------------------------
|
|
133
131
|
local selection
|
|
134
|
-
selection=$(
|
|
132
|
+
selection=$(run_fzf --prompt="Branch action > " \
|
|
135
133
|
-i \
|
|
136
134
|
--reverse \
|
|
137
135
|
--border \
|
|
138
136
|
--header="What would you like to do?" \
|
|
139
137
|
--no-multi \
|
|
140
|
-
--bind=enter:accept \
|
|
141
138
|
<<< "$choices"
|
|
142
|
-
)
|
|
139
|
+
) || true
|
|
143
140
|
|
|
144
141
|
# ESC or Ctrl-C
|
|
145
142
|
if [[ -z "$selection" ]]; then
|
|
146
143
|
echo "Aborted."
|
|
147
|
-
return
|
|
144
|
+
return 0
|
|
148
145
|
fi
|
|
149
146
|
|
|
150
147
|
# -----------------------------
|
|
@@ -152,17 +149,17 @@ EOF
|
|
|
152
149
|
# -----------------------------
|
|
153
150
|
case "$selection" in
|
|
154
151
|
"$create_option")
|
|
155
|
-
|
|
152
|
+
gb_run create
|
|
156
153
|
;;
|
|
157
154
|
"$switch_option")
|
|
158
|
-
|
|
155
|
+
gb_run switch
|
|
159
156
|
;;
|
|
160
157
|
"$update_option")
|
|
161
|
-
|
|
158
|
+
gb_run update
|
|
162
159
|
;;
|
|
163
160
|
"$abort_label")
|
|
164
161
|
echo "Aborted."
|
|
165
|
-
return
|
|
162
|
+
return 0
|
|
166
163
|
;;
|
|
167
164
|
*)
|
|
168
165
|
echo "Unknown selection."
|
package/commands/cleanstash.sh
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC2155
|
|
3
2
|
|
|
4
3
|
# Source common utilities
|
|
5
|
-
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]
|
|
4
|
+
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
5
|
# shellcheck source=_utils.sh
|
|
7
6
|
source "$SOURCE_DIR/_utils.sh"
|
|
7
|
+
# shellcheck source=unstash.sh
|
|
8
|
+
source "$SOURCE_DIR/unstash.sh"
|
|
8
9
|
|
|
9
10
|
cleanstash() {
|
|
10
|
-
# -----------------------------
|
|
11
|
-
# 0. Check for help/version flag
|
|
12
|
-
# -----------------------------
|
|
13
11
|
if [[ "${1:-}" == "-v" || "${1:-}" == "--version" ]]; then
|
|
14
12
|
echo "gitbash ${FUNCNAME[0]} v$VERSION"
|
|
15
13
|
return 0
|
|
@@ -24,155 +22,82 @@ Interactive fuzzy finder (fzf) with preview and multi-select support.
|
|
|
24
22
|
Options:
|
|
25
23
|
-h, --help Show this help message
|
|
26
24
|
|
|
27
|
-
Features:
|
|
28
|
-
- Multi-select support (use TAB to select multiple stashes)
|
|
29
|
-
- Preview stash contents before deletion
|
|
30
|
-
- Confirmation prompt before deletion
|
|
31
|
-
- Safe deletion (deletes in reverse order to maintain indices)
|
|
32
|
-
|
|
33
25
|
Navigation:
|
|
34
|
-
↑/↓
|
|
26
|
+
↑/↓ Navigate through stashes
|
|
35
27
|
TAB Select/deselect stash (multi-select)
|
|
36
28
|
Enter Confirm selection
|
|
37
29
|
ESC/Ctrl-C Abort
|
|
38
30
|
|
|
39
|
-
Examples:
|
|
40
|
-
$ cleanstash
|
|
41
|
-
Available stashes >
|
|
42
|
-
> stash@{0}: WIP on main: 1a2b3c4 commit message
|
|
43
|
-
stash@{1}: WIP on feature: 5d6e7f8 another commit
|
|
44
|
-
stash@{2}: On dev: 9a8b7c6 old work
|
|
45
|
-
✖ Abort
|
|
46
|
-
|
|
47
|
-
# Select stash@{0} and stash@{2} using TAB, then press Enter
|
|
48
|
-
|
|
49
|
-
Selected stashes to delete:
|
|
50
|
-
- stash@{0}
|
|
51
|
-
- stash@{2}
|
|
52
|
-
|
|
53
|
-
Delete these 2 stash(es)? (y/N): y
|
|
54
|
-
Deleting stashes...
|
|
55
|
-
Dropping stash@{2} ...
|
|
56
|
-
✓ Deleted stash@{2}
|
|
57
|
-
Dropping stash@{0} ...
|
|
58
|
-
✓ Deleted stash@{0}
|
|
59
|
-
|
|
60
|
-
Requirements:
|
|
61
|
-
- fzf (fuzzy finder) - will prompt to install if not found
|
|
62
|
-
- git stash list with at least one stash
|
|
63
|
-
|
|
64
31
|
Notes:
|
|
65
|
-
-
|
|
66
|
-
-
|
|
32
|
+
- Asks for confirmation before deleting
|
|
33
|
+
- Stashes are deleted from the highest index down, so indices stay valid
|
|
67
34
|
- No changes are applied to your working directory
|
|
68
35
|
|
|
36
|
+
Requirements:
|
|
37
|
+
- fzf (fuzzy finder)
|
|
38
|
+
|
|
69
39
|
EOF
|
|
70
40
|
return 0
|
|
71
41
|
fi
|
|
72
42
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
43
|
+
require_git_repo || return 1
|
|
44
|
+
|
|
45
|
+
local stash_list
|
|
46
|
+
stash_list=$(git stash list)
|
|
47
|
+
if [[ -z "$stash_list" ]]; then
|
|
48
|
+
echo "No stashes."
|
|
49
|
+
return 0
|
|
50
|
+
fi
|
|
51
|
+
|
|
76
52
|
require_fzf || return 1
|
|
77
53
|
|
|
78
|
-
# -----------------------------
|
|
79
|
-
# 2. Build menu entries
|
|
80
|
-
# -----------------------------
|
|
81
|
-
local abort_label="✖ Abort"
|
|
82
|
-
|
|
83
|
-
local choices
|
|
84
|
-
choices=$(
|
|
85
|
-
{
|
|
86
|
-
git stash list
|
|
87
|
-
echo "$abort_label"
|
|
88
|
-
}
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
# -----------------------------
|
|
92
|
-
# 3. Run fzf full-screen picker with preview (multi-select)
|
|
93
|
-
# -----------------------------
|
|
94
54
|
local selection
|
|
95
|
-
selection=$(
|
|
55
|
+
selection=$(run_fzf --prompt="Available stashes > " \
|
|
96
56
|
-i \
|
|
97
57
|
--reverse \
|
|
98
58
|
--border \
|
|
99
59
|
--header="Select stashes to delete (TAB for multi-select)" \
|
|
100
60
|
--multi \
|
|
101
|
-
--
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if [[ -n "$sel" ]]; then
|
|
105
|
-
git stash show -p "$sel" | delta --light 2>/dev/null || git stash show -p "$sel";
|
|
106
|
-
else
|
|
107
|
-
echo "No preview";
|
|
108
|
-
fi
|
|
109
|
-
' \
|
|
110
|
-
<<< "$choices"
|
|
111
|
-
) </dev/tty || true
|
|
112
|
-
|
|
113
|
-
# ESC or Ctrl-C
|
|
114
|
-
if [[ -z "$selection" ]]; then
|
|
115
|
-
echo "Aborted."
|
|
116
|
-
return 1
|
|
117
|
-
fi
|
|
61
|
+
--preview="$(_stash_preview)" \
|
|
62
|
+
<<< "$stash_list"
|
|
63
|
+
) || true
|
|
118
64
|
|
|
119
|
-
|
|
120
|
-
if echo "$selection" | grep -q "^$abort_label$"; then
|
|
65
|
+
if [[ -z "$selection" ]]; then
|
|
121
66
|
echo "Aborted."
|
|
122
|
-
return
|
|
67
|
+
return 0
|
|
123
68
|
fi
|
|
124
69
|
|
|
125
|
-
|
|
126
|
-
# 4. Extract stash IDs safely
|
|
127
|
-
# -----------------------------
|
|
128
|
-
local stash_ids=()
|
|
129
|
-
local stash_id line
|
|
70
|
+
local stash_ids=() stash_id line
|
|
130
71
|
while IFS= read -r line; do
|
|
131
|
-
stash_id=$(
|
|
132
|
-
|
|
133
|
-
stash_ids+=("$stash_id")
|
|
134
|
-
fi
|
|
72
|
+
stash_id=$(printf '%s' "$line" | grep -o '^stash@{[0-9]*}' || true)
|
|
73
|
+
[[ -n "$stash_id" ]] && stash_ids+=("$stash_id")
|
|
135
74
|
done <<< "$selection"
|
|
136
75
|
|
|
137
76
|
if [[ ${#stash_ids[@]} -eq 0 ]]; then
|
|
138
|
-
|
|
77
|
+
print_error "Could not determine any stash IDs."
|
|
139
78
|
return 1
|
|
140
79
|
fi
|
|
141
80
|
|
|
142
|
-
# -----------------------------
|
|
143
|
-
# 5. Confirm before deletion
|
|
144
|
-
# -----------------------------
|
|
145
81
|
echo "Selected stashes to delete:"
|
|
146
|
-
|
|
147
|
-
echo " - $stash_id"
|
|
148
|
-
done
|
|
82
|
+
printf ' - %s\n' "${stash_ids[@]}"
|
|
149
83
|
echo
|
|
150
84
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
else
|
|
170
|
-
echo "✗ Failed to delete $stash_id"
|
|
171
|
-
fi
|
|
172
|
-
done
|
|
173
|
-
;;
|
|
174
|
-
*)
|
|
175
|
-
echo "Deletion cancelled. No stashes were removed."
|
|
176
|
-
;;
|
|
177
|
-
esac
|
|
85
|
+
if ! gb_confirm "Delete these ${#stash_ids[@]} stash(es)?" n; then
|
|
86
|
+
echo "Deletion cancelled. No stashes were removed."
|
|
87
|
+
return 0
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# Highest index first, so the remaining indices don't shift
|
|
91
|
+
local sorted_ids=() id
|
|
92
|
+
while IFS= read -r id; do
|
|
93
|
+
sorted_ids+=("$id")
|
|
94
|
+
done < <(printf '%s\n' "${stash_ids[@]}" | sort -t'{' -k2 -rn)
|
|
95
|
+
|
|
96
|
+
for stash_id in "${sorted_ids[@]}"; do
|
|
97
|
+
if git stash drop --quiet "$stash_id"; then
|
|
98
|
+
print_success "Deleted $stash_id"
|
|
99
|
+
else
|
|
100
|
+
print_error "Failed to delete $stash_id"
|
|
101
|
+
fi
|
|
102
|
+
done
|
|
178
103
|
}
|