website: serve latest git hash (for buildbots)

Change-Id: I5332e111609f0d9f957609a4dcee6030653397d4
This commit is contained in:
mpl 2013-10-23 16:56:57 +02:00
parent c16ada0121
commit 7d2b1d78e1
1 changed files with 19 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import (
"os"
"os/exec"
"strings"
"sync"
"time"
"camlistore.org/pkg/osutil"
@ -124,6 +125,11 @@ https://camlistore.googlesource.com/camlistore/+/%s
return wc.Close()
}
var latestHash struct {
sync.Mutex
s string // hash of the most recent camlistore revision
}
func commitEmailLoop() error {
http.HandleFunc("/mailnow", mailNowHandler)
@ -149,6 +155,10 @@ func commitEmailLoop() error {
for _, commit := range hashes {
knownCommit[commit] = true
}
latestHash.Lock()
latestHash.s = hashes[0]
latestHash.Unlock()
http.HandleFunc("/latesthash", latestHashHandler)
for {
pollCommits(dir)
@ -179,6 +189,9 @@ func pollCommits(dir string) {
log.Print(err)
return
}
latestHash.Lock()
latestHash.s = hashes[0]
latestHash.Unlock()
for _, commit := range hashes {
if knownCommit[commit] {
continue
@ -221,3 +234,9 @@ func mailNowHandler(w http.ResponseWriter, r *http.Request) {
default:
}
}
func latestHashHandler(w http.ResponseWriter, r *http.Request) {
latestHash.Lock()
defer latestHash.Unlock()
fmt.Fprint(w, latestHash.s)
}