hackdoc: when redirecting, skip ref if default
Change-Id: Ie1680500ede673c407c9c8f4bbbe6b7f6a41b422
diff --git a/devtools/hackdoc/main.go b/devtools/hackdoc/main.go
index e460721..10fb65c 100644
--- a/devtools/hackdoc/main.go
+++ b/devtools/hackdoc/main.go
@@ -205,7 +205,15 @@
}
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 5004642..8923545 100644
--- a/devtools/hackdoc/markdown.go
+++ b/devtools/hackdoc/markdown.go
@@ -21,7 +21,7 @@
// 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 = ""
}