Permalink
Browse files

[19] Implemented possibility of `git log` restriction

Signed-off-by: DoesntMatter <jaed1@gmx.net>
  • Loading branch information...
DoesntMatter committed Jan 22, 2012
1 parent d5bee6c commit 3cd6c11c3241f156ae60d892a3b60dc697fbb24e
Showing with 14 additions and 3 deletions.
  1. +14 −3 gitlog_to_rss.pl
View
@@ -39,6 +39,7 @@
GetOptions (
\%options,
"repo=s",
"count=i",
"outfile=s",
"title=s",
"desc=s",
@@ -81,6 +82,7 @@
unless (CheckRepo($options{'repo'})) {
ShowHelp();
}
$options{'count'} = GetInput("Please enter count of commits: ");
$options{'outfile'} = GetInput("Please enter outfile path: ");
$rss{'title'} = GetInput("Please enter RSS title: ");
$rss{'desc'} = GetInput("Please enter RSS description: ");
@@ -91,7 +93,7 @@
# Do the job
#
$gitlog = ParseGitLog($options{'repo'});
$gitlog = ParseGitLog($options{'repo'}, $options{'count'});
unless ($gitlog) {
print "Parsing `git log` command failed!\n";
exit;
@@ -112,6 +114,8 @@ sub ShowHelp {
Options:
--repo REPO Path to your Git repository
--count COUNT Count of commits that shoud be parsed
Default: All commits
--outfile FILE Name and path of generated RSS file
Default: \$PWD/feed.rss
--title TITLE Title of your RSS Feed
@@ -163,8 +167,15 @@ sub CheckRepo {
sub ParseGitLog {
my $repo = shift || return undef;
my $cmd = "git log --pretty=tformat:%H%n%cd%n%cn%n%ce%n%s%n%b%m $repo";
my $result;
my $count = shift;
my ($cmd, $result);
if ($count) {
$cmd = "git log -n$count --pretty=tformat:%H%n%cd%n%cn%n%ce%n%s%n%b%m $repo";
}
else {
$cmd = "git log --pretty=tformat:%H%n%cd%n%cn%n%ce%n%s%n%b%m $repo";
}
$result = "\n" . qx/$cmd/;
if ($? == -1) {

0 comments on commit 3cd6c11

Please sign in to comment.