about summary refs log tree commit diff
path: root/ops/besadii/main.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-02-21T23·01+0000
committerVincent Ambo <tazjin@google.com>2020-02-21T23·06+0000
commitc689df0dc721b766dfc4c0820238646a9e3fe815 (patch)
tree7d4d6e7d003cf244386c76c9565dc2e6974144df /ops/besadii/main.go
parent21b76cb0238319c7fd58d7522fd42ca8c314ff8b (diff)
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.
Diffstat (limited to 'ops/besadii/main.go')
-rw-r--r--ops/besadii/main.go12
1 files changed, 7 insertions, 5 deletions
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")