gitbash 1.7.0 → 1.8.1
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 +13 -0
- package/bin/gitbash +206 -0
- package/commands/_utils.sh +8 -1
- package/commands/stale.sh +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ gitbash --version # Show version
|
|
|
20
20
|
gitbash --init # Print shell init code
|
|
21
21
|
gitbash --config # Interactive configuration wizard
|
|
22
22
|
gitbash --config-local # Configure local overrides for current repository
|
|
23
|
+
gitbash --config-user # Configure user-specific overrides (excluded from git)
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
### Dependencies
|
|
@@ -254,6 +255,18 @@ Local settings override the global `~/.gitbashrc` for that repository only. This
|
|
|
254
255
|
|
|
255
256
|
The interactive wizard will show each setting's current global value and ask if you want to override it locally. Only overridden values are written to the local config.
|
|
256
257
|
|
|
258
|
+
#### User Configuration
|
|
259
|
+
|
|
260
|
+
For personal settings that should not be committed to version control, run `gitbash --config-user` to create a `.gitbashrc-user` file in the repository root.
|
|
261
|
+
|
|
262
|
+
User settings override both global (`~/.gitbashrc`) and local (`.gitbashrc`) settings. The file is automatically added to `.gitignore`.
|
|
263
|
+
|
|
264
|
+
**Configuration priority (highest to lowest):**
|
|
265
|
+
|
|
266
|
+
1. `.gitbashrc-user` - User-specific settings (not committed)
|
|
267
|
+
2. `.gitbashrc` - Repository settings (can be committed)
|
|
268
|
+
3. `~/.gitbashrc` - Global settings
|
|
269
|
+
|
|
257
270
|
### Individual aliases
|
|
258
271
|
|
|
259
272
|
Instead of adding every command via `eval "$(gitbash --init)"` in `.zshrc` or `.bashrc`
|
package/bin/gitbash
CHANGED
|
@@ -5,6 +5,7 @@ set -euo pipefail
|
|
|
5
5
|
|
|
6
6
|
CONFIG_FILE="$HOME/.gitbashrc"
|
|
7
7
|
LOCAL_CONFIG_FILE=".gitbashrc"
|
|
8
|
+
USER_CONFIG_FILE=".gitbashrc-user"
|
|
8
9
|
|
|
9
10
|
load_config() {
|
|
10
11
|
# Source global config first
|
|
@@ -21,6 +22,13 @@ load_config() {
|
|
|
21
22
|
# shellcheck disable=SC1090
|
|
22
23
|
source "$local_config"
|
|
23
24
|
fi
|
|
25
|
+
|
|
26
|
+
# Source user config from repo root if present (overrides both)
|
|
27
|
+
local user_config="$repo_root/$USER_CONFIG_FILE"
|
|
28
|
+
if [[ -f "$user_config" ]]; then
|
|
29
|
+
# shellcheck disable=SC1090
|
|
30
|
+
source "$user_config"
|
|
31
|
+
fi
|
|
24
32
|
fi
|
|
25
33
|
}
|
|
26
34
|
|
|
@@ -359,6 +367,198 @@ configure_local_gitbash() {
|
|
|
359
367
|
echo "Saved local configuration to $local_config"
|
|
360
368
|
}
|
|
361
369
|
|
|
370
|
+
configure_user_gitbash() {
|
|
371
|
+
# Check if we're in a git repository
|
|
372
|
+
local repo_root
|
|
373
|
+
if ! repo_root=$(git rev-parse --show-toplevel 2>/dev/null); then
|
|
374
|
+
echo "Error: Not inside a git repository." >&2
|
|
375
|
+
exit 1
|
|
376
|
+
fi
|
|
377
|
+
|
|
378
|
+
local user_config="$repo_root/$USER_CONFIG_FILE"
|
|
379
|
+
local gitignore="$repo_root/.gitignore"
|
|
380
|
+
|
|
381
|
+
# Load all configs to get current effective values
|
|
382
|
+
load_config
|
|
383
|
+
|
|
384
|
+
# Backward compatibility: migrate GITBASH_FEATURE_BRANCH_PREFIX to GITBASH_CREATE_BRANCH_PREFIX
|
|
385
|
+
local current_prefix="${GITBASH_CREATE_BRANCH_PREFIX:-}"
|
|
386
|
+
if [[ -z "$current_prefix" && -n "${GITBASH_FEATURE_BRANCH_PREFIX:-}" ]]; then
|
|
387
|
+
# Remove "feature/" prefix from old variable
|
|
388
|
+
current_prefix="${GITBASH_FEATURE_BRANCH_PREFIX#feature/}"
|
|
389
|
+
fi
|
|
390
|
+
# Remove trailing slash if present
|
|
391
|
+
current_prefix="${current_prefix%/}"
|
|
392
|
+
|
|
393
|
+
echo "Configure user-specific gitbash overrides for this repository"
|
|
394
|
+
echo "Config will be saved to: $user_config"
|
|
395
|
+
echo "This file is intended for personal settings and excluded from version control."
|
|
396
|
+
echo
|
|
397
|
+
echo "Press Enter to keep current setting, or enter a new value to override."
|
|
398
|
+
echo "Enter '-' to explicitly unset an override."
|
|
399
|
+
echo
|
|
400
|
+
|
|
401
|
+
local overrides=()
|
|
402
|
+
local input
|
|
403
|
+
|
|
404
|
+
# Branch prefix
|
|
405
|
+
echo "1. Branch prefix"
|
|
406
|
+
echo " Current (effective): ${current_prefix:-'(empty)'}"
|
|
407
|
+
read -re -p " User override: " input
|
|
408
|
+
if [[ -n "$input" ]]; then
|
|
409
|
+
if [[ "$input" == "-" ]]; then
|
|
410
|
+
overrides+=("GITBASH_CREATE_BRANCH_PREFIX=\"\"")
|
|
411
|
+
echo " → Will use empty prefix"
|
|
412
|
+
else
|
|
413
|
+
input="${input%/}" # Remove trailing slash
|
|
414
|
+
overrides+=("GITBASH_CREATE_BRANCH_PREFIX=\"$input\"")
|
|
415
|
+
echo " → Will use '$input'"
|
|
416
|
+
fi
|
|
417
|
+
else
|
|
418
|
+
echo " → Keeping current setting"
|
|
419
|
+
fi
|
|
420
|
+
echo
|
|
421
|
+
|
|
422
|
+
# Merge command
|
|
423
|
+
local current_merge="${GITBASH_MERGE_COMMAND:-fork}"
|
|
424
|
+
echo "2. Merge tool command (used by update on conflicts)"
|
|
425
|
+
echo " Current (effective): $current_merge"
|
|
426
|
+
read -re -p " User override: " input
|
|
427
|
+
if [[ -n "$input" && "$input" != "-" ]]; then
|
|
428
|
+
overrides+=("GITBASH_MERGE_COMMAND=\"$input\"")
|
|
429
|
+
echo " → Will use '$input'"
|
|
430
|
+
else
|
|
431
|
+
echo " → Keeping current setting"
|
|
432
|
+
fi
|
|
433
|
+
echo
|
|
434
|
+
|
|
435
|
+
# Issue parsing
|
|
436
|
+
local current_no_issue_parsing="${GITBASH_CREATE_NO_ISSUE_PARSING:-no}"
|
|
437
|
+
local current_enabled="yes"
|
|
438
|
+
[[ "$current_no_issue_parsing" == "yes" ]] && current_enabled="no"
|
|
439
|
+
echo "3. Enable Jira issue parsing in branch names? (yes/no)"
|
|
440
|
+
echo " Current (effective): $current_enabled"
|
|
441
|
+
read -re -p " User override: " input
|
|
442
|
+
if [[ -n "$input" && "$input" != "-" ]]; then
|
|
443
|
+
case "$input" in
|
|
444
|
+
yes)
|
|
445
|
+
overrides+=("GITBASH_CREATE_NO_ISSUE_PARSING=\"no\"")
|
|
446
|
+
echo " → Will enable parsing"
|
|
447
|
+
;;
|
|
448
|
+
no)
|
|
449
|
+
overrides+=("GITBASH_CREATE_NO_ISSUE_PARSING=\"yes\"")
|
|
450
|
+
echo " → Will disable parsing"
|
|
451
|
+
;;
|
|
452
|
+
*)
|
|
453
|
+
echo " → Invalid value, keeping current setting"
|
|
454
|
+
;;
|
|
455
|
+
esac
|
|
456
|
+
else
|
|
457
|
+
echo " → Keeping current setting"
|
|
458
|
+
fi
|
|
459
|
+
echo
|
|
460
|
+
|
|
461
|
+
# Issue fallback
|
|
462
|
+
local current_issue_fallback="${GITBASH_CREATE_ISSUE_PARSING_FALLBACK:-NOISSUE}"
|
|
463
|
+
echo "4. Fallback prefix when no issue number is provided"
|
|
464
|
+
echo " Current (effective): $current_issue_fallback"
|
|
465
|
+
read -re -p " User override: " input
|
|
466
|
+
if [[ -n "$input" && "$input" != "-" ]]; then
|
|
467
|
+
overrides+=("GITBASH_CREATE_ISSUE_PARSING_FALLBACK=\"$input\"")
|
|
468
|
+
echo " → Will use '$input'"
|
|
469
|
+
else
|
|
470
|
+
echo " → Keeping current setting"
|
|
471
|
+
fi
|
|
472
|
+
echo
|
|
473
|
+
|
|
474
|
+
# Theme
|
|
475
|
+
local current_theme="${GITBASH_THEME:-auto}"
|
|
476
|
+
echo "5. Theme for delta/bat (auto/dark/light)"
|
|
477
|
+
echo " Current (effective): $current_theme"
|
|
478
|
+
read -re -p " User override: " input
|
|
479
|
+
if [[ -n "$input" && "$input" != "-" ]]; then
|
|
480
|
+
case "$input" in
|
|
481
|
+
auto|dark|light)
|
|
482
|
+
overrides+=("GITBASH_THEME=\"$input\"")
|
|
483
|
+
echo " → Will use '$input'"
|
|
484
|
+
;;
|
|
485
|
+
*)
|
|
486
|
+
echo " → Invalid value, keeping current setting"
|
|
487
|
+
;;
|
|
488
|
+
esac
|
|
489
|
+
else
|
|
490
|
+
echo " → Keeping current setting"
|
|
491
|
+
fi
|
|
492
|
+
echo
|
|
493
|
+
|
|
494
|
+
# Stale months
|
|
495
|
+
local current_stale_months="${GITBASH_STALE_MONTHS:-3}"
|
|
496
|
+
echo "6. Stale branch threshold in months"
|
|
497
|
+
echo " Current (effective): $current_stale_months"
|
|
498
|
+
read -re -p " User override: " input
|
|
499
|
+
if [[ -n "$input" && "$input" != "-" ]]; then
|
|
500
|
+
if [[ "$input" =~ ^[0-9]+$ ]] && [[ "$input" -ge 1 ]]; then
|
|
501
|
+
overrides+=("GITBASH_STALE_MONTHS=\"$input\"")
|
|
502
|
+
echo " → Will use '$input'"
|
|
503
|
+
else
|
|
504
|
+
echo " → Invalid value, keeping current setting"
|
|
505
|
+
fi
|
|
506
|
+
else
|
|
507
|
+
echo " → Keeping current setting"
|
|
508
|
+
fi
|
|
509
|
+
echo
|
|
510
|
+
|
|
511
|
+
# Cleanup days
|
|
512
|
+
local current_cleanup_days="${GITBASH_CLEANUP_DAYS:-7}"
|
|
513
|
+
echo "7. Cleanup threshold in days"
|
|
514
|
+
echo " Current (effective): $current_cleanup_days"
|
|
515
|
+
read -re -p " User override: " input
|
|
516
|
+
if [[ -n "$input" && "$input" != "-" ]]; then
|
|
517
|
+
if [[ "$input" =~ ^[0-9]+$ ]] && [[ "$input" -ge 1 ]]; then
|
|
518
|
+
overrides+=("GITBASH_CLEANUP_DAYS=\"$input\"")
|
|
519
|
+
echo " → Will use '$input'"
|
|
520
|
+
else
|
|
521
|
+
echo " → Invalid value, keeping current setting"
|
|
522
|
+
fi
|
|
523
|
+
else
|
|
524
|
+
echo " → Keeping current setting"
|
|
525
|
+
fi
|
|
526
|
+
echo
|
|
527
|
+
|
|
528
|
+
# Check if any overrides were set
|
|
529
|
+
if [[ ${#overrides[@]} -eq 0 ]]; then
|
|
530
|
+
echo "No user overrides configured."
|
|
531
|
+
return 0
|
|
532
|
+
fi
|
|
533
|
+
|
|
534
|
+
# Write user config file
|
|
535
|
+
{
|
|
536
|
+
echo "# User-specific gitbash configuration overrides for this repository"
|
|
537
|
+
echo "# Generated by 'gitbash --config-user'"
|
|
538
|
+
echo "# These settings override both global (~/.gitbashrc) and local (.gitbashrc) settings"
|
|
539
|
+
echo "# This file should NOT be committed to version control"
|
|
540
|
+
echo
|
|
541
|
+
for override in "${overrides[@]}"; do
|
|
542
|
+
echo "$override"
|
|
543
|
+
done
|
|
544
|
+
} > "$user_config"
|
|
545
|
+
|
|
546
|
+
echo "Saved user configuration to $user_config"
|
|
547
|
+
|
|
548
|
+
# Add to .gitignore if not already present
|
|
549
|
+
if [[ -f "$gitignore" ]]; then
|
|
550
|
+
if ! grep -qxF "$USER_CONFIG_FILE" "$gitignore"; then
|
|
551
|
+
echo "$USER_CONFIG_FILE" >> "$gitignore"
|
|
552
|
+
echo "Added '$USER_CONFIG_FILE' to .gitignore"
|
|
553
|
+
else
|
|
554
|
+
echo "'$USER_CONFIG_FILE' already in .gitignore"
|
|
555
|
+
fi
|
|
556
|
+
else
|
|
557
|
+
echo "$USER_CONFIG_FILE" > "$gitignore"
|
|
558
|
+
echo "Created .gitignore with '$USER_CONFIG_FILE'"
|
|
559
|
+
fi
|
|
560
|
+
}
|
|
561
|
+
|
|
362
562
|
# Check and offer to install dependencies
|
|
363
563
|
check_dependencies() {
|
|
364
564
|
local missing_required=()
|
|
@@ -547,6 +747,7 @@ Usage:
|
|
|
547
747
|
gitbash --init
|
|
548
748
|
gitbash --config
|
|
549
749
|
gitbash --config-local
|
|
750
|
+
gitbash --config-user
|
|
550
751
|
|
|
551
752
|
Commands:
|
|
552
753
|
branch Interactive menu for branch operations
|
|
@@ -570,6 +771,7 @@ Options:
|
|
|
570
771
|
--init Print shell initialization code (for sourcing)
|
|
571
772
|
--config Configure gitbash and save to ~/.gitbashrc
|
|
572
773
|
--config-local Configure local overrides for current repository
|
|
774
|
+
--config-user Configure user-specific overrides (excluded from git)
|
|
573
775
|
|
|
574
776
|
Examples:
|
|
575
777
|
gitbash commit fix bug -p # Commit and push
|
|
@@ -632,6 +834,10 @@ main() {
|
|
|
632
834
|
configure_local_gitbash
|
|
633
835
|
exit 0
|
|
634
836
|
;;
|
|
837
|
+
--config-user)
|
|
838
|
+
configure_user_gitbash
|
|
839
|
+
exit 0
|
|
840
|
+
;;
|
|
635
841
|
*)
|
|
636
842
|
local cmd="$1"
|
|
637
843
|
shift
|
package/commands/_utils.sh
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
# Common utilities for gitbash commands - compatible with bash and zsh
|
|
4
4
|
|
|
5
5
|
# Load config files if they exist
|
|
6
|
-
# Global config first, then local repo config (which can override
|
|
6
|
+
# Global config first, then local repo config, then user config (which can override)
|
|
7
7
|
CONFIG_FILE="$HOME/.gitbashrc"
|
|
8
8
|
LOCAL_CONFIG_FILE=".gitbashrc"
|
|
9
|
+
USER_CONFIG_FILE=".gitbashrc-user"
|
|
9
10
|
|
|
10
11
|
if [[ -f "$CONFIG_FILE" ]]; then
|
|
11
12
|
# shellcheck disable=SC1090
|
|
@@ -18,6 +19,12 @@ if [[ -n "$_repo_root" && -f "$_repo_root/$LOCAL_CONFIG_FILE" ]]; then
|
|
|
18
19
|
# shellcheck disable=SC1090
|
|
19
20
|
source "$_repo_root/$LOCAL_CONFIG_FILE"
|
|
20
21
|
fi
|
|
22
|
+
|
|
23
|
+
# Source user config from repo root if present (overrides both)
|
|
24
|
+
if [[ -n "$_repo_root" && -f "$_repo_root/$USER_CONFIG_FILE" ]]; then
|
|
25
|
+
# shellcheck disable=SC1090
|
|
26
|
+
source "$_repo_root/$USER_CONFIG_FILE"
|
|
27
|
+
fi
|
|
21
28
|
unset _repo_root
|
|
22
29
|
|
|
23
30
|
# Color codes for consistent output
|
package/commands/stale.sh
CHANGED
|
@@ -177,7 +177,7 @@ EOF
|
|
|
177
177
|
local all_branch_list
|
|
178
178
|
all_branch_list=$(git for-each-ref --sort=committerdate --format='%(refname:short)|%(committerdate:relative)|%(authorname)|%(committerdate:unix)' refs/remotes/origin | \
|
|
179
179
|
grep -v 'origin/HEAD' | \
|
|
180
|
-
grep -v '^origin
|
|
180
|
+
grep -v '^origin|' | \
|
|
181
181
|
while IFS='|' read -r branch date author timestamp; do
|
|
182
182
|
# Remove origin/ prefix for display
|
|
183
183
|
local full_branch="${branch#origin/}"
|
|
@@ -194,7 +194,7 @@ EOF
|
|
|
194
194
|
local stale_branch_list
|
|
195
195
|
stale_branch_list=$(git for-each-ref --sort=committerdate --format='%(refname:short)|%(committerdate:relative)|%(authorname)|%(committerdate:unix)' refs/remotes/origin | \
|
|
196
196
|
grep -v 'origin/HEAD' | \
|
|
197
|
-
grep -v '^origin
|
|
197
|
+
grep -v '^origin|' | \
|
|
198
198
|
while IFS='|' read -r branch date author timestamp; do
|
|
199
199
|
# Only include if older than 3 months
|
|
200
200
|
if [[ "$timestamp" -lt "$threshold_ago" ]]; then
|
|
@@ -262,7 +262,7 @@ EOF
|
|
|
262
262
|
|
|
263
263
|
json_output+="{\"last_change_timestamp\":$timestamp,\"author_email\":\"$author_email\",\"author_name\":\"$author_name\",\"name\":\"$name\",\"last_change_relative\":\"$rel_date\"}"
|
|
264
264
|
fi
|
|
265
|
-
done < <(git for-each-ref --sort=committerdate --format='%(refname:short)|%(committerdate:relative)|%(authorname)|%(authoremail)|%(committerdate:unix)' refs/remotes/origin 2>/dev/null | grep -v 'origin/HEAD' | grep -v '^origin
|
|
265
|
+
done < <(git for-each-ref --sort=committerdate --format='%(refname:short)|%(committerdate:relative)|%(authorname)|%(authoremail)|%(committerdate:unix)' refs/remotes/origin 2>/dev/null | grep -v 'origin/HEAD' | grep -v '^origin|' || true)
|
|
266
266
|
} &>/dev/null
|
|
267
267
|
json_output+="]"
|
|
268
268
|
echo "$json_output"
|