aboutsummaryrefslogtreecommitdiffstats
path: root/Perl
diff options
context:
space:
mode:
authorLaura Arjona Reina <larjona>2017-11-07 12:27:35 +0000
committerLaura Arjona Reina <larjona>2017-11-07 12:27:35 +0000
commitf2c46a72ea4a9e72059c5de641d1f57b633af26a (patch)
treeffb95d2c25674745d05984f334d891ee6b273488 /Perl
parentbdedb4c60397cfb754e29c43da622cbe01230cd0 (diff)
vcs_get_log function converted into git and hashes, needs review and test
CVS version numbers Perl/Local/VCS_git.pm: 1.8 -> 1.9
Diffstat (limited to 'Perl')
-rw-r--r--Perl/Local/VCS_git.pm29
1 files changed, 14 insertions, 15 deletions
diff --git a/Perl/Local/VCS_git.pm b/Perl/Local/VCS_git.pm
index af4ec9300f3..2b32199988f 100644
--- a/Perl/Local/VCS_git.pm
+++ b/Perl/Local/VCS_git.pm
@@ -297,14 +297,14 @@ Example use:
my @log_entries = vcs_get_log( 'foo.wml' );
-FIXME: this needs to be "translated" into git and hashes
+FIXME: converted into git and hashes, needs review and test
=cut
sub vcs_get_log
{
my $file = shift or return;
- my $rev1 = shift || '0';
+ my $rev1 = shift || '';
my $rev2 = shift || '';
my @logdata;
@@ -312,28 +312,27 @@ sub vcs_get_log
# set the record separator for git log output
local $/ = "\n----------------------------\n";
- my $command = sprintf( 'cvs log -r%s:%s %s', $rev1, $rev2, $file );
+ my $command = sprintf( 'git log %s..%s %s', $rev1, $rev2, $file );
open( my $git, '-|', $command )
or croak("Couldn't run `$command': $!");
- # skip the first record (gives genral meta-info)
- <$git>;
-
# read the consequetive records
while ( my $record = <$git> )
{
#print "==> $record\n";
- # the first two lines of a record contains metadata that looks like this:
- # revision 1.4
- # date: 2008-09-18 16:21:31 +0200; author: bas; state: Exp; lines: +212 -105; commitid: aGcNZ0HjJeSEfgjt;
+ # the first 3 lines of a record contain metadata that looks like this:
+ # commit abcdefg435768938de
+ # Author: Jane Doe <email@example.com>
+ # Date: Tue Nov 7 11:47:24 2017 +0100
- # first split off the first line
- my ($metadata1,$metadata2,$logmessage) = split( /\n/, $record, 3 );
-
- my ($revision) = $metadata1 =~ m{^revision (.+)};
- my ($date,$author) = $metadata2 =~ m{^date: (.*?); author: (.*?); state: };
+ # first split off the record
+ my ($metadata1,$metadata2,$metadata3,$logmessage) = split( /\n/, $record, 4 );
+ my ($revision) = $metadata1 =~ m{^commit (.+)};
+ my ($author) = $metadata2 =~ m{^Author: (.+)};
+ my ($date) = $metadata3 =~ m{^Date: (.+)};
+
croak( "Couldn't parse output of `$command'" )
unless $revision and $date and $author;
@@ -345,8 +344,8 @@ sub vcs_get_log
push @logdata, {
'rev' => $revision,
- 'date' => $date,
'author' => $author,
+ 'date' => $date,
'message' => $logmessage,
};
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy