Treat incomplete remote tag observations as uncertain

This commit is contained in:
2026-11-01 21:11:06 +00:00
parent 730e6380c8
commit 0632aa5901
6 changed files with 155 additions and 4 deletions

View File

@@ -749,6 +749,31 @@ func TestPublishUnavailableReconciliationRemainsUnknownAndPreservesPushError(t *
}
}
func TestPublishPeeledOnlyReconciliationRemainsUnknown(t *testing.T) {
repo := newPublishFixture(t)
wrapper := installGitWrapper(t, repo, "peeled-only")
t.Setenv("PATH", wrapper.bin+string(os.PathListSeparator)+os.Getenv("PATH"))
result, err := releasekit.Publish(context.Background(), releasekit.ReleaseRequest{
RepositoryDir: repo.work, Product: "Sample App", Version: "v1.2.3",
AdditionalChecks: func(context.Context, releasekit.Candidate) error { return nil },
})
if err == nil || result.State != releasekit.PublicationUnknown || result.Phase != releasekit.PublicationReconciliation || result.TagObject == "" {
t.Fatalf("result = %#v, error = %v", result, err)
}
var exitErr *exec.ExitError
if !errors.As(err, &exitErr) || exitErr.ExitCode() != 77 || !strings.Contains(err.Error(), "lost acknowledgment") {
t.Fatalf("push cause not retained: %v", err)
}
if count := countLines(t, wrapper.queryLog); count != 4 {
t.Fatalf("tag query count = %d, want one recovery query", count)
}
for _, dir := range []string{repo.work, repo.bare} {
if got := gitText(t, dir, "rev-parse", "refs/tags/v1.2.3"); got != result.TagObject {
t.Fatalf("tag in %s = %s, want %s", dir, got, result.TagObject)
}
}
}
func TestPublishUninterpretableReconciliationRemainsUnknown(t *testing.T) {
repo := newPublishFixture(t)
other := gitText(t, repo.work, "rev-parse", "refs/tags/v0.9.0")
@@ -931,11 +956,24 @@ if [ "$IS_LS_REMOTE" = "1" ]; then
;;
esac
fi
if [ "$MODE" = "peeled-only" ] && [ -f "$PUSH_DONE" ]; then
case "$ARGS" in
*refs/tags/v1.2.3*)
OBJECT=$("$REAL_GIT" rev-parse 'refs/tags/v1.2.3^{}')
printf '%%s\trefs/tags/v1.2.3^{}\n' "$OBJECT"
exit 0
;;
esac
fi
fi
if [ "$IS_PUSH" = "1" ]; then
"$REAL_GIT" "$@"
STATUS=$?
: > "$PUSH_DONE"
if [ "$MODE" = "peeled-only" ] && [ "$STATUS" = "0" ]; then
echo "lost acknowledgment after tag was accepted" >&2
exit 77
fi
if [ "$MODE" = "lost-ack-cancel" ] && [ "$STATUS" = "0" ]; then kill -STOP $$; fi
if [ "$MODE" = "lost-ack-rewrite" ] && [ "$STATUS" = "0" ]; then
"$REAL_GIT" config --local "url.\"$MUTATE_OBJECT\".insteadOf" %s