From 62321700a3a5124160fff3dab3e7d4a14801b827 Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 21 Aug 2026 18:12:12 -0500 Subject: [PATCH] fix(git): review follow-ups for #1357 (S1, S2, indent) S1: get_gitea_login_for_repo_override() now distinguishes "tea is not installed" from "no tea login named X exists", mirroring the host path. The old message diagnosed a cause that was never checked and pointed at seat-logins.sh, which cannot run without tea. Branch 6 in test-gitea-login-resolution.sh pins it (tea removed from PATH); reverting the fix fails that branch. S2: issue-list/pr-list/pr-view override-path error now points at the lines above for the cause instead of suggesting a default tea login. verify-release.mjs: indent of the #1356 test line fixed (cosmetic). --- .../framework/tools/git/detect-platform.sh | 8 ++++++ .../mosaic/framework/tools/git/issue-list.sh | 2 +- .../mosaic/framework/tools/git/pr-list.sh | 2 +- .../mosaic/framework/tools/git/pr-view.sh | 2 +- .../tools/git/test-gitea-login-resolution.sh | 28 +++++++++++++++++++ scripts/verify-release.mjs | 2 +- 6 files changed, 40 insertions(+), 4 deletions(-) diff --git a/packages/mosaic/framework/tools/git/detect-platform.sh b/packages/mosaic/framework/tools/git/detect-platform.sh index c293f2e7..8398757f 100755 --- a/packages/mosaic/framework/tools/git/detect-platform.sh +++ b/packages/mosaic/framework/tools/git/detect-platform.sh @@ -468,6 +468,14 @@ get_gitea_login_for_repo_override() { echo "$canon" return 0 fi + # Same split as the host path above (#1357 S1): a missing tea binary + # is not a missing login, and the "create it with" advice cannot be + # followed without tea. + if ! command -v tea >/dev/null 2>&1; then + echo "Error: git identity '$ident' (via $ident_src) requested for owner '${owner%%/*}', but tea is not installed," >&2 + echo " so no login can be resolved. Refusing to guess an identity." >&2 + return 1 + fi echo "Error: git identity '$ident' (via $ident_src) has no tea login '$canon' for owner '${owner%%/*}'." >&2 echo " Create it with: ~/.config/mosaic/tools/fleet/seat-logins.sh --apply --seat $ident" >&2 return 1 diff --git a/packages/mosaic/framework/tools/git/issue-list.sh b/packages/mosaic/framework/tools/git/issue-list.sh index 16ad1520..4e59d3d9 100755 --- a/packages/mosaic/framework/tools/git/issue-list.sh +++ b/packages/mosaic/framework/tools/git/issue-list.sh @@ -100,7 +100,7 @@ case "$PLATFORM" in gitea) if [[ -n "$REPO_OVERRIDE" ]]; then GITEA_LOGIN_NAME=$(get_gitea_login_for_repo_override "$REPO_OVERRIDE") || { - echo "Error: Could not resolve Gitea login for --repo override. Set GITEA_LOGIN or configure a default tea login." >&2 + echo "Error: could not resolve a Gitea login for the --repo override (the lines above say why). Set GITEA_LOGIN to name one explicitly." >&2 exit 1 } else diff --git a/packages/mosaic/framework/tools/git/pr-list.sh b/packages/mosaic/framework/tools/git/pr-list.sh index 9d4320ff..11eebeab 100755 --- a/packages/mosaic/framework/tools/git/pr-list.sh +++ b/packages/mosaic/framework/tools/git/pr-list.sh @@ -95,7 +95,7 @@ case "$PLATFORM" in gitea) if [[ -n "$REPO_OVERRIDE" ]]; then GITEA_LOGIN_NAME=$(get_gitea_login_for_repo_override "$REPO_OVERRIDE") || { - echo "Error: Could not resolve Gitea login for --repo override. Set GITEA_LOGIN or configure a default tea login." >&2 + echo "Error: could not resolve a Gitea login for the --repo override (the lines above say why). Set GITEA_LOGIN to name one explicitly." >&2 exit 1 } else diff --git a/packages/mosaic/framework/tools/git/pr-view.sh b/packages/mosaic/framework/tools/git/pr-view.sh index dcc3dc66..72f53074 100755 --- a/packages/mosaic/framework/tools/git/pr-view.sh +++ b/packages/mosaic/framework/tools/git/pr-view.sh @@ -60,7 +60,7 @@ if [[ "$PLATFORM" == "github" ]]; then elif [[ "$PLATFORM" == "gitea" ]]; then if [[ -n "$REPO_OVERRIDE" ]]; then GITEA_LOGIN_NAME=$(get_gitea_login_for_repo_override "$REPO_OVERRIDE") || { - echo "Error: Could not resolve Gitea login for --repo override. Set GITEA_LOGIN or configure a default tea login." >&2 + echo "Error: could not resolve a Gitea login for the --repo override (the lines above say why). Set GITEA_LOGIN to name one explicitly." >&2 exit 1 } else diff --git a/packages/mosaic/framework/tools/git/test-gitea-login-resolution.sh b/packages/mosaic/framework/tools/git/test-gitea-login-resolution.sh index 5c1a9b60..10595c7f 100755 --- a/packages/mosaic/framework/tools/git/test-gitea-login-resolution.sh +++ b/packages/mosaic/framework/tools/git/test-gitea-login-resolution.sh @@ -463,6 +463,34 @@ if [[ "$override_explicit" != "mosaicstack" ]]; then exit 1 fi +# Branch 6 (#1357 S1): with tea ABSENT from PATH, the override path must say tea is +# missing, not "no tea login named X exists" (a cause that was never checked) and +# not the seat-logins.sh advice, which cannot be followed without tea. +NOTEA_BIN="$WORK_DIR/notea-bin"; mkdir -p "$NOTEA_BIN" +for t in bash git python3 sed grep cat mktemp dirname basename readlink env sort head tr cut; do + _p="$(command -v "$t" 2>/dev/null || true)"; [[ -n "$_p" ]] && ln -sf "$_p" "$NOTEA_BIN/$t" +done +override_notea_rc=0 +override_notea_err=$(cd "$REPO_DIR" && env -u GITEA_LOGIN \ + PATH="$NOTEA_BIN" HOME="$HOME_DIR" MOSAIC_GIT_IDENTITY=testseat \ + bash -c ' + command -v tea >/dev/null 2>&1 && { echo "SETUP: tea still on PATH"; exit 99; } + source "'"$SCRIPT_DIR"'/detect-platform.sh" + get_gitea_login_for_repo_override mosaicstack/stack +' 2>&1 >/dev/null) || override_notea_rc=$? +if [[ "$override_notea_rc" != 1 ]]; then + echo "Expected --repo override path to fail (rc=1) with tea absent; got rc=$override_notea_rc: $override_notea_err" >&2 + exit 1 +fi +if ! grep -q 'tea is not installed' <<<"$override_notea_err"; then + echo "Expected --repo override path to name tea as absent; got: $override_notea_err" >&2 + exit 1 +fi +if grep -q 'has no tea login\|seat-logins.sh' <<<"$override_notea_err"; then + echo "Override path diagnosed a missing LOGIN while tea itself is absent: $override_notea_err" >&2 + exit 1 +fi + git -C "$REPO_DIR" remote set-url origin https://git.uscllc.com/USC/uconnect.git diff --git a/scripts/verify-release.mjs b/scripts/verify-release.mjs index 4e7f7600..f35edf14 100644 --- a/scripts/verify-release.mjs +++ b/scripts/verify-release.mjs @@ -61,7 +61,7 @@ export const STAGES = [ 'bash packages/mosaic/framework/tools/quality/scripts/check-tools-index.sh --self-test', 'bash packages/mosaic/framework/tools/quality/scripts/check-tools-index.sh', 'bash packages/mosaic/framework/tools/git/test-issue-close-fail-closed.sh', - 'bash packages/mosaic/framework/tools/git/test-gitea-login-resolution.sh', + 'bash packages/mosaic/framework/tools/git/test-gitea-login-resolution.sh', 'bash packages/mosaic/framework/tools/git/test-issue-view-comments.sh', 'bash packages/mosaic/framework/tools/git/test-wrapper-guard.sh', 'bash packages/mosaic/framework/tools/git/test-mosaic-worktree-large-repo.sh',