mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-22 04:38:24 +08:00
feat: add remote slug helper and auto-gitignore for .gstack/
- getRemoteSlug() in config.ts: parses git remote origin → owner-repo format - browse/bin/remote-slug: shell helper for SKILL.md use (BSD sed compatible) - ensureStateDir() now appends .gstack/ to project .gitignore if not present - setup creates ~/.gstack/projects/ global state directory - 7 new tests: 4 gitignore behavior + 3 remote slug parsing
This commit is contained in:
14
browse/bin/remote-slug
Executable file
14
browse/bin/remote-slug
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Output the remote slug (owner-repo) for the current git repo.
|
||||
# Used by SKILL.md files to derive project-specific paths in ~/.gstack/projects/.
|
||||
set -e
|
||||
URL=$(git remote get-url origin 2>/dev/null || true)
|
||||
if [ -n "$URL" ]; then
|
||||
# Strip trailing .git if present, then extract owner/repo
|
||||
URL="${URL%.git}"
|
||||
# Handle both SSH (git@host:owner/repo) and HTTPS (https://host/owner/repo)
|
||||
OWNER_REPO=$(echo "$URL" | sed -E 's#.*[:/]([^/]+)/([^/]+)$#\1-\2#')
|
||||
echo "$OWNER_REPO"
|
||||
else
|
||||
basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
fi
|
||||
Reference in New Issue
Block a user