Merge branch 'gb/gitweb-feature'
* gb/gitweb-feature: gitweb: make gitweb_check_feature a boolean wrapper gitweb: rename gitweb_check_feature to gitweb_get_feature gitweb: fix 'ctags' feature check and othersmaint
commit
dcbe0bd0d4
|
@ -329,7 +329,7 @@ our %feature = (
|
||||||
'default' => [0]},
|
'default' => [0]},
|
||||||
);
|
);
|
||||||
|
|
||||||
sub gitweb_check_feature {
|
sub gitweb_get_feature {
|
||||||
my ($name) = @_;
|
my ($name) = @_;
|
||||||
return unless exists $feature{$name};
|
return unless exists $feature{$name};
|
||||||
my ($sub, $override, @defaults) = (
|
my ($sub, $override, @defaults) = (
|
||||||
|
@ -344,6 +344,22 @@ sub gitweb_check_feature {
|
||||||
return $sub->(@defaults);
|
return $sub->(@defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# A wrapper to check if a given feature is enabled.
|
||||||
|
# With this, you can say
|
||||||
|
#
|
||||||
|
# my $bool_feat = gitweb_check_feature('bool_feat');
|
||||||
|
# gitweb_check_feature('bool_feat') or somecode;
|
||||||
|
#
|
||||||
|
# instead of
|
||||||
|
#
|
||||||
|
# my ($bool_feat) = gitweb_get_feature('bool_feat');
|
||||||
|
# (gitweb_get_feature('bool_feat'))[0] or somecode;
|
||||||
|
#
|
||||||
|
sub gitweb_check_feature {
|
||||||
|
return (gitweb_get_feature(@_))[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub feature_blame {
|
sub feature_blame {
|
||||||
my ($val) = git_get_project_config('blame', '--bool');
|
my ($val) = git_get_project_config('blame', '--bool');
|
||||||
|
|
||||||
|
@ -767,7 +783,7 @@ our $git_dir;
|
||||||
$git_dir = "$projectroot/$project" if $project;
|
$git_dir = "$projectroot/$project" if $project;
|
||||||
|
|
||||||
# list of supported snapshot formats
|
# list of supported snapshot formats
|
||||||
our @snapshot_fmts = gitweb_check_feature('snapshot');
|
our @snapshot_fmts = gitweb_get_feature('snapshot');
|
||||||
@snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
|
@snapshot_fmts = filter_snapshot_fmts(@snapshot_fmts);
|
||||||
|
|
||||||
# dispatch
|
# dispatch
|
||||||
|
@ -810,7 +826,7 @@ sub href (%) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($use_pathinfo) = gitweb_check_feature('pathinfo');
|
my $use_pathinfo = gitweb_check_feature('pathinfo');
|
||||||
if ($use_pathinfo) {
|
if ($use_pathinfo) {
|
||||||
# try to put as many parameters as possible in PATH_INFO:
|
# try to put as many parameters as possible in PATH_INFO:
|
||||||
# - project name
|
# - project name
|
||||||
|
@ -2101,7 +2117,7 @@ sub git_get_projects_list {
|
||||||
$filter ||= '';
|
$filter ||= '';
|
||||||
$filter =~ s/\.git$//;
|
$filter =~ s/\.git$//;
|
||||||
|
|
||||||
my ($check_forks) = gitweb_check_feature('forks');
|
my $check_forks = gitweb_check_feature('forks');
|
||||||
|
|
||||||
if (-d $projects_list) {
|
if (-d $projects_list) {
|
||||||
# search in directory
|
# search in directory
|
||||||
|
@ -2947,7 +2963,7 @@ EOF
|
||||||
}
|
}
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
|
|
||||||
my ($have_search) = gitweb_check_feature('search');
|
my $have_search = gitweb_check_feature('search');
|
||||||
if (defined $project && $have_search) {
|
if (defined $project && $have_search) {
|
||||||
if (!defined $searchtext) {
|
if (!defined $searchtext) {
|
||||||
$searchtext = "";
|
$searchtext = "";
|
||||||
|
@ -2961,7 +2977,7 @@ EOF
|
||||||
$search_hash = "HEAD";
|
$search_hash = "HEAD";
|
||||||
}
|
}
|
||||||
my $action = $my_uri;
|
my $action = $my_uri;
|
||||||
my ($use_pathinfo) = gitweb_check_feature('pathinfo');
|
my $use_pathinfo = gitweb_check_feature('pathinfo');
|
||||||
if ($use_pathinfo) {
|
if ($use_pathinfo) {
|
||||||
$action .= "/".esc_url($project);
|
$action .= "/".esc_url($project);
|
||||||
}
|
}
|
||||||
|
@ -3084,7 +3100,7 @@ sub git_print_page_nav {
|
||||||
$arg{'tree'}{'hash'} = $treehead if defined $treehead;
|
$arg{'tree'}{'hash'} = $treehead if defined $treehead;
|
||||||
$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
|
$arg{'tree'}{'hash_base'} = $treebase if defined $treebase;
|
||||||
|
|
||||||
my @actions = gitweb_check_feature('actions');
|
my @actions = gitweb_get_feature('actions');
|
||||||
my %repl = (
|
my %repl = (
|
||||||
'%' => '%',
|
'%' => '%',
|
||||||
'n' => $project, # project name
|
'n' => $project, # project name
|
||||||
|
@ -3454,7 +3470,7 @@ sub is_patch_split {
|
||||||
sub git_difftree_body {
|
sub git_difftree_body {
|
||||||
my ($difftree, $hash, @parents) = @_;
|
my ($difftree, $hash, @parents) = @_;
|
||||||
my ($parent) = $parents[0];
|
my ($parent) = $parents[0];
|
||||||
my ($have_blame) = gitweb_check_feature('blame');
|
my $have_blame = gitweb_check_feature('blame');
|
||||||
print "<div class=\"list_head\">\n";
|
print "<div class=\"list_head\">\n";
|
||||||
if ($#{$difftree} > 10) {
|
if ($#{$difftree} > 10) {
|
||||||
print(($#{$difftree} + 1) . " files changed:\n");
|
print(($#{$difftree} + 1) . " files changed:\n");
|
||||||
|
@ -3968,7 +3984,7 @@ sub git_project_list_body {
|
||||||
# actually uses global variable $project
|
# actually uses global variable $project
|
||||||
my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
|
my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
|
||||||
|
|
||||||
my ($check_forks) = gitweb_check_feature('forks');
|
my $check_forks = gitweb_check_feature('forks');
|
||||||
my @projects = fill_project_list_info($projlist, $check_forks);
|
my @projects = fill_project_list_info($projlist, $check_forks);
|
||||||
|
|
||||||
$order ||= $default_projects_order;
|
$order ||= $default_projects_order;
|
||||||
|
@ -4428,7 +4444,7 @@ sub git_summary {
|
||||||
my @taglist = git_get_tags_list(16);
|
my @taglist = git_get_tags_list(16);
|
||||||
my @headlist = git_get_heads_list(16);
|
my @headlist = git_get_heads_list(16);
|
||||||
my @forklist;
|
my @forklist;
|
||||||
my ($check_forks) = gitweb_check_feature('forks');
|
my $check_forks = gitweb_check_feature('forks');
|
||||||
|
|
||||||
if ($check_forks) {
|
if ($check_forks) {
|
||||||
@forklist = git_get_projects_list($project);
|
@forklist = git_get_projects_list($project);
|
||||||
|
@ -4457,7 +4473,7 @@ sub git_summary {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tag cloud
|
# Tag cloud
|
||||||
my $show_ctags = (gitweb_check_feature('ctags'))[0];
|
my $show_ctags = gitweb_check_feature('ctags');
|
||||||
if ($show_ctags) {
|
if ($show_ctags) {
|
||||||
my $ctags = git_get_project_ctags($project);
|
my $ctags = git_get_project_ctags($project);
|
||||||
my $cloud = git_populate_project_tagcloud($ctags);
|
my $cloud = git_populate_project_tagcloud($ctags);
|
||||||
|
@ -4747,7 +4763,7 @@ sub git_blob {
|
||||||
$expires = "+1d";
|
$expires = "+1d";
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($have_blame) = gitweb_check_feature('blame');
|
my $have_blame = gitweb_check_feature('blame');
|
||||||
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
|
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
|
||||||
or die_error(500, "Couldn't cat $file_name, $hash");
|
or die_error(500, "Couldn't cat $file_name, $hash");
|
||||||
my $mimetype = blob_mimetype($fd, $file_name);
|
my $mimetype = blob_mimetype($fd, $file_name);
|
||||||
|
@ -4840,7 +4856,7 @@ sub git_tree {
|
||||||
my $ref = format_ref_marker($refs, $hash_base);
|
my $ref = format_ref_marker($refs, $hash_base);
|
||||||
git_header_html();
|
git_header_html();
|
||||||
my $basedir = '';
|
my $basedir = '';
|
||||||
my ($have_blame) = gitweb_check_feature('blame');
|
my $have_blame = gitweb_check_feature('blame');
|
||||||
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
|
if (defined $hash_base && (my %co = parse_commit($hash_base))) {
|
||||||
my @views_nav = ();
|
my @views_nav = ();
|
||||||
if (defined $file_name) {
|
if (defined $file_name) {
|
||||||
|
@ -5838,7 +5854,7 @@ insensitive).</p>
|
||||||
<dt><b>commit</b></dt>
|
<dt><b>commit</b></dt>
|
||||||
<dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
|
<dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
|
||||||
EOT
|
EOT
|
||||||
my ($have_grep) = gitweb_check_feature('grep');
|
my $have_grep = gitweb_check_feature('grep');
|
||||||
if ($have_grep) {
|
if ($have_grep) {
|
||||||
print <<EOT;
|
print <<EOT;
|
||||||
<dt><b>grep</b></dt>
|
<dt><b>grep</b></dt>
|
||||||
|
@ -5855,7 +5871,7 @@ EOT
|
||||||
<dt><b>committer</b></dt>
|
<dt><b>committer</b></dt>
|
||||||
<dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
|
<dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
|
||||||
EOT
|
EOT
|
||||||
my ($have_pickaxe) = gitweb_check_feature('pickaxe');
|
my $have_pickaxe = gitweb_check_feature('pickaxe');
|
||||||
if ($have_pickaxe) {
|
if ($have_pickaxe) {
|
||||||
print <<EOT;
|
print <<EOT;
|
||||||
<dt><b>pickaxe</b></dt>
|
<dt><b>pickaxe</b></dt>
|
||||||
|
@ -5907,7 +5923,7 @@ sub git_shortlog {
|
||||||
|
|
||||||
sub git_feed {
|
sub git_feed {
|
||||||
my $format = shift || 'atom';
|
my $format = shift || 'atom';
|
||||||
my ($have_blame) = gitweb_check_feature('blame');
|
my $have_blame = gitweb_check_feature('blame');
|
||||||
|
|
||||||
# Atom: http://www.atomenabled.org/developers/syndication/
|
# Atom: http://www.atomenabled.org/developers/syndication/
|
||||||
# RSS: http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
|
# RSS: http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
|
||||||
|
|
Loading…
Reference in New Issue