Archived
1
0
Fork 0
This repository has been archived on 2021-10-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
ACU/process/files/send_git.pl
2013-11-18 18:57:30 +01:00

55 lines
1.2 KiB
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use Carp;
use v5.10;
use File::Path qw(remove_tree);
use File::Temp qw/tempfile tempdir/;
use ACU::LDAP;
use ACU::Log;
use ACU::Process;
sub process
{
my ($given_args, $args) = @_;
my $year = $args->{param}{year} // LDAP::get_year();
my $project_id = $args->{param}{id};
my $rendu = $args->{param}{rendu};
my $login = $args->{param}{login};
my $path = $args->{param}{path} // "ssh://git\@localhost/$year/$project_id/$login.git";
my $tempdir = tempdir();
qx/git clone -b '$rendu' '$path' '$tempdir'/ or croak "$path is not a valid repository.";
croak "$path is not a valid repository." if ($?);
my $tar;
open my $fh, "tar -czf - -C '$tempdir' . |" or die ($!);
$tar .= $_ while(<$fh>);
close $fh;
die "Unable to untar: $!" if ($?);
# Clean
remove_tree($tempdir);
return Process::Client::launch("moulette_get",
{
"type" => "std",
"id" => $project_id,
"year" => $year,
"rendu" => $rendu,
"login" => $login,
"file" => "rendu.tgz"
},
{
"rendu.tgz" => $tar
});
}
Process::register("send_git", \&process);