Skip to content

Commit e4e3b32

Browse files
theefergitster
authored andcommitted
gitweb: Modularized git_get_project_description to be more generic
Introduce a git_get_file_or_project_config utility function to retrieve a repository variable either from a plain text file in the $GIT_DIR or else from 'gitweb.$variable' in the repository config (e.g. 'description'). This would be used in next commit to retrieve category for a project, which is to be stored in the same way as project description. Signed-off-by: Sebastien Cevey <[email protected]> Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0fa920c commit e4e3b32

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

gitweb/gitweb.perl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,18 +2562,26 @@ sub git_get_path_by_hash {
25622562
## ......................................................................
25632563
## git utility functions, directly accessing git repository
25642564

2565-
sub git_get_project_description {
2566-
my $path = shift;
2565+
# get the value of config variable either from file named as the variable
2566+
# itself in the repository ($GIT_DIR/$name file), or from gitweb.$name
2567+
# configuration variable in the repository config file.
2568+
sub git_get_file_or_project_config {
2569+
my ($path, $name) = @_;
25672570

25682571
$git_dir = "$projectroot/$path";
2569-
open my $fd, '<', "$git_dir/description"
2570-
or return git_get_project_config('description');
2571-
my $descr = <$fd>;
2572+
open my $fd, '<', "$git_dir/$name"
2573+
or return git_get_project_config($name);
2574+
my $conf = <$fd>;
25722575
close $fd;
2573-
if (defined $descr) {
2574-
chomp $descr;
2576+
if (defined $conf) {
2577+
chomp $conf;
25752578
}
2576-
return $descr;
2579+
return $conf;
2580+
}
2581+
2582+
sub git_get_project_description {
2583+
my $path = shift;
2584+
return git_get_file_or_project_config($path, 'description');
25772585
}
25782586

25792587
# supported formats:

0 commit comments

Comments
 (0)