mirror of https://github.com/perkeep/perkeep.git
website: serve latest git hash (for buildbots)
Change-Id: I5332e111609f0d9f957609a4dcee6030653397d4
This commit is contained in:
parent
c16ada0121
commit
7d2b1d78e1
|
@ -26,6 +26,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"camlistore.org/pkg/osutil"
|
"camlistore.org/pkg/osutil"
|
||||||
|
@ -124,6 +125,11 @@ https://camlistore.googlesource.com/camlistore/+/%s
|
||||||
return wc.Close()
|
return wc.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var latestHash struct {
|
||||||
|
sync.Mutex
|
||||||
|
s string // hash of the most recent camlistore revision
|
||||||
|
}
|
||||||
|
|
||||||
func commitEmailLoop() error {
|
func commitEmailLoop() error {
|
||||||
http.HandleFunc("/mailnow", mailNowHandler)
|
http.HandleFunc("/mailnow", mailNowHandler)
|
||||||
|
|
||||||
|
@ -149,6 +155,10 @@ func commitEmailLoop() error {
|
||||||
for _, commit := range hashes {
|
for _, commit := range hashes {
|
||||||
knownCommit[commit] = true
|
knownCommit[commit] = true
|
||||||
}
|
}
|
||||||
|
latestHash.Lock()
|
||||||
|
latestHash.s = hashes[0]
|
||||||
|
latestHash.Unlock()
|
||||||
|
http.HandleFunc("/latesthash", latestHashHandler)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
pollCommits(dir)
|
pollCommits(dir)
|
||||||
|
@ -179,6 +189,9 @@ func pollCommits(dir string) {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
latestHash.Lock()
|
||||||
|
latestHash.s = hashes[0]
|
||||||
|
latestHash.Unlock()
|
||||||
for _, commit := range hashes {
|
for _, commit := range hashes {
|
||||||
if knownCommit[commit] {
|
if knownCommit[commit] {
|
||||||
continue
|
continue
|
||||||
|
@ -221,3 +234,9 @@ func mailNowHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func latestHashHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
latestHash.Lock()
|
||||||
|
defer latestHash.Unlock()
|
||||||
|
fmt.Fprint(w, latestHash.s)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue