Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[22] Rewritten project to object-oriented structure
Use header files for subroutines Use packages for better accessing Signed-off-by: DoesntMatter <jaed1@gmx.net>
- Loading branch information
1 parent
c46043e
commit b71d9ea
Showing
3 changed files
with
239 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/usr/bin/perl -w | ||
|
||
# GitlogParser | ||
# Converts the output of `git log` to different output types | ||
# | ||
# Copyright (C) 2012, by: Dennis Christ <jaed1@gmx.net> | ||
# http://dev-blog.doesntmatter.de | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# The GNU General Public License is available at: | ||
# http://www.gnu.org/copyleft/gpl.html | ||
|
||
use strict; | ||
use HTML::Entities; | ||
|
||
package GENERIC; | ||
|
||
# | ||
# Subroutines | ||
# | ||
|
||
sub GetInput { | ||
my $text = shift || return undef; | ||
my $mandatory = shift || 0; | ||
my $input; | ||
|
||
if ($mandatory) { | ||
until ($input) { | ||
print STDERR $text; | ||
$input = <>; | ||
chomp($input); | ||
} | ||
} | ||
else { | ||
print STDERR $text; | ||
$input = <>; | ||
chomp($input); | ||
} | ||
return $input; | ||
} | ||
|
||
sub CheckRepo { | ||
my $repo = shift || return undef; | ||
|
||
unless (-d $repo) { | ||
print "Repository does not exist in given path!\n"; | ||
return undef; | ||
} | ||
unless (-d ($repo . "/.git")) { | ||
print "Given directory is not a Git repository!\n"; | ||
return undef; | ||
} | ||
return 1; | ||
} | ||
|
||
sub ParseGitLog { | ||
my $repo = shift || return undef; | ||
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) { | ||
print "Command failed: $!\n"; | ||
return undef; | ||
} | ||
$result =~ s/\s+$//; # Remove trailing whitespaces | ||
return HTML::Entities::encode($result); | ||
} | ||
|
||
sub SplitCommits { | ||
my $gitlog = shift || return undef; | ||
my @items = split(/\n>/, $gitlog); | ||
my $size = scalar @items; | ||
my (@lines, @commit, $i); | ||
|
||
for $i ( 0 .. ($size - 1) ) { | ||
@lines = split(/\n/, $items[$i], 7); | ||
$commit[$i] = [ @lines ]; | ||
} | ||
return @commit; | ||
} | ||
|
||
return 1; |
Oops, something went wrong.