Luke Ross

Colorado

4 releases git clone https://lukeross.name/projects/colorado.git/

Web-based git repository viewer.

Commit ead31d4e575fa6ca89255496e1feecd88ca467cc

No need to show branch link if there's only one branch.

Committed 11 Jul 2017 by Luke Ross

src/colorado/views.py

@@ -66,12 +66,16 @@ def configure_template(tpl, repo=None):
 		run_on_meld(tpl, "repo-desc", lambda n: n.content(repo.description))
 		run_on_meld(tpl, "repo-clone", lambda n: n.content(repo.read_clone_url))
 		run_on_meld(tpl, "repo-issues", lambda n: n.deparent())  # FIXME
-		run_on_meld(tpl, "repo-branches", lambda n: (
-			n[0].content(str(len(git.heads))),
-			n.set("href", url_for(
-				".trees_view", slug=repo.slug
+		num_branches = len(git.heads)
+		if num_branches > 1:
+			run_on_meld(tpl, "repo-branches", lambda n: (
+				n[0].content(str(num_branches)),
+				n.set("href", url_for(
+					".trees_view", slug=repo.slug
+				))
 			))
-		))
+		else:
+			run_on_meld(tpl, "repo-branches", lambda n: n.deparent())
 		if git.tags:
 			run_on_meld(tpl, "repo-tags", lambda n: (
 				n[0].content(str(len(git.tags))),