10 lines
487 B
Plaintext
10 lines
487 B
Plaintext
|
|
#!/usr/bin/env bash
|
||
|
|
# gstack-slug — output project slug and sanitized branch name
|
||
|
|
# Usage: source <(gstack-slug) → sets SLUG and BRANCH variables
|
||
|
|
# Or: gstack-slug → prints SLUG=... and BRANCH=... lines
|
||
|
|
set -euo pipefail
|
||
|
|
SLUG=$(git remote get-url origin 2>/dev/null | sed 's|.*[:/]\([^/]*/[^/]*\)\.git$|\1|;s|.*[:/]\([^/]*/[^/]*\)$|\1|' | tr '/' '-')
|
||
|
|
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr '/' '-')
|
||
|
|
echo "SLUG=$SLUG"
|
||
|
|
echo "BRANCH=$BRANCH"
|