From c689df0dc721b766dfc4c0820238646a9e3fe815 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 21 Feb 2020 23:01:42 +0000 Subject: fix(ops/besadii): Replace slashes in branch names Submitting a build with a branch containing a slash (which is common for my branches) returns this error: Invalid tag name, tags must use lowercase alphanumeric characters, underscores, dashes, or dots This commit replaces all slashes with underscores to work around that. --- ops/besadii/main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ops/besadii/main.go') diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 36e0b6e59f..0241eb8449 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -96,7 +96,9 @@ func triggerBuild(log *syslog.Writer, token, branch, commit string) { Manifest: prepareManifest(commit), Note: fmt.Sprintf("Build of 'master' at '%s'", commit), Tags: []string{ - "depot", branch, + // my branch names tend to contain slashes, which are not valid + // identifiers in sourcehut. + "depot", strings.ReplaceAll(branch, "/", "_"), }, } @@ -122,8 +124,8 @@ func triggerBuild(log *syslog.Writer, token, branch, commit string) { defer resp.Body.Close() if resp.StatusCode != 200 { - respBody, err := ioutil.ReadAll(resp.Body) - log.Err(fmt.Sprintf("received non-success response from builds.sr.ht: %s (%v)[%s]", respBody, resp.Status, err)) + respBody, _ := ioutil.ReadAll(resp.Body) + log.Err(fmt.Sprintf("received non-success response from builds.sr.ht: %s (%v)", respBody, resp.Status)) } else { fmt.Fprintf(log, "triggered builds.sr.ht job for branch '%s' at commit '%s'", branch, commit) } @@ -165,10 +167,10 @@ func main() { // Before triggering builds, it is important that git // update-server-info is run so that cgit correctly serves the // repository. - err := exec.Command(gitBin, "update-server-info").Run() + err = exec.Command(gitBin, "update-server-info").Run() if err != nil { log.Alert("failed to run 'git update-server-info' for depot!") - os.Exit() + os.Exit(1) } token, err := ioutil.ReadFile("/etc/secrets/srht-token") -- cgit 1.4.1