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:<something>~<something-else>", only the last comment per
instance of <something> will be shown by default on the CL page (with
the rest viewable by toggling the "Show all entries" switch). The idea
behind the "<something-else>" 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 <mail@tazj.in>
This commit is contained in:
Griffin Smith 2021-08-18 10:20:19 -04:00 committed by grfn
parent 77be4dfe37
commit 330b7067a0

View file

@ -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)