List for cgit developers and users
 help / color / mirror / Atom feed
* patches: main as default branch, go gettable
@ 2022-01-08 22:28 Derek Stevens
       [not found] ` <CAH-DoZ74FOrn=H0A1EtoEj+f_z7UoRXL2Rq4+GcvEosPoQXrBQ@mail.gmail.com>
  2022-01-09 16:13 ` Reto
  0 siblings, 2 replies; 3+ messages in thread
From: Derek Stevens @ 2022-01-08 22:28 UTC (permalink / raw)
  To: cgit


[-- Attachment #1.1: Type: text/plain, Size: 402 bytes --]

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

[-- Attachment #1.2: go_gettable.diff --]
[-- Type: text/plain, Size: 620 bytes --]

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='");

[-- Attachment #1.3: main_branch.diff --]
[-- Type: text/plain, Size: 480 bytes --]

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;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patches: main as default branch, go gettable
       [not found] ` <CAH-DoZ74FOrn=H0A1EtoEj+f_z7UoRXL2Rq4+GcvEosPoQXrBQ@mail.gmail.com>
@ 2022-01-09  0:00   ` Derek Stevens
  0 siblings, 0 replies; 3+ messages in thread
From: Derek Stevens @ 2022-01-09  0:00 UTC (permalink / raw)
  To: Jamie Couture; +Cc: cgit

[-- Attachment #1: Type: text/plain, Size: 1587 bytes --]

Thanks Jamie, I just sent them using that method.

As for the default branch name, I agree that using the default branch of the git-config and per-repo overrides would be preferrable, but I just changed the hardcoded fallback from "master" to "main" in case nothing else was found. I could probably do some legwork in the future to try and get it pulled from the actual git config as well...

Cheers!
Derek

------original message------
From: Jamie Couture <jamie.couture@gmail.com>
Date: Sat, Jan 08, 2022 at 03:46:33PM MST

>Hi Derek,
>
>Can you retry sending these using git send-email?  Don't forget to add your
>sign-off to the commit log as well.
>
>https://git-scm.com/docs/git-send-email
>
>
>As for the default branch change, I suspect people may want this feature
>configurable based on their configuration. I'm thinking either derived from
>your git config file or granularly via an override in the repo-list
>configuration file.  Ideally, obtain the default branch name from config of
>each repo.
>
>
>Thanks,
>
>On Sat, Jan 8, 2022 at 5:28 PM Derek Stevens <nilix@nilfm.cc> wrote:
>
>> 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
>>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patches: main as default branch, go gettable
  2022-01-08 22:28 patches: main as default branch, go gettable Derek Stevens
       [not found] ` <CAH-DoZ74FOrn=H0A1EtoEj+f_z7UoRXL2Rq4+GcvEosPoQXrBQ@mail.gmail.com>
@ 2022-01-09 16:13 ` Reto
  1 sibling, 0 replies; 3+ messages in thread
From: Reto @ 2022-01-09 16:13 UTC (permalink / raw)
  To: Derek Stevens; +Cc: cgit

On Sat, Jan 08, 2022 at 03:28:00PM -0700, Derek Stevens wrote:
> The first is the trivial change to assume main as the default branch name, as this is the new standard in git.

It's really not. Refer to my other mail for details.
Some hosting sites changed the defaults, yes. However each repo admin
can do whatever they please as far as git is concerned.

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

That only makes sense for go repos, you are unconditionally doing that.
While that's probably fine as a local hack it certainly doesn't seem
valid for all of the cgit users.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-09 16:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 22:28 patches: main as default branch, go gettable Derek Stevens
     [not found] ` <CAH-DoZ74FOrn=H0A1EtoEj+f_z7UoRXL2Rq4+GcvEosPoQXrBQ@mail.gmail.com>
2022-01-09  0:00   ` Derek Stevens
2022-01-09 16:13 ` Reto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).