mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-06 05:35:46 +02:00
b332364b43
gstack-slug now outputs PROJECTS_DIR (respecting GSTACK_STATE_DIR env var). lib/util.ts gets getProjectsDir(slug?) as single source of truth for TypeScript consumers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
13 lines
623 B
Bash
Executable File
13 lines
623 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# gstack-slug — output project slug and sanitized branch name
|
|
# Usage: eval $(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 '/' '-' | tr '[:upper:]' '[:lower:]')
|
|
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr '/' '-')
|
|
STATE_DIR="${GSTACK_STATE_DIR:-$HOME/.gstack}"
|
|
PROJECTS_DIR="${STATE_DIR}/projects"
|
|
echo "SLUG=$SLUG"
|
|
echo "BRANCH=$BRANCH"
|
|
echo "PROJECTS_DIR=$PROJECTS_DIR"
|