send_git: new process to send a student repository to moulette
This commit is contained in:
parent
335b03768d
commit
0e35a1a2e9
52
process/files/send_git.pl
Normal file
52
process/files/send_git.pl
Normal file
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use v5.10;
|
||||
use File::Path qw(remove_tree);
|
||||
use File::Temp qw/tempfile tempdir/;
|
||||
|
||||
use ACU::Log;
|
||||
use ACU::Process;
|
||||
|
||||
|
||||
sub process
|
||||
{
|
||||
my ($given_args, $args) = @_;
|
||||
|
||||
my $year = $args->{param}{year};
|
||||
my $project_id = $args->{param}{id};
|
||||
my $rendu = $args->{param}{rendu};
|
||||
my $login = $args->{param}{login};
|
||||
|
||||
my $path = $args->{param}{path} // "/srv/git/repositories/$year/$project_id/$login.git";
|
||||
|
||||
return "$path is not a valid path." if (! -d $path);
|
||||
|
||||
my $tempdir = tempdir();
|
||||
|
||||
qx/git clone -b '$rendu' '$path' '$tempdir'/;
|
||||
|
||||
my $tar;
|
||||
open my $fh, "tar -czf - -C '$tempdir' . |";
|
||||
$tar .= $_ while(<$fh>);
|
||||
close $fh;
|
||||
|
||||
# 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);
|
Reference in New Issue
Block a user