From: "Jakub Narębski" <jnareb@gmail.com>
To: Krzesimir Nowak <krzesimir@endocode.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] gitweb: Add an option for adding more branch refs
Date: Wed, 27 Nov 2013 16:56:08 +0100 [thread overview]
Message-ID: <52961618.1070603@gmail.com> (raw)
In-Reply-To: <1385462243-7898-1-git-send-email-krzesimir@endocode.com>
Krzesimir Nowak wrote:
> Overriding an @additional_branch_refs configuration variable with
> value ('wip') will make gitweb to show branches that appear in
> refs/heads and refs/wip (refs/heads is hardcoded). Might be useful for
> gerrit setups where user branches are not stored under refs/heads/.
>
The description of this change starts with technical details,
instead of starting with intent of this change.
Perhaps (this is only a proposal)
Introduce @additional_branch_refs configuration variable, holding
names of references to be considered branches; by default empty.
For example setting it to ('wip') will make gitweb ...
BTW. I have thought at first that is something similar to 'remote_heads'
feature, which among others adds 'remotes' section to 'summary' view
displaying refs/remotes/* refs... but no, gitweb still doesn't treat
refs/remotes as branches, even with this feature set.
Nb. why new configuration variable, and not new %feature?
> Signed-off-by: Krzesimir Nowak <krzesimir@endocode.com>
> ---
> gitweb/gitweb.perl | 99 ++++++++++++++++++++++++++++++++++++++++--------------
> 1 file changed, 74 insertions(+), 25 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 68c77f6..9bfd38b 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -17,6 +17,7 @@ use Encode;
> use Fcntl ':mode';
> use File::Find qw();
> use File::Basename qw(basename);
> +use List::Util qw(min);
> use Time::HiRes qw(gettimeofday tv_interval);
> binmode STDOUT, ':utf8';
>
[...]
> @@ -3184,24 +3210,43 @@ sub git_get_project_owner {
> return $owner;
> }
>
> -sub git_get_last_activity {
> - my ($path) = @_;
> - my $fd;
> +sub git_get_last_activity_age {
> + my ($refs) = @_;
> + my $fd = -1;
>
> - $git_dir = "$projectroot/$path";
> open($fd, "-|", git_cmd(), 'for-each-ref',
> '--format=%(committer)',
> '--sort=-committerdate',
> '--count=1',
> - 'refs/heads') or return;
> + $refs) or return undef;
git-for-each-ref accepts more than one pattern. Why not simply
open($fd, "-|", git_cmd(), 'for-each-ref',
'--format=%(committer)',
'--sort=-committerdate',
'--count=1',
- 'refs/heads') or return;
+ get_branch_refs()) or return;
Then we won't need List::Util::min.
[...]
> +sub git_get_last_activity {
> + my ($path) = @_;
> + my @ages = ();
> +
> + $git_dir = "$projectroot/$path";
> + for my $ref (get_branch_refs()) {
> + my $age = git_get_last_activity_age('refs/' . $_);
> +
> + push @ages, $age if defined $age;
> + }
> + if (@ages) {
> + my $min_age = min(@ages);
> +
> + return ($min_age, age_string($min_age));
> + }
> +
> return (undef, undef);
> }
>
[...]
--
Jakub Narębski
next prev parent reply other threads:[~2013-11-27 15:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 10:37 [PATCH] gitweb: Add an option for adding more branch refs Krzesimir Nowak
2013-11-26 21:48 ` Junio C Hamano
2013-11-27 15:34 ` Krzesimir Nowak
2013-11-27 15:56 ` Jakub Narębski [this message]
2013-11-27 16:15 ` Krzesimir Nowak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52961618.1070603@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=krzesimir@endocode.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).