about summary refs log tree commit diff
path: root/web/cgit-taz/0002-cgit_subtree_readmes.patch
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-21T23·36+0000
committerVincent Ambo <tazjin@google.com>2019-12-21T23·36+0000
commit9ad47965387c63e287afac86c498566e37265248 (patch)
treef263eb41f0e403a271983ae7067f05251e8b3c4a /web/cgit-taz/0002-cgit_subtree_readmes.patch
parent03acae2f85a1cda6057ab17549941c2ce16464ed (diff)
feat(cgit-taz): Add patches for subtree about/ handling r/289
1. Generate links to subtree about pages.
2. Render README files in subtrees, too.
Diffstat (limited to 'web/cgit-taz/0002-cgit_subtree_readmes.patch')
-rw-r--r--web/cgit-taz/0002-cgit_subtree_readmes.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/web/cgit-taz/0002-cgit_subtree_readmes.patch b/web/cgit-taz/0002-cgit_subtree_readmes.patch
new file mode 100644
index 000000000000..f3aba10215bc
--- /dev/null
+++ b/web/cgit-taz/0002-cgit_subtree_readmes.patch
@@ -0,0 +1,46 @@
+From 61500898c7d1363f88b763c7778cf1a8dfd13aca Mon Sep 17 00:00:00 2001
+From: Vincent Ambo <tazjin@google.com>
+Date: Sat, 21 Dec 2019 22:58:19 +0000
+Subject: [PATCH 2/3] feat(ui-summary): Attempt to use README at each subtree
+
+This means that individual subtrees of a repository will also have
+their READMEs rendered on the about page, for example:
+
+    /foo/bar/README.md
+
+Will render on:
+
+    /about/foo/bar/
+
+This is useful for monorepo setups in which subtrees represent
+individual projects.
+---
+ ui-summary.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/ui-summary.c b/ui-summary.c
+index 8e81ac4..34ce4e9 100644
+--- a/ui-summary.c
++++ b/ui-summary.c
+@@ -128,6 +128,18 @@ void cgit_print_repo_readme(char *path)
+ 			goto done;
+ 	}
+ 
++	/* Determine which file to serve by checking whether the given filename is
++	 * already a valid file and otherwise appending the expected file name of
++	 * the readme.
++	 *
++	 * If neither yield a valid file, the user gets a blank page. Could probably
++	 * do with an error message in between there, but whatever.
++	 */
++	if (path && ref && !cgit_ref_path_exists(filename, ref, 1)) {
++	  filename = fmtalloc("%s/%s", path, ctx.repo->readme.items[0].string);
++	  free_filename = 1;
++	}
++
+ 	/* Print the calculated readme, either from the git repo or from the
+ 	 * filesystem, while applying the about-filter.
+ 	 */
+-- 
+2.24.1.735.g03f4e72817-goog
+