gitea: the not-stored refusal for another digest applies to the no-parts publish only; the one-part publish keeps trunk's refusal

Builds: design 47 G A-490, A-490a

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-19 17:09:16 +01:00
parent 13d43a7de0
commit f85199f624
2 changed files with 10 additions and 5 deletions
@@ -226,10 +226,15 @@ func (h *Holder) Publish(seat, caller string, p Publish) (Answer, error) {
return Answer{}, fmt.Errorf("publish: the forge cannot say whether it holds %s@%s: %w", p.Name, p.Version, err)
} else if ok {
if d != p.Digest {
// A no-parts publish names nothing the forge holds: it is refused as not stored (A-490), which the builder's
// republish recognises by those words.
reason := fmt.Sprintf("not stored: %s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest)
return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason))
reason := fmt.Sprintf("%s@%s is published with %s, not %s", p.Name, p.Version, d, p.Digest)
if len(p.Parts) == 0 {
// The builder's publish again names nothing the forge holds under that digest: refused as not stored (A-490,
// A-490a), the words its republish recognises.
reason = "not stored: " + reason
return Answer{Transfer: p.Transfer, Ended: true}, errors.Join(errors.New("publish: "+reason), h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason))
}
// A one-part publish of a taken version is refused with an event only, as the registry would (the builder's "version taken").
return Answer{Transfer: p.Transfer, Ended: true}, h.refused(Transfer{Shape: Opening{Publish: p, Seat: seat}}, reason)
}
o := outcomeOf(p, "")
o.Reference = Reference(p.Name, p.Version)
@@ -334,7 +334,7 @@ func TestTheForgeHoldsBothPackageSeats(t *testing.T) {
// The same version published with other content is refused, never uploaded over.
b = newBed(true)
b.forge.files[NpmSeat] = map[string][]byte{"x@0.1.0": []byte("first")}
if _, err := b.h.Publish(NpmSeat, nodeBuild, pub("x", "0.1.0", file)); err == nil || !strings.Contains(err.Error(), "not stored") || len(b.said) != 1 || b.said[0].event != EventRefused {
if _, err := b.h.Publish(NpmSeat, nodeBuild, pub("x", "0.1.0", file)); err != nil || len(b.said) != 1 || b.said[0].event != EventRefused {
t.Errorf("a published version with other content: %v, said %+v", err, b.said)
}
})