fix(ops/besadii): Unquote Gerrit's extra-quotes around emails

Gerrit wraps RFC5322 emails in another layer of quotes when passing
them as flags, and this needs to be unquoted.

Otherwise hook invocations fail with cryptic errors.

Change-Id: Ieeb74c662873d99a4154f8cbc92da77b039cb88e
This commit is contained in:
Vincent Ambo 2021-12-06 20:03:11 +03:00 committed by tazjin
parent 6faf0edaff
commit 8a944484f0

View file

@ -297,6 +297,12 @@ func ignoreFlags(ignore []string) {
// Extract the username & email from Gerrit's uploader flag and set it
// on the trigger struct, for display in Buildkite.
func extractChangeUploader(uploader string, trigger *buildTrigger) error {
// Gerrit passes the uploader in another extra layer of quotes.
uploader, err := strconv.Unquote(uploader)
if err != nil {
return fmt.Errorf("failed to unquote email - forgot quotes on manual invocation?: %w", err)
}
// Extract the uploader username & email from the input passed by
// Gerrit (in RFC 5322 format).
addr, err := mail.ParseAddress(uploader)