From 436c723a2f3fd9f54a0f57fdeada542f285edd26 Mon Sep 17 00:00:00 2001 From: orion Date: Tue, 14 Apr 2026 19:46:31 +0000 Subject: [PATCH] fix(git-hangman-lab): publish-package - handle cross-owner repo link gracefully The link step now: 1. Extracts the actual repo owner from the git remote URL 2. Captures HTTP response status and body 3. Shows a clear warning when the repo belongs to a different owner (requires site admin or matching owner), instead of silently failing --- git-hangman-lab/scripts/publish-package | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/git-hangman-lab/scripts/publish-package b/git-hangman-lab/scripts/publish-package index 387872c..0090d5a 100755 --- a/git-hangman-lab/scripts/publish-package +++ b/git-hangman-lab/scripts/publish-package @@ -88,9 +88,29 @@ do_docker() { # Link package to repository TOKEN=$(secret-mgr get-secret --key git-access-token 2>/dev/null || secret-mgr get-secret --key git) REPO_NAME=$(basename "$REPO") - curl -s -X POST \ + + # Determine the actual owner of the git repository + REPO_OWNER="$OWNER" + if [[ -d "$REPO/.git" ]]; then + REMOTE_URL=$(git -C "$REPO" remote get-url origin 2>/dev/null || true) + if [[ "$REMOTE_URL" =~ git\.hangman-lab\.top/([^/]+)/ ]]; then + REPO_OWNER="${BASH_REMATCH[1]}" + fi + fi + + LINK_RESP=$(curl -s -w "%{http_code}" -X POST \ -H "Authorization: token $TOKEN" \ - "https://git.hangman-lab.top/api/v1/packages/${OWNER}/container/${IMAGE}/-/link/${REPO_NAME}" || true + "https://git.hangman-lab.top/api/v1/packages/${OWNER}/container/${IMAGE}/-/link/${REPO_NAME}") + LINK_STATUS="${LINK_RESP: -3}" + LINK_BODY="${LINK_RESP:0:-3}" + + if [[ "$LINK_STATUS" != "200" && "$LINK_STATUS" != "201" ]]; then + if echo "$LINK_BODY" | grep -q '"message".*repository does not exist'; then + echo "Warning: repository '$REPO_NAME' is not owned by '$OWNER' — skipping link (requires site admin or matching owner)." + else + echo "Warning: package link failed (HTTP $LINK_STATUS): $LINK_BODY" + fi + fi lock-mgr release "$LOCKFILE" "$KEY" echo "Done: $FULL_IMAGE"