dmitri.shuralyov.com/service/change/maintner

handle draft status

The latest Gerrit API documents only NEW, MERGED, and ABANDONED statuses
at https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info.
Update changeState in the gerritapi package accordingly.

On the other hand, the maintner API documents that GerritCL.Status will
be will be "new", "merged", "abandoned", or "draft". Out of the options
available in change.Status, change.OpenState is the best available pick
for "draft", so use it. One example of such a CL in the maintner corpus
with "draft" status is CL 38720 in x/build, so there's no choice but to
handle that status somehow. It can be refined, if needed, in the future.

Also upgrade to go@1.23.0 and go-gerrit@v1.0.0 while here.
dmitshur committed 3 weeks ago commit 6140fdcb140798fe4fda313c57be133bf235e796
Showing partial commit. Full Commit
Collapse all
maintner/maintner.go
@@ -291,20 +291,19 @@ func (s service) GetDiff(_ context.Context, repo string, id uint64, opt *change.

func (service) EditComment(_ context.Context, repo string, id uint64, cr change.CommentRequest) (change.Comment, error) {
	return change.Comment{}, fmt.Errorf("EditComment: not implemented")
}

// changeState converts a [golang.org/x/build/maintner.GerritCL.Status] to [change.State].
func changeState(status string) change.State {
	switch status {
	case "new":
	case "new", "draft":
		return change.OpenState
	case "abandoned":
		return change.ClosedState
	case "merged":
		return change.MergedState
	case "draft":
		panic("not sure how to deal with draft status")
	default:
		panic(fmt.Errorf("unrecognized status %q", status))
	}
}