mirror of https://github.com/garrytan/gstack.git
refactor: lowercase slug in gstack-slug and getRemoteSlug()
Fixes mixed-case slugs like Garry-s-List-garryslist by adding tr '[:upper:]' '[:lower:]' to bash and .toLowerCase() to TypeScript. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
82cf085213
commit
07aad3562f
|
|
@ -3,7 +3,7 @@
|
||||||
# Usage: eval $(gstack-slug) → sets SLUG and BRANCH variables
|
# Usage: eval $(gstack-slug) → sets SLUG and BRANCH variables
|
||||||
# Or: gstack-slug → prints SLUG=... and BRANCH=... lines
|
# Or: gstack-slug → prints SLUG=... and BRANCH=... lines
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
SLUG=$(git remote get-url origin 2>/dev/null | sed 's|.*[:/]\([^/]*/[^/]*\)\.git$|\1|;s|.*[:/]\([^/]*/[^/]*\)$|\1|' | tr '/' '-')
|
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 '/' '-')
|
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null | tr '/' '-')
|
||||||
echo "SLUG=$SLUG"
|
echo "SLUG=$SLUG"
|
||||||
echo "BRANCH=$BRANCH"
|
echo "BRANCH=$BRANCH"
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ export function getRemoteSlug(): string {
|
||||||
// SSH: git@github.com:owner/repo.git → owner-repo
|
// SSH: git@github.com:owner/repo.git → owner-repo
|
||||||
// HTTPS: https://github.com/owner/repo.git → owner-repo
|
// HTTPS: https://github.com/owner/repo.git → owner-repo
|
||||||
const match = url.match(/[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);
|
const match = url.match(/[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);
|
||||||
if (match) return `${match[1]}-${match[2]}`;
|
if (match) return `${match[1]}-${match[2]}`.toLowerCase();
|
||||||
throw new Error('unparseable');
|
throw new Error('unparseable');
|
||||||
} catch {
|
} catch {
|
||||||
const root = getGitRoot();
|
const root = getGitRoot();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue