gitbash 1.3.6 → 1.4.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 +63 -26
- package/bin/gitbash +87 -7
- package/commands/create.sh +94 -54
- package/commands/stale.sh +53 -44
- package/commands/status.sh +10 -15
- package/commands/switch.sh +36 -13
- package/commands/update.sh +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,29 +32,6 @@ brew install git-delta # Better diff highlighting
|
|
|
32
32
|
brew install bat # File preview with syntax highlighting
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
### Configuration
|
|
36
|
-
|
|
37
|
-
gitbash reads configuration from `~/.gitbashrc` if it exists. You can set the following variables:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# Prefix for feature branches (default: "feature/")
|
|
41
|
-
GITBASH_FEATURE_BRANCH_PREFIX="feature/"
|
|
42
|
-
|
|
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
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
You can create this file manually or use `gitbash --config` to configure interactively.
|
|
57
|
-
|
|
58
35
|
## Commands
|
|
59
36
|
|
|
60
37
|
### branch
|
|
@@ -73,11 +50,38 @@ branch --version # Show version
|
|
|
73
50
|
create [JIRA_LINK|ISSUE] [TITLE...]
|
|
74
51
|
```
|
|
75
52
|
|
|
76
|
-
Create feature branch with Jira parsing. Updates main first, pushes and tracks.
|
|
53
|
+
Create feature branch with optional Jira parsing. Updates main first, pushes and tracks.
|
|
54
|
+
|
|
55
|
+
**Branch Name Format:** `<type>/<custom-prefix>/<issue>-<title>` or `<type>/<custom-prefix>/<title>`
|
|
56
|
+
|
|
57
|
+
**Examples with custom prefix** (`GITBASH_CREATE_BRANCH_PREFIX="awesome-team"`):
|
|
58
|
+
|
|
59
|
+
With issue parsing enabled (default):
|
|
60
|
+
```bash
|
|
61
|
+
create PROJ-123 fix login bug # → feature/awesome-team/PROJ-123-fix-login-bug
|
|
62
|
+
create fix bug # → feature/awesome-team/NOISSUE-fix-bug
|
|
63
|
+
create --hotfix PROJ-999 critical fix # → hotfix/awesome-team/PROJ-999-critical-fix
|
|
64
|
+
create # Interactive mode with Jira prompt
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
With issue parsing disabled (`GITBASH_CREATE_NO_ISSUE_PARSING="yes"`):
|
|
68
|
+
```bash
|
|
69
|
+
create fix login bug # → feature/awesome-team/fix-login-bug
|
|
70
|
+
create --hotfix enhance security # → hotfix/awesome-team/enhance-security
|
|
71
|
+
create # Interactive mode (no Jira prompt)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Examples with empty prefix** (`GITBASH_CREATE_BRANCH_PREFIX=""`, default):
|
|
77
75
|
|
|
76
|
+
With parsing enabled:
|
|
78
77
|
```bash
|
|
79
|
-
create PROJ-123 fix
|
|
80
|
-
create #
|
|
78
|
+
create PROJ-123 fix bug # → feature/PROJ-123-fix-bug
|
|
79
|
+
create fix bug # → feature/NOISSUE-fix-bug
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
With parsing disabled:
|
|
83
|
+
```bash
|
|
84
|
+
create enhance login screen # → feature/enhance-login-screen
|
|
81
85
|
```
|
|
82
86
|
|
|
83
87
|
### switch
|
|
@@ -202,6 +206,39 @@ commits # Show last 20 commits
|
|
|
202
206
|
commits 50 # Show last 50 commits
|
|
203
207
|
```
|
|
204
208
|
|
|
209
|
+
### Configuration
|
|
210
|
+
|
|
211
|
+
gitbash reads configuration from `~/.gitbashrc` if it exists. You can set the following variables:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Branch prefix inserted between type and issue number (default: "")
|
|
215
|
+
# No trailing slash needed - it's added automatically
|
|
216
|
+
# Format: <type>/<prefix>/<issue>-<title> or <type>/<prefix>/<title>
|
|
217
|
+
# Examples: "awesome-team" or "" for no prefix
|
|
218
|
+
GITBASH_CREATE_BRANCH_PREFIX=""
|
|
219
|
+
|
|
220
|
+
# Merge tool command invoked by 'update' when conflicts occur (default: "fork")
|
|
221
|
+
GITBASH_MERGE_COMMAND="fork"
|
|
222
|
+
|
|
223
|
+
# Disable Jira issue number parsing in branch names: yes or no (default: "no")
|
|
224
|
+
GITBASH_CREATE_NO_ISSUE_PARSING="no"
|
|
225
|
+
|
|
226
|
+
# Fallback prefix when no issue number is provided (default: "NOISSUE")
|
|
227
|
+
# Only used when GITBASH_CREATE_NO_ISSUE_PARSING="no"
|
|
228
|
+
GITBASH_CREATE_ISSUE_PARSING_FALLBACK="NOISSUE"
|
|
229
|
+
|
|
230
|
+
# Theme for delta/bat diff highlighting: auto, dark, or light (default: "light")
|
|
231
|
+
GITBASH_THEME="light"
|
|
232
|
+
|
|
233
|
+
# Stale branch threshold in months for 'stale' command (default: 3)
|
|
234
|
+
GITBASH_STALE_MONTHS=3
|
|
235
|
+
|
|
236
|
+
# Cleanup threshold in days - branches merged more than this many days ago (default: 7)
|
|
237
|
+
GITBASH_CLEANUP_DAYS=7
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
You can create this file manually or use `gitbash --config` to configure interactively.
|
|
241
|
+
|
|
205
242
|
### Individual aliases
|
|
206
243
|
|
|
207
244
|
Instead of adding every command via `eval "$(gitbash --init)"` in `.zshrc` or `.bashrc`
|
package/bin/gitbash
CHANGED
|
@@ -15,25 +15,88 @@ load_config() {
|
|
|
15
15
|
configure_gitbash() {
|
|
16
16
|
load_config
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
# Backward compatibility: migrate GITBASH_FEATURE_BRANCH_PREFIX to GITBASH_CREATE_BRANCH_PREFIX
|
|
19
|
+
local current_prefix="${GITBASH_CREATE_BRANCH_PREFIX:-}"
|
|
20
|
+
if [[ -z "$current_prefix" && -n "${GITBASH_FEATURE_BRANCH_PREFIX:-}" ]]; then
|
|
21
|
+
# Remove "feature/" prefix from old variable
|
|
22
|
+
current_prefix="${GITBASH_FEATURE_BRANCH_PREFIX#feature/}"
|
|
23
|
+
fi
|
|
24
|
+
# Remove trailing slash if present
|
|
25
|
+
current_prefix="${current_prefix%/}"
|
|
26
|
+
# Default to empty if still not set
|
|
27
|
+
current_prefix="${current_prefix:-}"
|
|
28
|
+
|
|
19
29
|
local current_merge="${GITBASH_MERGE_COMMAND:-fork}"
|
|
20
30
|
local current_theme="${GITBASH_THEME:-auto}"
|
|
21
31
|
local current_stale_months="${GITBASH_STALE_MONTHS:-3}"
|
|
22
32
|
local current_cleanup_days="${GITBASH_CLEANUP_DAYS:-7}"
|
|
33
|
+
local current_no_issue_parsing="${GITBASH_CREATE_NO_ISSUE_PARSING:-no}"
|
|
34
|
+
local current_issue_fallback="${GITBASH_CREATE_ISSUE_PARSING_FALLBACK:-NOISSUE}"
|
|
23
35
|
|
|
24
36
|
echo "Configure gitbash (writes to $CONFIG_FILE)"
|
|
25
37
|
echo
|
|
26
38
|
|
|
27
|
-
local input prefix merge_cmd theme stale_months cleanup_days
|
|
39
|
+
local input prefix merge_cmd theme stale_months cleanup_days no_issue_parsing issue_fallback
|
|
28
40
|
|
|
29
41
|
# Branch prefix
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
echo "Branch prefix"
|
|
43
|
+
echo "Team names are typically used to organize branches by team or subproject."
|
|
44
|
+
echo "Inserted between type and branch name, examples:"
|
|
45
|
+
echo " '' → feature/PROJ-123-fix-bug"
|
|
46
|
+
echo " 'team' → feature/team/PROJ-123-fix-bug"
|
|
47
|
+
echo " 'awesome-team' → hotfix/awesome-team/PROJ-999-critical-fix"
|
|
48
|
+
if [[ -n "$current_prefix" ]]; then
|
|
49
|
+
echo "Tip: Enter a single dash '-' to explicitly clear the prefix"
|
|
50
|
+
fi
|
|
51
|
+
read -e -p "Branch prefix [${current_prefix}]: " prefix
|
|
52
|
+
# If user just pressed Enter, keep current value
|
|
53
|
+
# If user entered a single dash, clear it
|
|
54
|
+
if [[ -z "$prefix" ]]; then
|
|
55
|
+
prefix="$current_prefix"
|
|
56
|
+
elif [[ "$prefix" == "-" ]]; then
|
|
57
|
+
prefix=""
|
|
58
|
+
fi
|
|
59
|
+
# Remove trailing slash if present (will be added automatically)
|
|
60
|
+
prefix="${prefix%/}"
|
|
32
61
|
|
|
33
62
|
# Merge tool
|
|
63
|
+
echo
|
|
34
64
|
read -e -p "Merge tool command (used by update on conflicts) [${current_merge}]: " input
|
|
35
65
|
merge_cmd=${input:-$current_merge}
|
|
36
66
|
|
|
67
|
+
# Issue parsing
|
|
68
|
+
echo
|
|
69
|
+
# Invert current value for display (no_issue_parsing="no" means enabled=yes)
|
|
70
|
+
local current_enabled="yes"
|
|
71
|
+
if [[ "$current_no_issue_parsing" == "yes" ]]; then
|
|
72
|
+
current_enabled="no"
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
read -e -p "Enable Jira issue parsing in branch names? (yes/no) [${current_enabled}]: " input
|
|
76
|
+
local enable_parsing=${input:-$current_enabled}
|
|
77
|
+
|
|
78
|
+
# Convert answer to no_issue_parsing variable (inverted logic)
|
|
79
|
+
case "$enable_parsing" in
|
|
80
|
+
yes)
|
|
81
|
+
no_issue_parsing="no"
|
|
82
|
+
;;
|
|
83
|
+
no)
|
|
84
|
+
no_issue_parsing="yes"
|
|
85
|
+
;;
|
|
86
|
+
*)
|
|
87
|
+
echo "Invalid value. Using 'yes' (parsing enabled)."
|
|
88
|
+
no_issue_parsing="no"
|
|
89
|
+
;;
|
|
90
|
+
esac
|
|
91
|
+
|
|
92
|
+
# Issue parsing fallback (only ask if parsing is enabled)
|
|
93
|
+
if [[ "$enable_parsing" == "yes" ]]; then
|
|
94
|
+
read -e -p "Fallback prefix when no issue number is provided [${current_issue_fallback}]: " input
|
|
95
|
+
issue_fallback=${input:-$current_issue_fallback}
|
|
96
|
+
else
|
|
97
|
+
issue_fallback="${current_issue_fallback}"
|
|
98
|
+
fi
|
|
99
|
+
|
|
37
100
|
# Theme preference
|
|
38
101
|
echo
|
|
39
102
|
echo "Theme preference for delta/bat (affects diff highlighting):"
|
|
@@ -68,17 +131,34 @@ configure_gitbash() {
|
|
|
68
131
|
fi
|
|
69
132
|
|
|
70
133
|
cat > "$CONFIG_FILE" <<EOF
|
|
71
|
-
# gitbash configuration
|
|
72
|
-
|
|
73
|
-
|
|
134
|
+
# Automatically generated gitbash configuration
|
|
135
|
+
|
|
136
|
+
# CAUTION: Do not edit this file manually to avoid setting being overwritten.
|
|
137
|
+
# run 'gitbash --config' to update settings
|
|
138
|
+
|
|
139
|
+
# Branch prefix inserted between type and issue (e.g., 'team-name' or '')
|
|
140
|
+
# No trailing slash needed - it's added automatically
|
|
141
|
+
# Format: <type>/<prefix>/<issue>-<title> or <type>/<prefix>/<title>
|
|
142
|
+
GITBASH_CREATE_BRANCH_PREFIX="$prefix"
|
|
143
|
+
|
|
74
144
|
# Merge tool command invoked by 'update' when conflicts occur
|
|
75
145
|
GITBASH_MERGE_COMMAND="$merge_cmd"
|
|
146
|
+
|
|
147
|
+
# Disable Jira issue number parsing in branch names (yes/no)
|
|
148
|
+
GITBASH_CREATE_NO_ISSUE_PARSING="$no_issue_parsing"
|
|
149
|
+
|
|
150
|
+
# Fallback prefix when no issue number is provided (only used if parsing is enabled)
|
|
151
|
+
GITBASH_CREATE_ISSUE_PARSING_FALLBACK="$issue_fallback"
|
|
152
|
+
|
|
76
153
|
# Theme for delta/bat: auto, dark, or light
|
|
77
154
|
GITBASH_THEME="$theme"
|
|
155
|
+
|
|
78
156
|
# Stale branch threshold in months (branches older than this in 'stale')
|
|
79
157
|
GITBASH_STALE_MONTHS="$stale_months"
|
|
158
|
+
|
|
80
159
|
# Cleanup threshold in days (branches merged more than this many days ago)
|
|
81
160
|
GITBASH_CLEANUP_DAYS="$cleanup_days"
|
|
161
|
+
|
|
82
162
|
EOF
|
|
83
163
|
|
|
84
164
|
echo
|
package/commands/create.sh
CHANGED
|
@@ -7,6 +7,19 @@ SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
|
7
7
|
source "$SOURCE_DIR/_utils.sh"
|
|
8
8
|
|
|
9
9
|
create() {
|
|
10
|
+
# Load configuration
|
|
11
|
+
local no_issue_parsing="${GITBASH_CREATE_NO_ISSUE_PARSING:-no}"
|
|
12
|
+
local issue_fallback="${GITBASH_CREATE_ISSUE_PARSING_FALLBACK:-NOISSUE}"
|
|
13
|
+
|
|
14
|
+
# Load branch prefix with backward compatibility
|
|
15
|
+
local branch_prefix_config="${GITBASH_CREATE_BRANCH_PREFIX:-}"
|
|
16
|
+
if [[ -z "$branch_prefix_config" && -n "${GITBASH_FEATURE_BRANCH_PREFIX:-}" ]]; then
|
|
17
|
+
# Migrate old variable: remove "feature/" prefix
|
|
18
|
+
branch_prefix_config="${GITBASH_FEATURE_BRANCH_PREFIX#feature/}"
|
|
19
|
+
fi
|
|
20
|
+
# Remove trailing slash if present (will be added automatically when used)
|
|
21
|
+
branch_prefix_config="${branch_prefix_config%/}"
|
|
22
|
+
|
|
10
23
|
# -----------------------------
|
|
11
24
|
# 0. Check for help/version flag and parse options
|
|
12
25
|
# -----------------------------
|
|
@@ -24,19 +37,20 @@ create() {
|
|
|
24
37
|
cat << 'EOF'
|
|
25
38
|
Usage: create [OPTIONS] [JIRA_LINK] [TITLE...]
|
|
26
39
|
|
|
27
|
-
Create a new git branch with
|
|
40
|
+
Create a new git branch with optional Jira issue parsing.
|
|
28
41
|
|
|
29
42
|
Options:
|
|
30
43
|
-h, --help Show this help message
|
|
31
44
|
-t, --type Show branch type selector menu (feature, bugfix, hotfix, release)
|
|
32
|
-
--feature Use 'feature/'
|
|
33
|
-
--bugfix Use 'bugfix/'
|
|
34
|
-
--hotfix Use 'hotfix/'
|
|
35
|
-
--release Use 'release/'
|
|
45
|
+
--feature Use 'feature/' type (default)
|
|
46
|
+
--bugfix Use 'bugfix/' type
|
|
47
|
+
--hotfix Use 'hotfix/' type
|
|
48
|
+
--release Use 'release/' type
|
|
36
49
|
|
|
37
|
-
Configuration:
|
|
38
|
-
-
|
|
39
|
-
-
|
|
50
|
+
Configuration (run 'gitbash --config'):
|
|
51
|
+
- GITBASH_CREATE_BRANCH_PREFIX: Custom prefix between type and issue (default: "")
|
|
52
|
+
- GITBASH_CREATE_NO_ISSUE_PARSING: Disable Jira parsing (yes/no, default: "no")
|
|
53
|
+
- GITBASH_CREATE_ISSUE_PARSING_FALLBACK: Fallback when no issue (default: "NOISSUE")
|
|
40
54
|
|
|
41
55
|
Branch Types:
|
|
42
56
|
feature/ - New features and enhancements
|
|
@@ -44,44 +58,48 @@ Branch Types:
|
|
|
44
58
|
hotfix/ - Urgent production fixes
|
|
45
59
|
release/ - Release preparation branches
|
|
46
60
|
|
|
47
|
-
|
|
61
|
+
Branch Name Format:
|
|
62
|
+
<type><custom-prefix><issue>-<title> (with issue parsing)
|
|
63
|
+
<type><custom-prefix><title> (without issue parsing)
|
|
64
|
+
|
|
65
|
+
Examples with custom prefix "awesome-team" (no trailing slash needed):
|
|
66
|
+
|
|
67
|
+
With issue parsing enabled (default):
|
|
68
|
+
$ create PROJ-123 fix login bug
|
|
69
|
+
# → feature/awesome-team/PROJ-123-fix-login-bug
|
|
70
|
+
|
|
71
|
+
$ create fix bug
|
|
72
|
+
# → feature/awesome-team/NOISSUE-fix-bug (uses fallback)
|
|
73
|
+
|
|
74
|
+
$ create --hotfix PROJ-999 critical fix
|
|
75
|
+
# → hotfix/awesome-team/PROJ-999-critical-fix
|
|
76
|
+
|
|
77
|
+
With issue parsing disabled (GITBASH_CREATE_NO_ISSUE_PARSING="yes"):
|
|
78
|
+
$ create fix login bug
|
|
79
|
+
# → feature/awesome-team/fix-login-bug
|
|
80
|
+
|
|
81
|
+
$ create --hotfix enhance security
|
|
82
|
+
# → hotfix/awesome-team/enhance-security
|
|
83
|
+
|
|
84
|
+
Examples with empty prefix (GITBASH_CREATE_BRANCH_PREFIX=""):
|
|
85
|
+
|
|
86
|
+
With parsing enabled:
|
|
87
|
+
$ create PROJ-123 fix bug
|
|
88
|
+
# → feature/PROJ-123-fix-bug
|
|
89
|
+
|
|
90
|
+
With parsing disabled:
|
|
91
|
+
$ create enhance login screen
|
|
92
|
+
# → feature/enhance-login-screen
|
|
93
|
+
|
|
94
|
+
Interactive Mode:
|
|
48
95
|
$ create
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Enter branch title (will be converted to lowercase with dashes):
|
|
54
|
-
> Fix Login Bug
|
|
55
|
-
|
|
56
|
-
Branch name: feature/PROJ-123-fix-login-bug
|
|
57
|
-
Create this branch? (y/N): y
|
|
58
|
-
|
|
59
|
-
With type selector:
|
|
60
|
-
$ create -t PROJ-123 urgent fix
|
|
61
|
-
Branch type >
|
|
62
|
-
> feature/ - New features and enhancements
|
|
63
|
-
bugfix/ - Bug fixes
|
|
64
|
-
hotfix/ - Urgent production fixes
|
|
65
|
-
release/ - Release preparation branches
|
|
66
|
-
|
|
67
|
-
# Select hotfix/, creates: hotfix/PROJ-123-urgent-fix
|
|
68
|
-
|
|
69
|
-
Quick type flags:
|
|
70
|
-
$ create --bugfix PROJ-456 fix crash
|
|
71
|
-
# Creates: bugfix/PROJ-456-fix-crash
|
|
72
|
-
|
|
73
|
-
One-liner mode (with arguments):
|
|
74
|
-
$ create https://jira.company.com/browse/PROJ-123 fix login bug
|
|
75
|
-
Parsed issue number: PROJ-123
|
|
76
|
-
|
|
77
|
-
Branch name: feature/PROJ-123-fix-login-bug
|
|
78
|
-
Create this branch? (y/N): y
|
|
79
|
-
|
|
80
|
-
Examples:
|
|
96
|
+
# Prompts for Jira link (if parsing enabled) and title
|
|
97
|
+
|
|
98
|
+
More Examples:
|
|
81
99
|
create https://jira.company.com/browse/PROJ-123 make some fixes
|
|
82
100
|
create PROJ-456 implement new feature
|
|
83
101
|
create -t PROJ-789 some work # Show type menu
|
|
84
|
-
create --hotfix PROJ-999 critical fix # Use hotfix
|
|
102
|
+
create --hotfix PROJ-999 critical fix # Use hotfix type
|
|
85
103
|
|
|
86
104
|
EOF
|
|
87
105
|
return 0
|
|
@@ -149,19 +167,26 @@ TYPES
|
|
|
149
167
|
return 1
|
|
150
168
|
fi
|
|
151
169
|
|
|
152
|
-
# Extract just the prefix (first word)
|
|
170
|
+
# Extract just the type prefix (first word)
|
|
153
171
|
branch_prefix=$(echo "$selected_type" | awk '{print $1}')
|
|
154
172
|
else
|
|
155
|
-
|
|
173
|
+
# Use default feature/ type
|
|
174
|
+
branch_prefix="feature/"
|
|
156
175
|
fi
|
|
157
176
|
|
|
158
177
|
# -----------------------------
|
|
159
|
-
# 2. Get Jira link from user (or from arguments)
|
|
178
|
+
# 2. Get Jira link from user (or from arguments) - skip if parsing disabled
|
|
160
179
|
# -----------------------------
|
|
161
180
|
local jira_link
|
|
162
181
|
local branch_title
|
|
163
182
|
|
|
164
|
-
if [[ $
|
|
183
|
+
if [[ "$no_issue_parsing" == "yes" ]]; then
|
|
184
|
+
# Issue parsing disabled - treat all args as branch title
|
|
185
|
+
if [[ ${#positional_args[@]} -gt 0 ]]; then
|
|
186
|
+
branch_title="${positional_args[*]}"
|
|
187
|
+
fi
|
|
188
|
+
jira_link=""
|
|
189
|
+
elif [[ ${#positional_args[@]} -gt 0 ]]; then
|
|
165
190
|
# Arguments provided - use one-liner mode
|
|
166
191
|
# Use array index 1 for zsh compatibility (zsh arrays are 1-indexed, bash uses 0)
|
|
167
192
|
if [[ -n "${ZSH_VERSION:-}" ]]; then
|
|
@@ -190,10 +215,13 @@ TYPES
|
|
|
190
215
|
# -----------------------------
|
|
191
216
|
local issue_number
|
|
192
217
|
|
|
193
|
-
if [[
|
|
194
|
-
#
|
|
195
|
-
issue_number="
|
|
196
|
-
|
|
218
|
+
if [[ "$no_issue_parsing" == "yes" ]]; then
|
|
219
|
+
# Issue parsing disabled - no issue number in branch name
|
|
220
|
+
issue_number=""
|
|
221
|
+
elif [[ -z "$jira_link" ]]; then
|
|
222
|
+
# No Jira link provided, use configured fallback
|
|
223
|
+
issue_number="$issue_fallback"
|
|
224
|
+
print_info "No Jira link provided. Using $issue_fallback."
|
|
197
225
|
else
|
|
198
226
|
# First try to match just the issue number pattern (e.g., PROJ-123)
|
|
199
227
|
issue_number=$(echo "$jira_link" | grep -o -E '^[A-Z]+-[0-9]+$' | head -1 || true)
|
|
@@ -206,8 +234,8 @@ TYPES
|
|
|
206
234
|
fi
|
|
207
235
|
|
|
208
236
|
if [[ -z "$issue_number" ]]; then
|
|
209
|
-
print_warning "Could not parse issue number from Jira link. Using
|
|
210
|
-
issue_number="
|
|
237
|
+
print_warning "Could not parse issue number from Jira link. Using $issue_fallback."
|
|
238
|
+
issue_number="$issue_fallback"
|
|
211
239
|
# If parsing failed and we had arguments, include the first arg in the title
|
|
212
240
|
if [[ -n "$branch_title" ]]; then
|
|
213
241
|
branch_title="$jira_link $branch_title"
|
|
@@ -238,8 +266,20 @@ TYPES
|
|
|
238
266
|
# -----------------------------
|
|
239
267
|
# 4. Construct branch name
|
|
240
268
|
# -----------------------------
|
|
241
|
-
# branch_prefix
|
|
242
|
-
|
|
269
|
+
# branch_prefix contains the type (feature/, hotfix/, etc.)
|
|
270
|
+
# branch_prefix_config is the custom prefix inserted between type and issue
|
|
271
|
+
# Format: <type>/<custom-prefix>/<issue>-<title> or <type>/<custom-prefix>/<title>
|
|
272
|
+
local branch_name
|
|
273
|
+
local custom_prefix_part=""
|
|
274
|
+
if [[ -n "$branch_prefix_config" ]]; then
|
|
275
|
+
custom_prefix_part="${branch_prefix_config}/"
|
|
276
|
+
fi
|
|
277
|
+
|
|
278
|
+
if [[ -n "$issue_number" ]]; then
|
|
279
|
+
branch_name="${branch_prefix}${custom_prefix_part}${issue_number}-${branch_title}"
|
|
280
|
+
else
|
|
281
|
+
branch_name="${branch_prefix}${custom_prefix_part}${branch_title}"
|
|
282
|
+
fi
|
|
243
283
|
|
|
244
284
|
echo "Branch name: $branch_name"
|
|
245
285
|
|
package/commands/stale.sh
CHANGED
|
@@ -12,6 +12,7 @@ stale() {
|
|
|
12
12
|
# -----------------------------
|
|
13
13
|
local json_mode=false
|
|
14
14
|
local my_mode=false
|
|
15
|
+
local all_mode=false
|
|
15
16
|
local filter_args=()
|
|
16
17
|
local stale_months="${GITBASH_STALE_MONTHS:-3}"
|
|
17
18
|
|
|
@@ -33,6 +34,7 @@ Arguments:
|
|
|
33
34
|
|
|
34
35
|
Options:
|
|
35
36
|
-h, --help Show this help message
|
|
37
|
+
-a, --all Start in 'all branches' mode (default is stale mode)
|
|
36
38
|
-m, --my Pre-fill filter with your git username (from git config user.name)
|
|
37
39
|
--json Output branch data as JSON (non-interactive)
|
|
38
40
|
--age=N Override stale threshold in months (default: 3, configurable via GITBASH_STALE_MONTHS)
|
|
@@ -69,8 +71,9 @@ Examples:
|
|
|
69
71
|
$ stale --age=6
|
|
70
72
|
# Show branches older than 6 months
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
+
$ stale --all
|
|
75
|
+
# Start with all branches visible (including recent ones)
|
|
76
|
+
# Press Ctrl-A to toggle between all/stale view
|
|
74
77
|
|
|
75
78
|
$ stale --my
|
|
76
79
|
# Pre-fills fzf filter with your git username to show only your branches
|
|
@@ -95,6 +98,10 @@ EOF
|
|
|
95
98
|
json_mode=true
|
|
96
99
|
shift
|
|
97
100
|
;;
|
|
101
|
+
-a|--all)
|
|
102
|
+
all_mode=true
|
|
103
|
+
shift
|
|
104
|
+
;;
|
|
98
105
|
-m|--my)
|
|
99
106
|
my_mode=true
|
|
100
107
|
shift
|
|
@@ -266,11 +273,31 @@ EOF
|
|
|
266
273
|
local stale_file=$(mktemp)
|
|
267
274
|
local all_file=$(mktemp)
|
|
268
275
|
local state_file=$(mktemp)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
|
|
277
|
+
# Write stale branches with header
|
|
278
|
+
{
|
|
279
|
+
echo "══ Stale branches (>${stale_months}mo, oldest first) ══"
|
|
280
|
+
if [[ -n "$stale_branch_list" ]]; then
|
|
281
|
+
echo "$stale_branch_list"
|
|
282
|
+
fi
|
|
283
|
+
echo "$abort_label"
|
|
284
|
+
} > "$stale_file"
|
|
285
|
+
|
|
286
|
+
# Write all branches with header
|
|
287
|
+
{
|
|
288
|
+
echo "══ All branches (oldest first) ══"
|
|
289
|
+
if [[ -n "$all_branch_list" ]]; then
|
|
290
|
+
echo "$all_branch_list"
|
|
291
|
+
fi
|
|
292
|
+
echo "$abort_label"
|
|
293
|
+
} > "$all_file"
|
|
294
|
+
|
|
295
|
+
# Set initial state based on --all flag
|
|
296
|
+
if [[ "$all_mode" == true ]]; then
|
|
297
|
+
printf "all" > "$state_file"
|
|
298
|
+
else
|
|
299
|
+
printf "stale" > "$state_file"
|
|
300
|
+
fi
|
|
274
301
|
|
|
275
302
|
# -----------------------------
|
|
276
303
|
# 6. Run fzf picker with preview
|
|
@@ -278,64 +305,46 @@ EOF
|
|
|
278
305
|
local stale_count=$(echo "$stale_branch_list" | grep -c . || echo "0")
|
|
279
306
|
local all_count=$(echo "$all_branch_list" | grep -c . || echo "0")
|
|
280
307
|
|
|
281
|
-
# Create toggle script
|
|
308
|
+
# Create toggle script
|
|
282
309
|
local toggle_script=$(mktemp)
|
|
283
310
|
cat > "$toggle_script" << TOGGLE_EOF
|
|
284
311
|
#!/bin/bash
|
|
285
|
-
state=\$(cat "$state_file")
|
|
312
|
+
state=\$(cat "$state_file" | tr -d '\n')
|
|
313
|
+
# Toggle: if currently stale, switch to all; if currently all, switch to stale
|
|
286
314
|
if [[ "\$state" == "stale" ]]; then
|
|
287
|
-
|
|
315
|
+
# Switching FROM stale TO all
|
|
316
|
+
printf "all" > "$state_file"
|
|
288
317
|
cat "$all_file"
|
|
289
318
|
else
|
|
290
|
-
|
|
319
|
+
# Switching FROM all TO stale
|
|
320
|
+
printf "stale" > "$state_file"
|
|
291
321
|
cat "$stale_file"
|
|
292
322
|
fi
|
|
293
323
|
TOGGLE_EOF
|
|
294
324
|
chmod +x "$toggle_script"
|
|
295
325
|
|
|
296
|
-
#
|
|
297
|
-
local
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
else
|
|
304
|
-
echo "All branches (oldest first) > "
|
|
305
|
-
fi
|
|
306
|
-
PROMPT_EOF
|
|
307
|
-
chmod +x "$prompt_script"
|
|
308
|
-
|
|
309
|
-
# Create header script
|
|
310
|
-
local header_script=$(mktemp)
|
|
311
|
-
cat > "$header_script" << HEADER_EOF
|
|
312
|
-
#!/bin/bash
|
|
313
|
-
state=\$(cat "$state_file")
|
|
314
|
-
if [[ "\$state" == "stale" ]]; then
|
|
315
|
-
echo "[TAB] select | [Ctrl-A] toggle all/stale | [Enter] delete | [ESC] exit
|
|
316
|
-
Showing $stale_count stale branches (older than ${stale_months} months)"
|
|
317
|
-
else
|
|
318
|
-
echo "[TAB] select | [Ctrl-A] toggle all/stale | [Enter] delete | [ESC] exit
|
|
319
|
-
Showing all $all_count branches"
|
|
320
|
-
fi
|
|
321
|
-
HEADER_EOF
|
|
322
|
-
chmod +x "$header_script"
|
|
326
|
+
# Set initial input file based on mode
|
|
327
|
+
local initial_input_file
|
|
328
|
+
if [[ "$all_mode" == true ]]; then
|
|
329
|
+
initial_input_file="$all_file"
|
|
330
|
+
else
|
|
331
|
+
initial_input_file="$stale_file"
|
|
332
|
+
fi
|
|
323
333
|
|
|
324
334
|
local selection
|
|
325
335
|
selection=$(
|
|
326
|
-
fzf \
|
|
327
|
-
--prompt="Stale branches (>${stale_months}mo, oldest first) > " \
|
|
336
|
+
cat "$initial_input_file" | fzf \
|
|
328
337
|
--query="$filter" \
|
|
329
338
|
-i \
|
|
330
339
|
--reverse \
|
|
331
340
|
--border \
|
|
332
|
-
--header="[TAB] select | [Ctrl-A] toggle all/stale | [Enter] delete | [ESC] exit
|
|
333
|
-
|
|
341
|
+
--header="[TAB] select | [Ctrl-A] toggle all/stale | [Enter] delete | [ESC] exit" \
|
|
342
|
+
--header-lines=1 \
|
|
334
343
|
--multi \
|
|
335
344
|
--delimiter=$'\t' \
|
|
336
345
|
--with-nth=1 \
|
|
337
346
|
--bind=enter:accept \
|
|
338
|
-
--bind="ctrl-a:reload($toggle_script)+
|
|
347
|
+
--bind="ctrl-a:reload(bash $toggle_script)+clear-query" \
|
|
339
348
|
--preview='
|
|
340
349
|
line={}
|
|
341
350
|
if [[ "$line" == "✖ Abort" ]]; then
|
|
@@ -350,7 +359,7 @@ Showing $stale_count stale branches (older than ${stale_months} months)" \
|
|
|
350
359
|
fi
|
|
351
360
|
' \
|
|
352
361
|
--preview-window=right:35% \
|
|
353
|
-
< "$
|
|
362
|
+
< "$initial_input_file"
|
|
354
363
|
) </dev/tty || true
|
|
355
364
|
|
|
356
365
|
# Cleanup temp files
|
package/commands/status.sh
CHANGED
|
@@ -292,21 +292,16 @@ EOF
|
|
|
292
292
|
done
|
|
293
293
|
|
|
294
294
|
echo
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
# Use the commit function with staged and push flags
|
|
306
|
-
commit -s -p
|
|
307
|
-
break
|
|
308
|
-
;;
|
|
309
|
-
esac
|
|
295
|
+
echo "Ready to commit and push staged changes."
|
|
296
|
+
echo "Press Ctrl+C to abort."
|
|
297
|
+
echo
|
|
298
|
+
# Source commit.sh if commit function not available
|
|
299
|
+
if ! declare -f commit >/dev/null 2>&1; then
|
|
300
|
+
source "$SOURCE_DIR/commit.sh"
|
|
301
|
+
fi
|
|
302
|
+
# Directly prompt for commit message (user can Ctrl+C to abort)
|
|
303
|
+
commit -s -p
|
|
304
|
+
break
|
|
310
305
|
fi
|
|
311
306
|
done
|
|
312
307
|
}
|
package/commands/switch.sh
CHANGED
|
@@ -101,19 +101,42 @@ EOF
|
|
|
101
101
|
fi
|
|
102
102
|
}
|
|
103
103
|
)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
|
|
105
|
+
# -----------------------------
|
|
106
|
+
# 3b. Check for single match when filter is provided
|
|
107
|
+
# -----------------------------
|
|
108
|
+
if [[ -n "$filter" ]]; then
|
|
109
|
+
# Filter branch list (case-insensitive), excluding spacer
|
|
110
|
+
local matching_branches
|
|
111
|
+
matching_branches=$(echo "$branch_list" | grep -iv '───' | grep -i "$filter" || true)
|
|
112
|
+
local match_count
|
|
113
|
+
match_count=$(echo "$matching_branches" | grep -c . || echo "0")
|
|
114
|
+
|
|
115
|
+
if [[ "$match_count" -eq 1 ]]; then
|
|
116
|
+
# Single match - skip fzf
|
|
117
|
+
selected_branch="$matching_branches"
|
|
118
|
+
print_info "Single match found, switching directly..."
|
|
119
|
+
fi
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
# -----------------------------
|
|
123
|
+
# 3c. Use fzf if no single match
|
|
124
|
+
# -----------------------------
|
|
125
|
+
if [[ -z "$selected_branch" ]]; then
|
|
126
|
+
selected_branch=$(
|
|
127
|
+
fzf \
|
|
128
|
+
--height=40% \
|
|
129
|
+
--reverse \
|
|
130
|
+
--border \
|
|
131
|
+
--prompt="Select branch: " \
|
|
132
|
+
--query="$filter" \
|
|
133
|
+
-i \
|
|
134
|
+
--preview="branch=\$(echo {} | sed 's/^[^:]*: //'); if [[ \"\$branch\" == *───* ]]; then echo 'Spacer - not selectable'; else git log --color=always -n 1 --format='%C(bold cyan)Author:%C(reset) %an%n%C(bold cyan)Date:%C(reset) %ar (%ad)%n%C(bold cyan)Message:%C(reset) %s%n' --date=format:'%Y-%m-%d %H:%M' \"\$branch\" 2>/dev/null && echo && git log --oneline --color=always -n 10 \"\$branch\" 2>/dev/null; fi" \
|
|
135
|
+
--preview-window=right:50% \
|
|
136
|
+
--header="Current: $current_branch" \
|
|
137
|
+
<<< "$branch_list"
|
|
138
|
+
) </dev/tty || true
|
|
139
|
+
fi
|
|
117
140
|
|
|
118
141
|
# -----------------------------
|
|
119
142
|
# 4. Handle selection
|
package/commands/update.sh
CHANGED
|
@@ -8,7 +8,7 @@ source "$SOURCE_DIR/_utils.sh"
|
|
|
8
8
|
|
|
9
9
|
# Update the current branch with the latest version of master/main
|
|
10
10
|
update() {
|
|
11
|
-
local merge_tool="${
|
|
11
|
+
local merge_tool="${GITBASH_MERGE_COMMAND:-fork}"
|
|
12
12
|
local should_push=false
|
|
13
13
|
|
|
14
14
|
# Parse arguments
|