patches: main as default branch, go gettable

Derek Stevens nilix at nilfm.cc
Sat Jan 8 22:28:00 UTC 2022


Hello CGit folk!

I use cgit for my own git server and have made some minor modifications that might be of interest.

The first is the trivial change to assume main as the default branch name, as this is the new standard in git.

The second and more interesting is to add a <meta> attribute to make a repository go-gettable.

Both patches are attached; Happy new year and happy hacking!

Cheers,
Derek
-------------- next part --------------
diff --git a/ui-shared.c b/ui-shared.c
index acd8ab5..49a9407 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -785,6 +785,10 @@ void cgit_print_docstart(void)
 	html_txt(ctx.page.title);
 	html("</title>\n");
 	htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
+	if (ctx.repo){
+	  htmlf("<meta name='go-import' content='%s%s%s git https://%s%s%s'/>\n",
+	    host, cgit_rooturl(), ctx.repo->url, host, cgit_rooturl(), ctx.repo->url);
+	}
 	if (ctx.cfg.robots && *ctx.cfg.robots)
 		htmlf("<meta name='robots' content='%s'/>\n", ctx.cfg.robots);
 	html("<link rel='stylesheet' type='text/css' href='");
-------------- next part --------------
diff --git a/ui-repolist.c b/ui-repolist.c
index 529a203..c162290 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -53,7 +53,7 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
 
 	strbuf_reset(&path);
 	strbuf_addf(&path, "%s/refs/heads/%s", repo->path,
-		    repo->defbranch ? repo->defbranch : "master");
+		    repo->defbranch ? repo->defbranch : "main");
 	if (stat(path.buf, &s) == 0) {
 		*mtime = s.st_mtime;
 		r->mtime = *mtime;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20220108/1226ea0d/attachment.sig>


More information about the CGit mailing list