gitbash 1.3.4 → 1.3.5
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 +16 -5
- package/commands/switch.sh +45 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,8 +40,17 @@ gitbash reads configuration from `~/.gitbashrc` if it exists. You can set the fo
|
|
|
40
40
|
# Prefix for feature branches (default: "feature/")
|
|
41
41
|
GITBASH_FEATURE_BRANCH_PREFIX="feature/"
|
|
42
42
|
|
|
43
|
-
#
|
|
44
|
-
GITBASH_MERGE_COMMAND="
|
|
43
|
+
# Merge tool command invoked by 'update' when conflicts occur (default: "fork")
|
|
44
|
+
GITBASH_MERGE_COMMAND="fork"
|
|
45
|
+
|
|
46
|
+
# Theme for delta/bat diff highlighting: auto, dark, or light (default: "light")
|
|
47
|
+
GITBASH_THEME="light"
|
|
48
|
+
|
|
49
|
+
# Stale branch threshold in months for 'stale' command (default: 3)
|
|
50
|
+
GITBASH_STALE_MONTHS=3
|
|
51
|
+
|
|
52
|
+
# Cleanup threshold in days - branches merged more than this many days ago (default: 7)
|
|
53
|
+
GITBASH_CLEANUP_DAYS=7
|
|
45
54
|
```
|
|
46
55
|
|
|
47
56
|
You can create this file manually or use `gitbash --config` to configure interactively.
|
|
@@ -121,13 +130,15 @@ Merge latest main/master into current branch. Opens merge tool on conflicts.
|
|
|
121
130
|
### stale
|
|
122
131
|
|
|
123
132
|
```bash
|
|
124
|
-
stale [-
|
|
133
|
+
stale [-a|--all] [--age=N] [--json] [FILTER...]
|
|
125
134
|
```
|
|
126
135
|
|
|
127
136
|
List remote branches >3 months old (oldest first). Multi-select with TAB to delete.
|
|
128
137
|
|
|
129
|
-
-
|
|
130
|
-
-
|
|
138
|
+
- By default, pre-filters by your git username (from `git config user.name`)
|
|
139
|
+
- `-a|--all` shows all branches without username filter
|
|
140
|
+
- `--age=N` sets stale threshold in months (default: 3, or `GITBASH_STALE_MONTHS`)
|
|
141
|
+
- `Ctrl-A` toggles showing all branches (including recent ones)
|
|
131
142
|
- `--json` outputs JSON for scripting (same format as cleanup)
|
|
132
143
|
|
|
133
144
|
### stashes
|
package/commands/switch.sh
CHANGED
|
@@ -136,10 +136,13 @@ EOF
|
|
|
136
136
|
# -----------------------------
|
|
137
137
|
# 5. Switch to branch
|
|
138
138
|
# -----------------------------
|
|
139
|
+
local switch_success=false
|
|
139
140
|
if [[ "$branch_type" == "local" ]]; then
|
|
140
141
|
# Switch to local branch
|
|
141
142
|
echo "Switching to local branch: $branch_name"
|
|
142
|
-
git checkout "$branch_name"
|
|
143
|
+
if git checkout "$branch_name"; then
|
|
144
|
+
switch_success=true
|
|
145
|
+
fi
|
|
143
146
|
else
|
|
144
147
|
# Handle remote branch
|
|
145
148
|
local local_branch="${branch_name#*/}" # Remove origin/ prefix
|
|
@@ -147,15 +150,52 @@ EOF
|
|
|
147
150
|
# Check if local branch already exists
|
|
148
151
|
if git show-ref --verify --quiet "refs/heads/$local_branch"; then
|
|
149
152
|
echo "Switching to existing local branch: $local_branch"
|
|
150
|
-
git checkout "$local_branch"
|
|
153
|
+
if git checkout "$local_branch"; then
|
|
154
|
+
switch_success=true
|
|
155
|
+
fi
|
|
151
156
|
else
|
|
152
157
|
echo "Creating local tracking branch: $local_branch (tracking $branch_name)"
|
|
153
|
-
git checkout -b "$local_branch" --track "$branch_name"
|
|
158
|
+
if git checkout -b "$local_branch" --track "$branch_name"; then
|
|
159
|
+
switch_success=true
|
|
160
|
+
fi
|
|
154
161
|
fi
|
|
155
162
|
fi
|
|
156
163
|
|
|
157
|
-
if [[
|
|
158
|
-
print_success "
|
|
164
|
+
if [[ "$switch_success" == true ]]; then
|
|
165
|
+
print_success "Switched to branch: $(git rev-parse --abbrev-ref HEAD)"
|
|
166
|
+
|
|
167
|
+
# -----------------------------
|
|
168
|
+
# 6. Check if branch is behind upstream and offer to pull
|
|
169
|
+
# -----------------------------
|
|
170
|
+
local upstream behind_count
|
|
171
|
+
upstream=$(git rev-parse --abbrev-ref '@{upstream}' 2>/dev/null || true)
|
|
172
|
+
|
|
173
|
+
if [[ -n "$upstream" ]]; then
|
|
174
|
+
# Fetch to get latest info (silently)
|
|
175
|
+
git fetch origin 2>/dev/null || true
|
|
176
|
+
|
|
177
|
+
# Check how many commits we're behind
|
|
178
|
+
behind_count=$(git rev-list --count HEAD..@{upstream} 2>/dev/null || echo "0")
|
|
179
|
+
|
|
180
|
+
if [[ "$behind_count" -gt 0 ]]; then
|
|
181
|
+
print_warning "Branch is $behind_count commit(s) behind '$upstream'"
|
|
182
|
+
local pull_answer
|
|
183
|
+
prompt_read "Pull latest changes? (Y/n): " pull_answer
|
|
184
|
+
case "$pull_answer" in
|
|
185
|
+
[nN][oO]|[nN])
|
|
186
|
+
print_info "Skipped pulling. Run 'git pull' when ready."
|
|
187
|
+
;;
|
|
188
|
+
*)
|
|
189
|
+
if git pull; then
|
|
190
|
+
print_success "Successfully pulled latest changes."
|
|
191
|
+
else
|
|
192
|
+
print_error "Pull failed. You may need to resolve conflicts."
|
|
193
|
+
return 1
|
|
194
|
+
fi
|
|
195
|
+
;;
|
|
196
|
+
esac
|
|
197
|
+
fi
|
|
198
|
+
fi
|
|
159
199
|
else
|
|
160
200
|
print_error "Failed to switch branch."
|
|
161
201
|
return 1
|