From 502aff1fd522c454e39a3723b596aca43d206d4e Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 18 Aug 2013 08:08:18 -0700 Subject: [PATCH] camweb,buildbot: Update camlistore git repo URLs. Also add redirect for /code/ request with a commit hash to new code host. Change-Id: I68a8746dacb6f0a4fc6719e3f5ed23ee0f37778b --- misc/buildbot/bot.go | 2 +- website/camweb.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/misc/buildbot/bot.go b/misc/buildbot/bot.go index 80d38e26b..bbfb05791 100644 --- a/misc/buildbot/bot.go +++ b/misc/buildbot/bot.go @@ -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 diff --git a/website/camweb.go b/website/camweb.go index b1a4acde7..2aedac3d5 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -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 }