Luke Ross

Colorado

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

Web-based git repository viewer.

Commit a28b3b43642f0af45a317abfbdef29de7f77fff0

Basic fork support

Committed 26 Jul 2018 by Luke Ross

colorado/repo.py

@@ -25,6 +25,8 @@ class Repo(Base):
 	description = Column(Unicode)
 	master = Column(Unicode, default="master")
 	read_clone_url = Column(String)
+	forked_from_git = Column(String, nullable=True)
+	forked_from_http = Column(String, nullable=True)
 
 	@property
 	def repo(self):


colorado/templates/repo-home.xml

@@ -2,6 +2,8 @@
 <div xmlns="http://www.w3.org/1999/xhtml" xmlns:meld="http://www.plope.com/software/meld3" meld:id="container">
 <h2><a href="#" meld:id="repo-name">Repository</a></h2>
 
+<p class="tidbit" meld:id="forked">forked from <a meld:id="forked-url" href="#">git://example.com</a></p>
+
 <div meld:id="toolbar" id="toolbar">
 <a href="#" meld:id="repo-branches"><span>2</span> branches</a>
 <a href="#" meld:id="repo-tags"><span>5</span> releases</a>


colorado/views.py

@@ -84,6 +84,7 @@ def configure_template(tpl, repo=None):
 			))
 		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))),
@@ -93,6 +94,18 @@ def configure_template(tpl, repo=None):
 			))
 		else:
 			run_on_meld(tpl, "repo-tags", lambda n: n.deparent())
+
+		if len(tpl.findmeld("forked")):
+			if repo.forked_from_git:
+				if repo.forked_from_http:
+					tpl.findmeld("forked-url").set("href", repo.forked_from_http)
+				else:
+					tpl.findmeld("forked-url").tag = "tt"
+					tpl.findmeld("forked-url").attrib.pop("href")
+				tpl.findmeld("forked-url").text = repo.forked_from_git
+			else:
+				tpl.findmeld("forked").deparent()
+
 	run_on_meld(tpl, "page-title", lambda n: n.set(
 		"href",
 		current_app.config.get('COLORADO_HREF', None) or