The delivery repository's contracts and SDK live under modules/ as mesh-delivery-contracts and mesh-delivery-sdk, their Go module paths renamed to match the folders (the TypeScript names already did), and every importer in mesh-delivery, mesh-catalog, mesh-host, mesh-tools and mesh-sdk follows in the same group: a design as it should be, one path per module, checked by the group's check building every importer. Builds: design 47 G §427, §88 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
46 lines
2.1 KiB
Go
46 lines
2.1 KiB
Go
package bridge
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
git "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git"
|
|
)
|
|
|
|
// ForgePull is a pull request as the forge itself says it: what the bridge needs of a merge made on the forge, not
|
|
// through the gate (a recovery merge or the operator's own, which the gate holds no merge of; issue 1966).
|
|
type ForgePull struct {
|
|
Number int
|
|
Branch string // the pull request's head branch
|
|
Head string // the head commit
|
|
Merge string // the merge commit into the trunk
|
|
}
|
|
|
|
// ForgeMade reads, through the seat `git`'s verb pull, the merged pull request whose merge commit is merge: by number
|
|
// when number is given (its merge commit must then equal merge), else by the merge commit. A pull request not merged,
|
|
// merged into another branch than the trunk, or merged at another commit is refused.
|
|
func ForgeMade(ctx context.Context, call Caller, owner, repo string, number int, merge string) (ForgePull, error) {
|
|
in := git.PullInput{Repository: repository(owner, repo), MergeCommit: merge}
|
|
if number > 0 {
|
|
in = git.PullInput{Repository: repository(owner, repo), Number: int64(number)}
|
|
}
|
|
a, err := askGit[git.PullAnswer](ctx, call, git.VerbPull, in)
|
|
if err != nil {
|
|
return ForgePull{}, err
|
|
}
|
|
p := a.Pull
|
|
switch {
|
|
case p == nil || p.Number == 0:
|
|
return ForgePull{}, fmt.Errorf("the pull request of %s at %s: %w", in.Repository, merge, errNoAnswer)
|
|
case p.State != git.PullStateMerged:
|
|
return ForgePull{}, fmt.Errorf("the forge says the pull request %s#%d is %s, not merged", in.Repository, p.Number, p.State)
|
|
case p.MergeCommit != merge:
|
|
return ForgePull{}, fmt.Errorf("the forge says %s#%d was merged at %s, not at %s", in.Repository, p.Number, p.MergeCommit, merge)
|
|
case p.Base != Trunk:
|
|
return ForgePull{}, fmt.Errorf("the forge says %s#%d was merged into %s, not the trunk %s", in.Repository, p.Number, p.Base, Trunk)
|
|
case p.Branch == "":
|
|
return ForgePull{}, fmt.Errorf("the forge gives no head branch for %s#%d", in.Repository, p.Number)
|
|
}
|
|
return ForgePull{Number: int(p.Number), Branch: p.Branch, Head: p.Head, Merge: p.MergeCommit}, nil
|
|
}
|