From de309848eb49a13018a0f62195f9dc74801ef0ec Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Dec 2019 17:28:35 +0000 Subject: feat(cgit-taz): Patch cgit to construct monorepo URLs Effectively dropping /depot/ from all URLs. --- services/cgit-taz/cgit_depot_url.patch | 43 ++++++++++++++++++++++++++++++++++ services/cgit-taz/default.nix | 9 ++++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 services/cgit-taz/cgit_depot_url.patch diff --git a/services/cgit-taz/cgit_depot_url.patch b/services/cgit-taz/cgit_depot_url.patch new file mode 100644 index 0000000000..5ca2857371 --- /dev/null +++ b/services/cgit-taz/cgit_depot_url.patch @@ -0,0 +1,43 @@ +diff --git a/ui-shared.c b/ui-shared.c +index 739505a..5c3e7bc 100644 +--- a/ui-shared.c ++++ b/ui-shared.c +@@ -95,29 +95,23 @@ 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); ++ // my cgit instance *only* serves the depot, hence that's the only value ever ++ // needed. ++ return "/"; + } + + 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 = "&"; ++ strbuf_addf(&sb, "%s%s/%s", ctx.cfg.virtual_root, ++ pagename, (filename ? filename:"")); ++ ++ if (query) { ++ strbuf_addf(&sb, "%s%s", "?", query); + } +- if (query) +- strbuf_addf(&sb, "%s%s", delim, query); ++ + return strbuf_detach(&sb, NULL); + } + diff --git a/services/cgit-taz/default.nix b/services/cgit-taz/default.nix index e59d076a2a..79cf579ec1 100644 --- a/services/cgit-taz/default.nix +++ b/services/cgit-taz/default.nix @@ -22,9 +22,16 @@ let repo.owner=tazjin repo.clone-url=https://git.tazj.in ssh://source.developers.google.com:2022/p/tazjins-infrastructure/r/depot ''; + + # Patched version of cgit that builds repository URLs correctly + # (since only one repository is served) + monocgit = cgit.overrideAttrs(old: { + patches = old.patches ++ [ ./cgit_depot_url.patch ]; + }); + thttpdConfig = writeText "thttpd.conf" '' port=8080 - dir=${cgit}/cgit + dir=${monocgit}/cgit nochroot novhost logfile=/dev/stdout -- cgit 1.4.1