git-jira-shortcuts 1.0.16 → 1.0.18

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 CHANGED
@@ -75,7 +75,8 @@ git config --global core.excludesfile ~/.gitignore_global
75
75
  | `gs` | `gstatus` | Clean git status with remote sync info |
76
76
  | `glist` | `gl` | List files pending in this branch |
77
77
  | `grecent` | — | Show recently checked out branches (last 10) |
78
- | `grepos` | `repos` | Show all repo clones and their current branch |
78
+ | `grepos` | `repos` | Show all repo clones and their current branch (with Jira URLs) |
79
+ | `gstory [branch]` | — | Print the Jira story URL for the current (or given) branch |
79
80
  | `ghelp` | — | Show all available commands |
80
81
 
81
82
  ### Branching
@@ -152,6 +153,12 @@ When `GJS_BRANCH_ALIASES` is set, the defaults are replaced entirely — so incl
152
153
  npm update -g git-jira-shortcuts
153
154
  ```
154
155
 
156
+ After upgrading, open a new terminal session or reload your current shell:
157
+
158
+ ```bash
159
+ source ~/.zshrc
160
+ ```
161
+
155
162
  ## Reconfigure
156
163
 
157
164
  ```bash
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ console.log(`
4
+ git-jira-shortcuts installed/updated.
5
+
6
+ Remember to start a new terminal session before using gw, gs, ghelp, etc.
7
+ Existing terminals keep the old shell functions in memory.
8
+
9
+ Or reload your current shell with:
10
+ source ~/.zshrc
11
+ `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-jira-shortcuts",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Git + Jira workflow shortcuts for zsh — interactive branch switching, auto-prefixed commits, Jira integration, and more.",
5
5
  "author": "chipallen2",
6
6
  "license": "MIT",
@@ -11,6 +11,9 @@
11
11
  "bin": {
12
12
  "git-jira-shortcuts": "./bin/cli.js"
13
13
  },
14
+ "scripts": {
15
+ "postinstall": "node ./bin/postinstall.js"
16
+ },
14
17
  "files": [
15
18
  "bin/",
16
19
  "shell/",
@@ -268,6 +268,34 @@ _gjs_sanitize_branch_name() {
268
268
  cut -c1-50
269
269
  }
270
270
 
271
+ _gjs_extract_ticket_from_branch() {
272
+ local branch="$1"
273
+ [[ -z "$branch" ]] && return 1
274
+ if [[ -n "$GJS_TICKET_PREFIX" ]]; then
275
+ local pattern="^${GJS_TICKET_PREFIX}-[0-9]+"
276
+ if [[ "$branch" =~ $pattern ]]; then
277
+ echo "$MATCH"
278
+ return 0
279
+ fi
280
+ fi
281
+ if [[ "$branch" =~ ^[A-Z][A-Z0-9_]+-[0-9]+ ]]; then
282
+ echo "$MATCH"
283
+ return 0
284
+ fi
285
+ return 1
286
+ }
287
+
288
+ _gjs_jira_story_url() {
289
+ local branch="$1"
290
+ [[ -z "$branch" ]] && branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
291
+ [[ -z "$branch" || -z "$GJS_JIRA_DOMAIN" ]] && return 1
292
+ local ticket
293
+ if ! ticket=$(_gjs_extract_ticket_from_branch "$branch"); then
294
+ return 1
295
+ fi
296
+ echo "https://$GJS_JIRA_DOMAIN/browse/$ticket"
297
+ }
298
+
271
299
  _gjs_get_jira_story_title() {
272
300
  local story_number="$1"
273
301
 
@@ -322,11 +350,34 @@ grecent() { # grecent | Show recently checked out branches (last 10)
322
350
  sed 's/^/ /'
323
351
  }
324
352
 
353
+ gstory() { # gstory [branch] | Print Jira story URL for current (or given) branch
354
+ local branch="$1"
355
+ [[ -z "$branch" ]] && branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
356
+ if [[ -z "$branch" ]]; then
357
+ echo "❌ Not a git repo." >&2
358
+ return 1
359
+ fi
360
+ if [[ -z "$GJS_JIRA_DOMAIN" ]]; then
361
+ echo "❌ GJS_JIRA_DOMAIN not set. Run: git-jira-shortcuts init" >&2
362
+ return 1
363
+ fi
364
+ local url
365
+ if ! url=$(_gjs_jira_story_url "$branch"); then
366
+ echo "❌ No Jira ticket found in branch '$branch'." >&2
367
+ return 1
368
+ fi
369
+ echo "$url"
370
+ }
371
+
325
372
  unalias gs 2>/dev/null
326
373
  gs() { # gs | Clean git status with remote sync info
327
374
  local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
328
375
  [[ -z "$branch" ]] && echo "Not a git repo" && return 1
329
376
  echo "\033[1m$branch\033[0m"
377
+ local story_url
378
+ if story_url=$(_gjs_jira_story_url "$branch"); then
379
+ echo "\033[2mWork: $story_url\033[0m"
380
+ fi
330
381
  local staged=$(git diff --cached --numstat 2>/dev/null | wc -l | tr -d ' ')
331
382
  local unstaged=$(git diff --numstat 2>/dev/null | wc -l | tr -d ' ')
332
383
  local untracked=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d ' ')
@@ -347,19 +398,39 @@ alias gp='git pull --no-rebase --no-edit' # gp | Pull without rebase or editor
347
398
 
348
399
  grepos() { # grepos | Show all repo clones and their current branch
349
400
  [[ -z "${GJS_REPOS+x}" ]] && echo "GJS_REPOS not defined. Run: git-jira-shortcuts init" && return 1
350
- local max_len=0
401
+ local max_label=0
402
+ local max_branch=0
403
+ local -a labels=() dirs=() branches=()
351
404
  for entry in "${GJS_REPOS[@]}"; do
352
405
  local label="${entry##*:}"
353
- (( ${#label} > max_len )) && max_len=${#label}
354
- done
355
- for entry in "${GJS_REPOS[@]}"; do
356
406
  local dir="${entry%:*}"
357
- local label="${entry##*:}"
407
+ local branch=""
358
408
  if [[ -d "$dir/.git" ]]; then
359
- local branch=$(git -C "$dir" rev-parse --abbrev-ref HEAD 2>/dev/null)
360
- printf "%-${max_len}s %s\n" "$label" "${branch:-???}"
409
+ branch=$(git -C "$dir" rev-parse --abbrev-ref HEAD 2>/dev/null)
410
+ [[ -z "$branch" ]] && branch="???"
411
+ else
412
+ branch="(not found)"
413
+ fi
414
+ labels+=("$label")
415
+ dirs+=("$dir")
416
+ branches+=("$branch")
417
+ (( ${#label} > max_label )) && max_label=${#label}
418
+ (( ${#branch} > max_branch )) && max_branch=${#branch}
419
+ done
420
+ local i
421
+ for (( i=1; i<=${#labels[@]}; i++ )); do
422
+ local label="${labels[$i]}"
423
+ local branch="${branches[$i]}"
424
+ local story_url=""
425
+ if [[ "$branch" != "???" && "$branch" != "(not found)" ]]; then
426
+ story_url=$(_gjs_jira_story_url "$branch" 2>/dev/null)
427
+ fi
428
+ if [[ "$branch" == "(not found)" ]]; then
429
+ printf "%-${max_label}s \033[31m%s\033[0m\n" "$label" "$branch"
430
+ elif [[ -n "$story_url" ]]; then
431
+ printf "%-${max_label}s %-${max_branch}s \033[2m%s\033[0m\n" "$label" "$branch" "$story_url"
361
432
  else
362
- printf "%-${max_len}s %s\n" "$label" "\033[31m(not found)\033[0m"
433
+ printf "%-${max_label}s %s\n" "$label" "$branch"
363
434
  fi
364
435
  done
365
436
  }
@@ -409,6 +480,7 @@ ghelp() { # ghelp | Show all git-jira-shortcuts commands
409
480
 
410
481
  ── Utilities ──────────────────────────────────────────────────
411
482
  grepos / repos Show all repo clones and their current branch
483
+ gstory [branch] Print Jira story URL for current (or given) branch
412
484
  testJira / tj Test your Jira API connection
413
485
  ghelp This help screen
414
486
 
@@ -515,6 +587,10 @@ gpr() { # gpr [*branch=m] | Open GitHub compare URL from current branch to targe
515
587
 
516
588
  local url="https://github.com/${repo_path}/compare/${target}...${current_branch}?expand=1"
517
589
  echo "$url"
590
+ local story_url
591
+ if story_url=$(_gjs_jira_story_url "$current_branch"); then
592
+ echo "Work: $story_url"
593
+ fi
518
594
  open "$url" 2>/dev/null || xdg-open "$url" 2>/dev/null || echo "Open the URL above in your browser."
519
595
  }
520
596