git-jira-shortcuts 1.0.13 → 1.0.16
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 +37 -2
- package/package.json +1 -1
- package/shell/git-extras.sh +49 -4
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ The `init` command will walk you through configuration and add the necessary sou
|
|
|
26
26
|
|
|
27
27
|
## Configuration
|
|
28
28
|
|
|
29
|
-
Running `git-jira-shortcuts init` creates `~/.git-jira-shortcuts.env` with:
|
|
29
|
+
Running `git-jira-shortcuts init` creates `~/.git-jira-shortcuts.env` with your machine-wide settings:
|
|
30
30
|
|
|
31
31
|
| Variable | Required | Description |
|
|
32
32
|
|----------|----------|-------------|
|
|
@@ -34,6 +34,26 @@ Running `git-jira-shortcuts init` creates `~/.git-jira-shortcuts.env` with:
|
|
|
34
34
|
| `GJS_JIRA_DOMAIN` | Yes | Jira domain (e.g. `yourco.atlassian.net`) |
|
|
35
35
|
| `GJS_JIRA_API_TOKEN` | Yes | Base64-encoded Jira API token |
|
|
36
36
|
| `GJS_BRANCH_WEBHOOK_URL` | No | Optional webhook for branch name generation |
|
|
37
|
+
| `GJS_BRANCH_ALIASES` | No | Override `m`/`d` shorthand (e.g. `("m:main" "d:develop")`) |
|
|
38
|
+
|
|
39
|
+
### Per-repo config
|
|
40
|
+
|
|
41
|
+
Different repos can use different branch names (e.g. `main` vs `master`). Add a `.git-jira-shortcuts` file to any repo root to override your global settings for that repo:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# my-repo/.git-jira-shortcuts
|
|
45
|
+
GJS_BRANCH_ALIASES=("m:main" "d:develop")
|
|
46
|
+
GJS_TICKET_PREFIX=OTHERPROJ
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The file is sourced automatically when you `cd` into the repo, and your global settings are restored when you leave. Any `GJS_*` variable can be overridden this way.
|
|
50
|
+
|
|
51
|
+
You'll probably want to add this to your global gitignore so it doesn't get committed:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
echo ".git-jira-shortcuts" >> ~/.gitignore_global
|
|
55
|
+
git config --global core.excludesfile ~/.gitignore_global
|
|
56
|
+
```
|
|
37
57
|
|
|
38
58
|
### Generating your Jira API token
|
|
39
59
|
|
|
@@ -61,7 +81,7 @@ Running `git-jira-shortcuts init` creates `~/.git-jira-shortcuts.env` with:
|
|
|
61
81
|
### Branching
|
|
62
82
|
| Command | Alias | Description |
|
|
63
83
|
|---------|-------|-------------|
|
|
64
|
-
| `gswitch [branch]` | `gw` | Switch branches with interactive picker (↑/↓
|
|
84
|
+
| `gswitch [branch] [--force]` | `gw` | Switch branches with interactive picker (↑/↓). `--force` skips uncommitted and unpushed guards. |
|
|
65
85
|
| `gstart <branch\|ticket#>` | `gt`, `gcreate` | Create or switch to branch, auto-names from Jira |
|
|
66
86
|
| `gdelete [branch]` | `gdel` | Delete feature branch if clean and pushed |
|
|
67
87
|
| `gmerge [branch]` | `gm` | Merge branch into current if no conflicts |
|
|
@@ -108,9 +128,24 @@ gc fix the bug # Commits as "PROJ-1234: fix the bug"
|
|
|
108
128
|
```
|
|
109
129
|
|
|
110
130
|
### Branch shorthand
|
|
131
|
+
By default:
|
|
111
132
|
- `m` → `master`
|
|
112
133
|
- `d` → `develop`
|
|
113
134
|
|
|
135
|
+
To customize these (e.g. if your repo uses `main` instead of `master`), set `GJS_BRANCH_ALIASES` in `~/.git-jira-shortcuts.env`:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
GJS_BRANCH_ALIASES=("m:main" "d:develop")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
You can add as many aliases as you want:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
GJS_BRANCH_ALIASES=("m:main" "d:dev" "s:staging")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
When `GJS_BRANCH_ALIASES` is set, the defaults are replaced entirely — so include all the aliases you want.
|
|
148
|
+
|
|
114
149
|
## Update
|
|
115
150
|
|
|
116
151
|
```bash
|
package/package.json
CHANGED
package/shell/git-extras.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# git-jira-shortcuts — Git + Jira workflow shortcuts for zsh
|
|
3
3
|
# https://github.com/chipallen2/git-jira-shortcuts
|
|
4
4
|
#
|
|
5
|
-
#
|
|
5
|
+
# Global configuration (set in ~/.git-jira-shortcuts.env):
|
|
6
6
|
# GJS_TICKET_PREFIX — Jira project key (e.g. MYPROJ, ACME)
|
|
7
7
|
# GJS_JIRA_DOMAIN — Jira domain (e.g. yourco.atlassian.net)
|
|
8
8
|
# GJS_JIRA_API_TOKEN — Base64 Jira API token
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
# GJS_REPOS — Optional array of repo paths for grepos
|
|
11
11
|
# GJS_CLEAN_PROTECTED — Optional array of branch names to never delete with gclean
|
|
12
12
|
# GJS_BRANCH_ALIASES — Optional array of branch aliases (e.g. "m:master" "d:develop")
|
|
13
|
+
#
|
|
14
|
+
# Per-repo overrides (set in <repo-root>/.git-jira-shortcuts):
|
|
15
|
+
# Same variables as above — auto-loaded on cd, reset to global on leave.
|
|
16
|
+
# Example: GJS_BRANCH_ALIASES=("m:main" "d:develop")
|
|
13
17
|
|
|
14
18
|
# Store path to this script for self-reference (used by ghelp)
|
|
15
19
|
GJS_SHELL_SCRIPT_PATH="${0:A}"
|
|
@@ -43,6 +47,45 @@ _gjs_check_upgrade() {
|
|
|
43
47
|
fi
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
###
|
|
51
|
+
### PER-REPO CONFIG
|
|
52
|
+
###
|
|
53
|
+
|
|
54
|
+
# Snapshot global values (from ~/.git-jira-shortcuts.env) so they can be
|
|
55
|
+
# restored when leaving a repo that has local overrides.
|
|
56
|
+
_GJS_GLOBAL_TICKET_PREFIX="${GJS_TICKET_PREFIX:-}"
|
|
57
|
+
_GJS_GLOBAL_BRANCH_WEBHOOK_URL="${GJS_BRANCH_WEBHOOK_URL:-}"
|
|
58
|
+
if [[ -n "${GJS_BRANCH_ALIASES+x}" ]]; then
|
|
59
|
+
_GJS_GLOBAL_BRANCH_ALIASES=("${GJS_BRANCH_ALIASES[@]}")
|
|
60
|
+
_GJS_GLOBAL_BRANCH_ALIASES_ISSET=1
|
|
61
|
+
else
|
|
62
|
+
_GJS_GLOBAL_BRANCH_ALIASES=()
|
|
63
|
+
_GJS_GLOBAL_BRANCH_ALIASES_ISSET=0
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# Load .git-jira-shortcuts from the current repo root (if present),
|
|
67
|
+
# overriding global values. Resets to globals first so leaving a repo
|
|
68
|
+
# with local overrides cleanly reverts to the machine-wide config.
|
|
69
|
+
_gjs_apply_repo_config() {
|
|
70
|
+
GJS_TICKET_PREFIX="$_GJS_GLOBAL_TICKET_PREFIX"
|
|
71
|
+
GJS_BRANCH_WEBHOOK_URL="$_GJS_GLOBAL_BRANCH_WEBHOOK_URL"
|
|
72
|
+
if [[ "$_GJS_GLOBAL_BRANCH_ALIASES_ISSET" -eq 1 ]]; then
|
|
73
|
+
GJS_BRANCH_ALIASES=("${_GJS_GLOBAL_BRANCH_ALIASES[@]}")
|
|
74
|
+
else
|
|
75
|
+
unset GJS_BRANCH_ALIASES
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
local git_root
|
|
79
|
+
git_root=$(git rev-parse --show-toplevel 2>/dev/null) || return 0
|
|
80
|
+
local rc_file="$git_root/.git-jira-shortcuts"
|
|
81
|
+
[[ -f "$rc_file" ]] && source "$rc_file"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Auto-apply on directory change and immediately for the current directory.
|
|
85
|
+
autoload -U add-zsh-hook 2>/dev/null
|
|
86
|
+
add-zsh-hook chpwd _gjs_apply_repo_config
|
|
87
|
+
_gjs_apply_repo_config
|
|
88
|
+
|
|
46
89
|
###
|
|
47
90
|
### INTERNAL HELPERS
|
|
48
91
|
###
|
|
@@ -334,7 +377,7 @@ ghelp() { # ghelp | Show all git-jira-shortcuts commands
|
|
|
334
377
|
|
|
335
378
|
── Branching ──────────────────────────────────────────────────
|
|
336
379
|
gw [branch] Switch branches — arrow-key picker if no branch given
|
|
337
|
-
gswitch (same, also accepts --force / -f)
|
|
380
|
+
gswitch (same, also accepts --force / -f to skip dirty or unpushed guards)
|
|
338
381
|
gt <branch|ticket#> Create or switch to a branch — auto-names from Jira
|
|
339
382
|
gstart, gcreate (same)
|
|
340
383
|
gdel [branch] Delete a branch — interactive picker, safety checks
|
|
@@ -553,7 +596,7 @@ greset() { # greset [*file] | Reset a specific file with confirmation (interacti
|
|
|
553
596
|
}
|
|
554
597
|
alias gr='greset' # greset [*file] | Alias for greset
|
|
555
598
|
|
|
556
|
-
gswitch() { # gswitch [*branch] [--force|-f] | Switch branches (
|
|
599
|
+
gswitch() { # gswitch [*branch] [--force|-f] | Switch branches (bypass dirty tree / unpushed guards with --force)
|
|
557
600
|
local force_switch=0
|
|
558
601
|
local -a positional=()
|
|
559
602
|
local arg
|
|
@@ -580,8 +623,9 @@ gswitch() { # gswitch [*branch] [--force|-f] | Switch branches (optionally bypas
|
|
|
580
623
|
local unpushed
|
|
581
624
|
unpushed=$(git log origin/"$branch"..HEAD --oneline 2>/dev/null)
|
|
582
625
|
|
|
583
|
-
if [[ -n "$unpushed" ]]; then
|
|
626
|
+
if [[ $force_switch -eq 0 && -n "$unpushed" ]]; then
|
|
584
627
|
echo "🚫 You have commits on '$branch' not pushed to origin. Push them first."
|
|
628
|
+
echo " Use 'gw --force [branch]' to switch anyway."
|
|
585
629
|
return 1
|
|
586
630
|
fi
|
|
587
631
|
|
|
@@ -986,6 +1030,7 @@ testJira() { # testJira | Test Jira API connection
|
|
|
986
1030
|
}
|
|
987
1031
|
alias tj='testJira' # testJira | Test Jira API connection
|
|
988
1032
|
|
|
1033
|
+
unalias gclean 2>/dev/null
|
|
989
1034
|
gclean() { # gclean [--dry-run] | Delete local branches already merged to master (skips recent)
|
|
990
1035
|
local dry_run=0
|
|
991
1036
|
|