PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.2.9
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.2.9
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / .claude / skills / issue-workflow / scripts / make-issue-branch.sh

make-issue-branch.sh in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.2.9, at .claude/skills/issue-workflow/scripts/make-issue-branch.sh

46 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 #!/usr/bin/env bash
2 # Create a branch name from an issue number and title.
3 # Usage: make-issue-branch.sh <issue-number> "<issue-title>" [prefix] [base-ref]
4 # prefix: fix (default), enhancement, test
5 #
6 # base-ref: pass an explicit ref such as "origin/develop" when running inside a
7 # worktree or after a git fetch to avoid inheriting unexpected commits.
8 # Defaults to "origin/develop" when omitted.
9 set -euo pipefail
10
11 # Required arguments.
12 ISSUE_NUMBER="${1:?issue number required}"
13 TITLE="${2:?issue title required}"
14
15 # Optional prefix — determines branch type per naming convention.
16 PREFIX="${3:-fix}"
17
18 # Validate prefix.
19 case "$PREFIX" in
20 fix|enhancement|test) ;;
21 *) PREFIX="fix" ;;
22 esac
23
24 # Optional base ref — defaults to origin/develop (Imagify base branch).
25 BASE_REF="${4:-origin/develop}"
26
27 # Build a short, URL-safe slug from the title (first 4 words max).
28 SLUG="$(printf '%s' "$TITLE" \
29 | tr '[:upper:]' '[:lower:]' \
30 | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//' \
31 | cut -d- -f1-4 \
32 | sed 's/-*$//')"
33
34 # Branch naming convention: <prefix>/<issue>-<slug>
35 BRANCH="${PREFIX}/${ISSUE_NUMBER}-${SLUG}"
36
37 # Create and switch to the branch (idempotent — safe if branch already exists).
38 if git show-ref --verify --quiet "refs/heads/${BRANCH}"; then
39 git checkout "$BRANCH"
40 elif [[ -n "$BASE_REF" ]]; then
41 git checkout -b "$BRANCH" "$BASE_REF"
42 else
43 git checkout -b "$BRANCH"
44 fi
45 echo "$BRANCH"
46