From 330b7067a0d63de38bc9e1cbf51306552c49f65e Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Wed, 18 Aug 2021 10:20:19 -0400 Subject: [PATCH] feat(besadii): Tag gerrit comments as autogenerated This is a bit of an under-documented feature, but if the "tag" field for a gerrit review starts with the string "autogenerated:~", only the last comment per instance of will be shown by default on the CL page (with the rest viewable by toggling the "Show all entries" switch). The idea behind the "" tag is to be used for the "type" of comment within a particular system - gerrit's documentation gives the example of one tag for "the build is running" and another for "the build has finished, here's the result". Change-Id: I9199a6ed97beca1b3a51ec5d6230c6c8358ba2b3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3374 Tested-by: BuildkiteCI Reviewed-by: tazjin --- ops/besadii/main.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 7972df74d..77c04099e 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -54,10 +54,10 @@ type Author struct { // Build is the representation of a Buildkite build as described on // https://buildkite.com/docs/apis/rest-api/builds#create-a-build type Build struct { - Commit string `json:"commit"` - Branch string `json:"branch"` - Author Author `json:"author"` - Env map[string]string `json:"env"` + Commit string `json:"commit"` + Branch string `json:"branch"` + Author Author `json:"author"` + Env map[string]string `json:"env"` } // Trigger a build of a given branch & commit on Buildkite @@ -70,9 +70,9 @@ func triggerBuild(log *syslog.Writer, token string, update *refUpdated) error { } build := Build{ - Commit: update.commit, - Branch: update.ref, - Env: env, + Commit: update.commit, + Branch: update.ref, + Env: env, Author: Author{ Name: update.submitter, Email: update.email, @@ -221,6 +221,7 @@ type reviewInput struct { Labels map[string]int `json:"labels"` OmitDuplicateComments bool `json:"omit_duplicate_comments"` IgnoreDefaultAttentionSetRules bool `json:"ignore_default_attention_set_rules"` + Tag string `json:"tag"` } func postCommandMain() { @@ -267,6 +268,8 @@ func postCommandMain() { // Update the attention set if we are failing this patchset. IgnoreDefaultAttentionSetRules: verified == 1, + + Tag: "autogenerated:buildkite~result", } body, _ := json.Marshal(review)