summary refs log tree commit diff
path: root/fleet/hosts/trieste/cgit/monorepo-support.patch
diff options
context:
space:
mode:
Diffstat (limited to 'fleet/hosts/trieste/cgit/monorepo-support.patch')
-rw-r--r--fleet/hosts/trieste/cgit/monorepo-support.patch153
1 files changed, 153 insertions, 0 deletions
diff --git a/fleet/hosts/trieste/cgit/monorepo-support.patch b/fleet/hosts/trieste/cgit/monorepo-support.patch
new file mode 100644
index 0000000..f634d9c
--- /dev/null
+++ b/fleet/hosts/trieste/cgit/monorepo-support.patch
@@ -0,0 +1,153 @@
+SPDX-FileCopyrightText: V <v@unfathomable.blue>
+SPDX-License-Identifier: OSL-3.0
+diff --git a/cgit.c b/cgit.c
+index dd28a79..1426a72 100644
+--- a/cgit.c
++++ b/cgit.c
+@@ -603,7 +603,7 @@ static int prepare_repo_cmd(int nongit)
+ 		cgit_print_docend();
+ 		return 1;
+ 	}
+-	ctx.page.title = fmtalloc("%s - %s", ctx.repo->name, ctx.repo->desc);
++	ctx.page.title = ctx.cfg.root_title;
+ 
+ 	if (!ctx.repo->defbranch)
+ 		ctx.repo->defbranch = guess_defbranch();
+diff --git a/ui-shared.c b/ui-shared.c
+index 72a1505..d798d99 100644
+--- a/ui-shared.c
++++ b/ui-shared.c
+@@ -129,29 +129,17 @@ const char *cgit_loginurl(void)
+ 
+ char *cgit_repourl(const char *reponame)
+ {
+-	if (ctx.cfg.virtual_root)
+-		return fmtalloc("%s%s/", ctx.cfg.virtual_root, reponame);
+-	else
+-		return fmtalloc("?r=%s", reponame);
++	return fmtalloc("%s/", ctx.cfg.virtual_root);
+ }
+ 
+ char *cgit_fileurl(const char *reponame, const char *pagename,
+ 		   const char *filename, const char *query)
+ {
+ 	struct strbuf sb = STRBUF_INIT;
+-	char *delim;
+-
+-	if (ctx.cfg.virtual_root) {
+-		strbuf_addf(&sb, "%s%s/%s/%s", ctx.cfg.virtual_root, reponame,
+-			    pagename, (filename ? filename:""));
+-		delim = "?";
+-	} else {
+-		strbuf_addf(&sb, "?url=%s/%s/%s", reponame, pagename,
+-			    (filename ? filename : ""));
+-		delim = "&amp;";
+-	}
++	strbuf_addf(&sb, "%s/%s/%s", ctx.cfg.virtual_root,
++		    pagename, (filename ? filename:""));
+ 	if (query)
+-		strbuf_addf(&sb, "%s%s", delim, query);
++		strbuf_addf(&sb, "?%s", query);
+ 	return strbuf_detach(&sb, NULL);
+ }
+ 
+@@ -277,30 +265,12 @@ static char *repolink(const char *title, const char *class, const char *page,
+ 		html("'");
+ 	}
+ 	html(" href='");
+-	if (ctx.cfg.virtual_root) {
+-		html_url_path(ctx.cfg.virtual_root);
+-		html_url_path(ctx.repo->url);
+-		if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/')
+-			html("/");
+-		if (page) {
+-			html_url_path(page);
+-			html("/");
+-			if (path)
+-				html_url_path(path);
+-		}
+-	} else {
+-		html_url_path(ctx.cfg.script_name);
+-		html("?url=");
+-		html_url_arg(ctx.repo->url);
+-		if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/')
+-			html("/");
+-		if (page) {
+-			html_url_arg(page);
+-			html("/");
+-			if (path)
+-				html_url_arg(path);
+-		}
+-		delim = "&amp;";
++	html_url_path(ctx.cfg.virtual_root);
++	if (page) {
++		html_url_path(page);
++		html("/");
++		if (path)
++			html_url_path(path);
+ 	}
+ 	if (head && ctx.repo->defbranch && strcmp(head, ctx.repo->defbranch)) {
+ 		html(delim);
+@@ -1001,44 +971,27 @@ static void print_header(void)
+ 	}
+ 
+ 	html("<td class='main'>");
+-	if (ctx.repo) {
+-		cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1);
+-		html(" : ");
+-		cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
+-		if (ctx.env.authenticated) {
+-			html("</td><td class='form'>");
+-			html("<form method='get'>\n");
+-			cgit_add_hidden_formfields(0, 1, ctx.qry.page);
+-			html("<select name='h' onchange='this.form.submit();'>\n");
+-			print_this_commit_option();
+-			html("<optgroup label='branches'>");
+-			for_each_branch_ref(print_branch_option, ctx.qry.head);
+-			if (ctx.repo->enable_remote_branches)
+-				for_each_remote_ref(print_branch_option, ctx.qry.head);
+-			html("</optgroup>");
+-			html("</select> ");
+-			html("<input type='submit' value='switch'/>");
+-			html("</form>");
+-		}
+-	} else
+-		html_txt(ctx.cfg.root_title);
++	cgit_index_link(ctx.cfg.root_title, NULL, NULL, NULL, NULL, 0, 1);
++	if (ctx.env.authenticated) {
++		html("</td><td class='form'>");
++		html("<form method='get'>\n");
++		cgit_add_hidden_formfields(0, 1, ctx.qry.page);
++		html("<select name='h' onchange='this.form.submit();'>\n");
++		print_this_commit_option();
++		html("<optgroup label='branches'>");
++		for_each_branch_ref(print_branch_option, ctx.qry.head);
++		if (ctx.repo->enable_remote_branches)
++			for_each_remote_ref(print_branch_option, ctx.qry.head);
++		html("</optgroup>");
++		html("</select> ");
++		html("<input type='submit' value='switch'/>");
++		html("</form>");
++	}
+ 	html("</td></tr>\n");
+ 
+ 	html("<tr><td class='sub'>");
+-	if (ctx.repo) {
+-		html_txt(ctx.repo->desc);
+-		html("</td><td class='sub right'>");
+-		if (ctx.repo->owner_filter) {
+-			cgit_open_filter(ctx.repo->owner_filter);
+-			html_txt(ctx.repo->owner);
+-			cgit_close_filter(ctx.repo->owner_filter);
+-		} else {
+-			html_txt(ctx.repo->owner);
+-		}
+-	} else {
+-		if (ctx.cfg.root_desc)
+-			html_txt(ctx.cfg.root_desc);
+-	}
++	if (ctx.cfg.root_desc)
++		html_txt(ctx.cfg.root_desc);
+ 	html("</td></tr></table>\n");
+ }
+