[PATCH] gitweb: Support for custom per-project owner string

Subsystems: the rest

DORMANTno replies

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] gitweb: Support for custom per-project owner string

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:41

This adds very simple support for per-project setting of the owner string
(in an environment where the actual owners won't have access to the
repositories accessed by gitweb, so faking identity is not an issue).

There should be an option to disable this, but this is just a patch
that someone might like (and/or pick up and polish), not intended for
inclusion as it is.

Also, ideally this would be in the configfile but calling repoconfig for
each repository in the index would slow things down way too much.

Signed-off-by: Petr Baudis <redacted>
---

 gitweb/gitweb.perl |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7ecd7df..d50bae5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -818,6 +818,13 @@ sub git_get_project_owner {
 		}
 		close $fd;
 	}
+	if (!defined $owner and -f "$projectroot/$project/owner") {
+		if (open my $fd, "$projectroot/$project/owner") {
+			$owner = <$fd>;
+			chomp $owner;
+			close $fd;
+		}
+	}
 	if (!defined $owner) {
 		$owner = get_file_owner("$projectroot/$project");
 	}
@@ -2186,7 +2193,7 @@ sub git_project_list {
 			$pr->{'descr'} = chop_str($descr, 25, 5);
 		}
 		if (!defined $pr->{'owner'}) {
-			$pr->{'owner'} = get_file_owner("$projectroot/$pr->{'path'}") || "";
+			$pr->{'owner'} = git_get_project_owner($pr->{'path'}) || "";
 		}
 		push @projects, $pr;
 	}
@@ -2275,7 +2282,7 @@ sub git_project_index {
 
 	foreach my $pr (@projects) {
 		if (!exists $pr->{'owner'}) {
-			$pr->{'owner'} = get_file_owner("$projectroot/$project");
+			$pr->{'owner'} = git_get_project_owner($project);
 		}
 
 		my ($path, $owner) = ($pr->{'path'}, $pr->{'owner'});

Re: [PATCH] gitweb: Support for custom per-project owner string

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:41

Petr Baudis wrote:
This adds very simple support for per-project setting of the owner string
(in an environment where the actual owners won't have access to the
repositories accessed by gitweb, so faking identity is not an issue).
Is it really needed? If $projects_list is a _file_, you can set correct
ownership information there.

Now $projects_list being a directory (usually $projectroot) support
hierarchy of repositories; generating appropriate projects' index file
is as easy as unsetting $projects_list (so it is by default set to
$projectroot), going to summary view, clicking [TXT] link on the left of
[OPML] link at the bottom, copy the result to projects' index file, correct
ownership information (and perhaps remove some projects), and set
$projects_list to this file.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

Re: [PATCH] gitweb: Support for custom per-project owner string

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:41

Dear diary, on Wed, Sep 20, 2006 at 01:04:50AM CEST, I got a letter
where Jakub Narebski [off-list ref] said that...
Petr Baudis wrote:
quoted
This adds very simple support for per-project setting of the owner string
(in an environment where the actual owners won't have access to the
repositories accessed by gitweb, so faking identity is not an issue).
Is it really needed? If $projects_list is a _file_, you can set correct
ownership information there.

Now $projects_list being a directory (usually $projectroot) support
hierarchy of repositories; generating appropriate projects' index file
is as easy as unsetting $projects_list (so it is by default set to
$projectroot), going to summary view, clicking [TXT] link on the left of
[OPML] link at the bottom, copy the result to projects' index file, correct
ownership information (and perhaps remove some projects), and set
$projects_list to this file.
Which is not really easy at all. I would have to do some ugly script to
autogenerate the text file while this way I can just throw the data to
the hierarchy and having everything still working magically.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help