From 6e0e92af7e68a970d4babae511bbc8340a1d80c2 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Tue, 9 Dec 2014 01:22:46 -0500 Subject: [PATCH] godoc/redirect: if id in /cl/{id} is less than 150k, treat as Gerrit CL id Change-Id: Id69c00d908d18151486007ec03da5495b34b05f5 Reviewed-on: https://go-review.googlesource.com/1223 Reviewed-by: Andrew Gerrand --- godoc/redirect/redirect.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/godoc/redirect/redirect.go b/godoc/redirect/redirect.go index 87dcca95d0..b58b962c92 100644 --- a/godoc/redirect/redirect.go +++ b/godoc/redirect/redirect.go @@ -10,6 +10,7 @@ package redirect import ( "net/http" "regexp" + "strconv" "strings" ) @@ -183,7 +184,9 @@ func clHandler(w http.ResponseWriter, r *http.Request) { return } target := "" - if strings.HasPrefix(id, "I") { + // the first CL in rietveld is about 152046, so if id is less than + // 150000, treat it as a Gerrit change id. + if n, _ := strconv.Atoi(id); strings.HasPrefix(id, "I") || n < 150000 { target = "https://go-review.googlesource.com/#/q/" + id } else { target = "https://codereview.appspot.com/" + id