about summary refs log tree commit diff
path: root/gerrit/changeset.go
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-12-09T10·49+0300
committerVincent Ambo <mail@tazj.in>2021-12-09T10·49+0300
commit24f5a642af3aa1627bbff977f0a101907a02c69f (patch)
treef1c0a6607ec9fdcdf03091fe5fbc5dabc5536a47 /gerrit/changeset.go
parentc67b3ba7ea769cd747ea2f43ee6d12943d599ae0 (diff)
gerrit: Use a Gerrit label instead of hashtag for autosubmit
This moves to using a Gerrit label ('Autosubmit') with boolean values
for determining whether a developer wants to have a change
automatically submitted.

See also https://cl.tvl.fyi/c/depot/+/4172
Diffstat (limited to 'gerrit/changeset.go')
-rw-r--r--gerrit/changeset.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/gerrit/changeset.go b/gerrit/changeset.go
index 0a0a607cd611..f71032a567cb 100644
--- a/gerrit/changeset.go
+++ b/gerrit/changeset.go
@@ -16,8 +16,8 @@ type Changeset struct {
 	Number          int
 	Verified        int
 	CodeReviewed    int
+	Autosubmit      int
 	Submittable     bool
-	HashTags        []string
 	CommitID        string
 	ParentCommitIDs []string
 	OwnerName       string
@@ -32,8 +32,8 @@ func MakeChangeset(changeInfo *goGerrit.ChangeInfo) *Changeset {
 		Number:          changeInfo.Number,
 		Verified:        labelInfoToInt(changeInfo.Labels["Verified"]),
 		CodeReviewed:    labelInfoToInt(changeInfo.Labels["Code-Review"]),
+		Autosubmit:      labelInfoToInt(changeInfo.Labels["Autosubmit"]),
 		Submittable:     changeInfo.Submittable,
-		HashTags:        changeInfo.Hashtags,
 		CommitID:        changeInfo.CurrentRevision, // yes, this IS the commit ID.
 		ParentCommitIDs: getParentCommitIDs(changeInfo),
 		OwnerName:       changeInfo.Owner.Name,
@@ -41,15 +41,13 @@ func MakeChangeset(changeInfo *goGerrit.ChangeInfo) *Changeset {
 	}
 }
 
-// HasTag returns true if a Changeset has the given tag.
-func (c *Changeset) HasTag(tag string) bool {
-	hashTags := c.HashTags
-	for _, hashTag := range hashTags {
-		if hashTag == tag {
-			return true
-		}
-	}
-	return false
+// IsAutosubmit returns true if the changeset is intended to be
+// automatically submitted by gerrit-queue.
+//
+// This is determined by the Change Owner setting +1 on the
+// "Autosubmit" label.
+func (c *Changeset) IsAutosubmit() bool {
+	return c.Autosubmit == 1
 }
 
 // IsVerified returns true if the changeset passed CI,