From a2407ec89735f6915359c25bf4536053b9c61d70 Mon Sep 17 00:00:00 2001 From: mpl Date: Fri, 11 Oct 2013 18:33:43 +0200 Subject: [PATCH] website: vars cleanup&renaming Change-Id: Iaf3784e26d4a2fbe403f8fcafb482779c16dbe77 --- website/camweb.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/camweb.go b/website/camweb.go index 3b4340bb0..44362aa92 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -48,8 +48,6 @@ var ( logStdout = flag.Bool("logstdout", true, "Write to stdout?") tlsCertFile = flag.String("tlscert", "", "TLS cert file") tlsKeyFile = flag.String("tlskey", "", "TLS private key file") - gerritUser = flag.String("gerrituser", "ubuntu", "Gerrit host's username") - gerritHost = flag.String("gerrithost", "", "Gerrit host, or empty.") buildbotBackend = flag.String("buildbot_backend", "", "Build bot status backend URL") buildbotHost = flag.String("buildbot_host", "", "Hostname to map to the buildbot_backend. If an HTTP request with this hostname is received, it proxies to buildbot_backend.") alsoRun = flag.String("also_run", "", "Optional path to run as a child process. (Used to run camlistore.org's ./scripts/run-blob-server)") @@ -169,6 +167,8 @@ func serveError(w http.ResponseWriter, r *http.Request, relpath string, err erro servePage(w, "File "+relpath, "", contents) } +const gerritURLPrefix = "https://camlistore.googlesource.com/camlistore/+/" + var commitHash = regexp.MustCompile(`^p=camlistore.git;a=commit;h=([0-9a-f]+)$`) // empty return value means don't redirect. @@ -178,17 +178,17 @@ func redirectPath(u *url.URL) string { if strings.HasPrefix(u.Path, "/code/") { m := commitHash.FindStringSubmatch(u.RawQuery) if len(m) == 2 { - return "https://camlistore.googlesource.com/camlistore/+/" + m[1] + return gerritURLPrefix + m[1] } } if strings.HasPrefix(u.Path, "/gw/") { path := strings.TrimPrefix(u.Path, "/gw/") if strings.HasPrefix(path, "doc") || strings.HasPrefix(path, "clients") { - return "https://camlistore.googlesource.com/camlistore/+/master/" + path + return gerritURLPrefix + "master/" + path } // Assume it's a commit - return "https://camlistore.googlesource.com/camlistore/+/" + path + return gerritURLPrefix + path } return "" }