mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
godoc/redirect: update the rules for /cl/ redirect
If id is a number greater than 150k, then it is a Rietveld CL, otherwise treat it as a Gerrit change id. Also add support for /cl/ID/, because go commit 0edafefc36 uses this form. Change-Id: I46575e3284faaa727e346b34bbc46ab248cf12b3 Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/1283 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
parent
71d0144635
commit
4d81e11d78
@ -177,17 +177,19 @@ func clHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
id := r.URL.Path[len(prefix):]
|
||||
// support /cl/152700045/, which is used in commit 0edafefc36.
|
||||
id = strings.TrimSuffix(id, "/")
|
||||
if !validId.MatchString(id) {
|
||||
http.Error(w, "Not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
target := ""
|
||||
// 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 {
|
||||
// the first CL in rietveld is about 152046, so only treat the id as
|
||||
// a rietveld CL if it is larger than 150000.
|
||||
if n, err := strconv.Atoi(id); err == nil && n > 150000 {
|
||||
target = "https://codereview.appspot.com/" + id
|
||||
} else {
|
||||
target = "https://go-review.googlesource.com/r/" + id
|
||||
}
|
||||
http.Redirect(w, r, target, http.StatusFound)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user