From 81262ff2028746c176b83670bb646def52b02c95 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Sat, 6 Mar 2021 20:44:56 +0000 Subject: [PATCH] hackdoc: when redirecting, skip ref if default Change-Id: Ie1680500ede673c407c9c8f4bbbe6b7f6a41b422 --- devtools/hackdoc/main.go | 10 +++++++++- devtools/hackdoc/markdown.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/devtools/hackdoc/main.go b/devtools/hackdoc/main.go index e460721a..10fb65c7 100644 --- a/devtools/hackdoc/main.go +++ b/devtools/hackdoc/main.go @@ -205,7 +205,15 @@ func (r *request) handlePageAuto(dirpath string) { } if file { - http.Redirect(r.w, r.r, "/"+fpath+"?ref="+r.ref, 302) + ref := r.ref + if ref == flagGitwebDefaultBranch { + ref = "" + } + path := "/" + fpath + if ref != "" { + path += "?ref=" + ref + } + http.Redirect(r.w, r.r, path, 302) return } } diff --git a/devtools/hackdoc/markdown.go b/devtools/hackdoc/markdown.go index 50046422..89235452 100644 --- a/devtools/hackdoc/markdown.go +++ b/devtools/hackdoc/markdown.go @@ -21,7 +21,7 @@ func renderMarkdown(input []byte, ref string) []byte { // master is the default branch - do not make special links for that, as // that makes them kinda ugly. - if ref == "master" { + if ref == flagGitwebDefaultBranch { ref = "" }