From 29804a46212a98217555a91bada9e12d924a93ab Mon Sep 17 00:00:00 2001 From: Nikolay Shaplov Date: Sun, 7 Jun 2026 16:23:56 +0000 Subject: [PATCH] =?utf8?q?cgi-=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20?= =?utf8?q?=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D1=8E=D1=89?= =?utf8?q?=D0=B8=D0=B9=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20=D0=B2?= =?utf8?q?=D0=B5=D1=82=D0=BE=D0=BA=20=D0=B2=20=D1=80=D0=B5=D0=BF=D0=BE?= =?utf8?q?=D0=B7=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- cgi/git4ai-branches.pl | 48 ++++++++++++++++++++++++++++++++++++++++++ conf/nginx/git4ai | 6 ++++++ 2 files changed, 54 insertions(+) create mode 100755 cgi/git4ai-branches.pl diff --git a/cgi/git4ai-branches.pl b/cgi/git4ai-branches.pl new file mode 100755 index 0000000..c81f4d3 --- /dev/null +++ b/cgi/git4ai-branches.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl +use strict; +use warnings; + +my $GIT_ROOT = '/var/lib/git'; +my $BASE_URL = 'https://gitweb.nataraj.world'; + +my $repo = $ENV{GIT_REPO}; + +$repo =~ s{[^a-zA-Z0-9._-]}{}g; + +die unless $repo; + +my $git_dir = "$GIT_ROOT/$repo"; + +print "Content-Type: text/html; charset=utf-8\r\n"; +print "Cache-Control: no-store, no-cache, must-revalidate\r\n"; +print "\r\n"; + +open(my $fh, '-|', 'git', "--git-dir=$git_dir", 'for-each-ref', + '--format=%(refname:short)', + 'refs/heads/') + or die "git failed: $!"; + +my @branches; +while (<$fh>) { + chomp; + push @branches, $_; +} +close($fh); + +print < + + +git branches: $repo + + +

git branches: $repo

+\n\n"; diff --git a/conf/nginx/git4ai b/conf/nginx/git4ai index 57832aa..c105b5c 100644 --- a/conf/nginx/git4ai +++ b/conf/nginx/git4ai @@ -4,6 +4,7 @@ map $uri $git4ai_script { ~^/git4ai-cat-file/ /srv/cgi/git4ai-cat-file.pl; ~^/git4ai-log/ /srv/cgi/git4ai-log.pl; ~^/git4ai-ls-tree/ /srv/cgi/git4ai-ls-tree.pl; + ~^/git4ai-branches/ /srv/cgi/git4ai-branches.pl; ~^/git4ai/ /srv/cgi/git4ai.pl; } @@ -80,6 +81,11 @@ location ~ "^/git4ai-ls-tree/([^/]+)/([^/]+)/([^/]+)$" { add_header Cache-Control "no-store" always; } +location ~ "^/git4ai-branches/([^/]+)$" { + return 302 https://gitweb.nataraj.world/git4ai-branches/$1/-/-/-/$request_id; + add_header Cache-Control "no-store" always; +} + # repo branch id offset nonce location ~ "^/git4ai[^/]*/([a-zA-Z0-9._-]+)/([a-zA-Z0-9._-]+|-)/([0-9a-f]{4,40}|-)/([0-9]+|-)(?:/([a-zA-Z0-9]+))?$" { set $git_repo $1; -- 2.47.3