From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>,
Jonathan Nieder <jrnieder@gmail.com>, Petr Baudis <pasky@suse.cz>,
"J.H." <warthog9@kernel.org>, Sebastien Cevey <seb@cine7.net>,
Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 2/3] gitweb: Modularized git_get_project_description to be more generic
Date: Tue, 8 Mar 2011 00:13:34 +0100 [thread overview]
Message-ID: <1299539616-19991-3-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <1299539616-19991-1-git-send-email-jnareb@gmail.com>
From: Sebastien Cevey <seb@cine7.net>
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 <seb@cine7.net>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
gitweb/gitweb.perl | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0020b13..c032cd4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2550,18 +2550,26 @@ sub git_get_path_by_hash {
## ......................................................................
## git utility functions, directly accessing git repository
-sub git_get_project_description {
- my $path = shift;
+# get the value of config variable either from file named as the variable
+# itself in the repository ($GIT_DIR/$name file), or from gitweb.$name
+# configuration variable in the repository config file.
+sub git_get_file_or_project_config {
+ my ($path, $name) = @_;
$git_dir = "$projectroot/$path";
- open my $fd, '<', "$git_dir/description"
- or return git_get_project_config('description');
- my $descr = <$fd>;
+ open my $fd, '<', "$git_dir/$name"
+ or return git_get_project_config($name);
+ my $conf = <$fd>;
close $fd;
- if (defined $descr) {
- chomp $descr;
+ if (defined $conf) {
+ chomp $conf;
}
- return $descr;
+ return $conf;
+}
+
+sub git_get_project_description {
+ my $path = shift;
+ return git_get_file_or_project_config($path, 'description');
}
sub git_get_project_ctags {
--
1.7.3
next prev parent reply other threads:[~2011-03-07 23:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-07 23:13 [RFC/PATCH 0/3] gitweb: Categories support Jakub Narebski
2011-03-07 23:13 ` [PATCH 1/3] gitweb: Split git_project_list_body in two functions Jakub Narebski
2011-03-07 23:13 ` Jakub Narebski [this message]
2011-03-07 23:13 ` [PATCH 3/3] gitweb: Optional grouping of projects by category Jakub Narebski
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=1299539616-19991-3-git-send-email-jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=pasky@suse.cz \
--cc=seb@cine7.net \
--cc=u.kleine-koenig@pengutronix.de \
--cc=warthog9@kernel.org \
/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).