Commit a2e50f37 authored by Laura Arjona Reina's avatar Laura Arjona Reina

vcs_get_file function converted to use git checkouts, needs review and test

CVS version numbers

Perl/Local/VCS_git.pm: 1.10 -> 1.11
parent cfbe359c
......@@ -426,19 +426,6 @@ sub vcs_get_diff
}
# returns the respository
# FIXME: this needs to be "translated" into git and hashes
sub _get_repository
{
open( my $fd, '<', 'CVS/Repository' )
or croak("Couldn't open `CVS/Repository': $!");
my $repo = <$fd>;
close( $fd );
chomp $repo;
return $repo;
}
=item vcs_get_file
Return a particular revision of a file
......@@ -453,7 +440,7 @@ Example use:
my $text = vcs_get_file( 'foo.c', '1.12' );
# FIXME: this needs to be "translated" into git and hashes
FIXME: converted to use git checkouts. Assumes we provide in $file the complete path. Needs review and test
=cut
......@@ -466,21 +453,27 @@ sub vcs_get_file
#TODO: what happens if we're not in the root webwml dir?
my $command = sprintf( 'cvs -q checkout -p -r%s %s/%s',
$rev, _get_repository, $file );
local $/ = ('=' x 67) . "\n";
my $command1 = sprintf( 'git -q checkout %s', $rev );
my $command2 = sprintf( 'cat %s', $file );
my $command3 = sprintf( 'git -q checkout origin/master');
my $text;
open ( my $git, '-|', $command )
or croak("Error while executing `$command': $!");
while ( my $line = <$git> )
open ( my $git1, '-|', $command1 )
or croak("Error while executing `$command1': $!");
close( $git1 );
open ( my $git2, '-|', $command2 )
or croak("Error while executing `$command2': $!");
while ( my $line = <$git2> )
{
$text .= $line;
}
close( $git );
close( $git2 );
croak("Error while executing `$command': $!") unless WIFEXITED($?);
# return to git master
open ( my $git3, '-|', $command3 )
or croak("Error while executing `$command3': $!");
close( $git3 );
# return the file
return $text;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment