From 21b76cb0238319c7fd58d7522fd42ca8c314ff8b Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 21 Feb 2020 22:57:34 +0000 Subject: feat(ops/besadii): Run 'git update-server-info' at startup Since besadii is effectively the entire post-receive hook, it also needs to do the entire job of the hook. --- ops/besadii/main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ops/besadii/main.go b/ops/besadii/main.go index 438dd91f5e8b..36e0b6e59fdd 100644 --- a/ops/besadii/main.go +++ b/ops/besadii/main.go @@ -17,9 +17,12 @@ import ( "log/syslog" "net/http" "os" + "os/exec" "strings" ) +var gitBin = "git" + // Represents an updated reference as passed to besadii by git // // https://git-scm.com/docs/githooks#pre-receive @@ -106,7 +109,7 @@ func triggerBuild(log *syslog.Writer, token, branch, commit string) { os.Exit(1) } - req.Header.Add("Authorization", "token " + token) + req.Header.Add("Authorization", "token "+token) req.Header.Add("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) @@ -159,6 +162,15 @@ func main() { os.Exit(1) } + // 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() + if err != nil { + log.Alert("failed to run 'git update-server-info' for depot!") + os.Exit() + } + token, err := ioutil.ReadFile("/etc/secrets/srht-token") if err != nil { log.Alert("sourcehot token could not be read") -- cgit 1.4.1