diff options
author | Vincent Ambo <tazjin@google.com> | 2020-02-21T22·57+0000 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-02-21T22·58+0000 |
commit | 21b76cb0238319c7fd58d7522fd42ca8c314ff8b (patch) | |
tree | f45e4de7e049ddd1554c2f7a8482327ea7d34415 /ops/besadii/main.go | |
parent | 8377fd48f51df43b2c2376b5be34d1d63e72185d (diff) |
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.
Diffstat (limited to 'ops/besadii/main.go')
-rw-r--r-- | ops/besadii/main.go | 14 |
1 files changed, 13 insertions, 1 deletions
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") |