mirror of https://github.com/perkeep/perkeep.git
camweb,buildbot: Update camlistore git repo URLs.
Also add redirect for /code/ request with a commit hash to new code host. Change-Id: I68a8746dacb6f0a4fc6719e3f5ed23ee0f37778b
This commit is contained in:
parent
b0d2a8f0e5
commit
502aff1fd5
|
@ -1064,7 +1064,7 @@ func goRepoURL(hash string) string {
|
|||
}
|
||||
|
||||
func camliRepoURL(hash string) string {
|
||||
return "http://camlistore.org/code/?p=camlistore.git;a=commit;h=" + hash
|
||||
return "https://camlistore.googlesource.com/camlistore/+/" + hash
|
||||
}
|
||||
|
||||
// style inspired from $GOROOT/misc/dashboard/app/build/ui.html
|
||||
|
|
|
@ -170,15 +170,26 @@ func serveError(w http.ResponseWriter, r *http.Request, relpath string, err erro
|
|||
servePage(w, "File "+relpath, "", contents)
|
||||
}
|
||||
|
||||
var commitHash = regexp.MustCompile(`^p=camlistore.git;a=commit;h=([0-9a-f]+)$`)
|
||||
|
||||
func mainHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
relPath := req.URL.Path[1:] // serveFile URL paths start with '/'
|
||||
if strings.Contains(relPath, "..") {
|
||||
return
|
||||
}
|
||||
|
||||
// Example:
|
||||
// /code/?p=camlistore.git;a=commit;h=b0d2a8f0e5f27bbfc025a96ec3c7896b42d198ed
|
||||
if strings.HasPrefix(relPath, "code/") {
|
||||
m := commitHash.FindStringSubmatch(req.URL.RawQuery)
|
||||
if len(m) == 2 {
|
||||
http.Redirect(rw, req, "https://camlistore.googlesource.com/camlistore/+/"+m[1], http.StatusFound)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasPrefix(relPath, "gw/") {
|
||||
path := relPath[3:]
|
||||
http.Redirect(rw, req, "http://camlistore.org/code/?p=camlistore.git;f="+path+";hb=master", http.StatusFound)
|
||||
http.Redirect(rw, req, "https://camlistore.googlesource.com/camlistore/+/HEAD/"+path, http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue