Archived
1
0

Merge branch 'master' of ssh://cpp/liblerdorf

This commit is contained in:
Root Cpp Charlie 2013-10-23 06:57:22 +02:00
commit 7214b54053
10 changed files with 93 additions and 19 deletions

View File

@ -10,9 +10,10 @@ use Carp;
use ACU::API::Base;
use ACU::LDAP;
sub add($;$)
sub add($$;$)
{
my $project_name = shift;
my $flavor = shift;
my $year = shift;
if ($year and $year != LDAP::get_year) {
@ -21,7 +22,10 @@ sub add($;$)
my $res = API::Base::send('ResultHandler',
"projects/projects/add.xml",
[ project_name => $project_name ]);
[
project_name => $project_name,
flavor => $flavor,
]);
if ($res->{result} ne '0') {
croak "Erreur durant l'ajout : ".$res->{message};

View File

@ -38,8 +38,12 @@ sub tinyglob
elsif ($str[$i] eq '*') {
$res .= '.*';
}
elsif ($metaescape) {
$res .= $str[$i];
$metaescape = 0;
}
else {
croak "Invalid number of \\ in '$orig'";
$res .= "\\".$str[$i];
}
}
else {
@ -55,6 +59,8 @@ sub match
my $glob = tinyglob(shift);
my $str = shift;
say $glob;
return $str =~ /$glob/;
}

View File

@ -18,6 +18,9 @@ is(Tinyglob::tinyglob("\\*"), "\\*");
is(Tinyglob::tinyglob("\\\\*"), "\\\\.*");
is(Tinyglob::tinyglob("\\?"), "\\?");
is(Tinyglob::tinyglob("\\\\?"), "\\\\.");
is(Tinyglob::tinyglob("\\."), "\\.");
is(Tinyglob::tinyglob("\\\\."), "\\\\\\.");
is(Tinyglob::tinyglob("a*b?"), "a.*b.");
ok(! Tinyglob::match("?", ""));
ok(! Tinyglob::match("b", "a"));

View File

@ -18,6 +18,7 @@ install:
! test -d $(GITOLITE_DEST) || $(MAKEDIR) -p $(GITOLITE_DEST)/update.secondary.d
! test -d $(GITOLITE_DEST) || $(COPY) hooks/gl-pre-git $(GITOLITE_DEST)/
! test -d $(GITOLITE_DEST) || $(COPY) hooks/subjects.pl $(GITOLITE_DEST)/update.secondary.d/
! test -d $(GITOLITE_DEST) || $(COPY) hooks/conferences.pl $(GITOLITE_DEST)/update.secondary.d/
! test -d $(GITOLITE_DEST) || $(COPY) hooks/submissions.pl $(GITOLITE_DEST)/update.secondary.d/
update:

49
hooks/conferences.pl Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env perl
use strict;
use warnings;
use v5.10;
use Digest::SHA qw(sha1_base64);
use File::Basename;
use utf8;
use ACU::API::Projects;
use ACU::Defense;
use ACU::LDAP;
use ACU::Log;
$ACU::Log::log_file = "/var/log/hooks/" . basename($0) . ".log";
use ACU::Process;
# First, check if the repository is in the conferences/ directory
exit 0 if ($ENV{GL_REPO} !~ /^conferences\//);
my ($ref, $oldsha, $newsha) = @ARGV;
log DONE, "This is a conference repository!";
my %known_tags = (
"subject" => \&tag_document,
);
if ($ref =~ m<^refs/tags(/.+)$>)
{
my $tag = $1;
my @args;
while ($tag =~ m<[,/]([^,]*)>g) {
push @args, $1;
}
my $create = ($newsha ne '0' x 40);
if (exists $known_tags{$args[0]}) {
exit $known_tags{$args[0]}($create, @args);
}
}
exit 0;
sub tag_document
{
}

View File

@ -19,6 +19,8 @@ my $promo = qx(git config hooks.promo);
my $id_project = qx(git config hooks.idproject);
my $repo_login = qx(git config hooks.repologin);
my @habitent_loin = ("amed_m", "bellev_m", "faure_n", "freima_m", "ikouna_l", "simon_j");
# First, check if the repository is in the YYYY/ directory
exit 0 if (($promo && $id_project && $repo_login) || $ENV{GL_REPO} !~ /^2[0-9]{3}\/.+\/.+/);
@ -46,6 +48,8 @@ if ($ip->overlaps($labnetwork) == $IP_A_IN_B_OVERLAP)
# exit 1;
#}
exit 0 if (grep { /\Q$repo_login\E/ } @habitent_loin);
my $schoolnetwork = Net::IP->new('10.41.0.0/16');
#my $vjschoolnetwork = Net::IP->new('10.3.0.0/16');

View File

@ -19,7 +19,16 @@ tex2md()
do
bi=`basename "$i"`
echo -e "\e[1;34m>>>\e[1;37m Trying to convert $i to Markdown...\e[0m"
# BEGIN HACK! Need stacking
sed -Ei 's/\\distribution\{\}/FreeBSD 9/gi' "$i"
sed -Ei 's/\\\{/__OPEN_BRACKET_MINIROOT__/gi' "$i"
sed -Ei 's/\\\}/__CLOSE_BRACKET_MINIROOT__/gi' "$i"
sed -Ei 's/-\{\}-//gi' "$i"
sed -Ei 's/\\_/_/gi' "$i"
# DIRTY HACK
sed -Ei 's/\\includegraphics *\{([^}]+)}/\\verb+%%image(\1)+/gi' "$i"
sed -Ei 's/\\include *\{([^}]+)}/\\verb+%%scoped-include(\1)+/gi' "$i"
sed -Ei 's/\\input *\{([^}]+)}/\\verb+%%scoped-include(\1)+/gi' "$i"
@ -39,7 +48,7 @@ tex2md()
sed -Ei 's/\\verb ([^+]+) /\\verb+\1+/g' "$i"
# Special macros
sed -Ei 's/\\(file|email|command) *\{([^{]*\{[^}]*\})*([^}]*)}/\\verb+\2\3+/gi' "$i"
sed -Ei 's/\\(file|email|command|code|bcode) *\{([^}]*)\}/\\verb+\2+/gi' "$i"
sed -Ei 's/\\begin *\{assistant\}/\\verb+%%assistant-begin+/g' "$i"
sed -Ei 's/\\end *\{assistant\}/\\verb+%%assistant-end+/g' "$i"
@ -59,6 +68,10 @@ tex2md()
sed -Ei 's/\\frame//g' "$i"
sed -Ei 's/\\item( *)<[^>]+>/\\item\1/g' "$i"
# END HACK!
sed -Ei 's/__OPEN_BRACKET_MINIROOT__/\{/gi' "$i"
sed -Ei 's/__CLOSE_BRACKET_MINIROOT__/\}/gi' "$i"
if pandoc -o "$DEST"/${bi%%.tex}.md $i
then
git add "$DEST"/${bi%%.tex}.md

View File

@ -3,7 +3,7 @@
use v5.10.1;
use strict;
use warnings;
#use threads;
use threads;
use Carp;
use File::Basename;
use File::Copy;
@ -168,7 +168,7 @@ sub run_moulette
opendir(my $dh, $submitdir) or die "Can't list files in $submitdir: $!";
while (readdir($dh))
{
if (/([a-zA-Z0-9_-]+).ff$/ && -f "$submitdir/$_") {
if (/([a-zA-Z0-9_-]+).ff$/ && -f "$submitdir/$_" && ! /^tests\.ff$/) {
push @logins, $1;
}
}
@ -183,6 +183,10 @@ sub run_moulette
} elsif (-f "$testdir/test.ft") {
open $fhin, "<", "$testdir/test.ft" or croak "Unable to open $testdir/test.ft: $!";
}
#TODO: remove this
elsif (-f "$submit/test.ft") {
open $fhin, "<", "$testdir/test.ft" or croak "Unable to open $testdir/test.ft: $!";
}
if ($fhin)
{
@ -317,9 +321,5 @@ sub process_get
return "Ok";
}
#threads->create('monitor_start');
threads->create('monitor_start');
Process::register("moulette_get", \&process_get);
#$project_paths{'/data/output/2016-exam-c-0-rendu-1'} = { "id" => "exam-c-0", "year" => "2016", "rendu" => "rendu-1" };
#$fm->monitor('/data/output/2016-exam-c-0-rendu-1');
#monitor_start();

View File

@ -7,8 +7,6 @@ use File::Basename;
use Mail::Internet;
use Pod::Usage;
use lib "../../";
use ACU::Log;
use ACU::LDAP;
use ACU::Process;

View File

@ -27,11 +27,7 @@ sub process
my $year = shift @args // LDAP::get_year;
# Project existing?
if (! -d "$basedir/$year/$project_id")
{
log ERROR, "Unable to find $project_id in $year";
return "Unable to find $project_id in $year\n";
}
croak "Unable to find $project_id in $year" if (! -d "$basedir/$year/$project_id");
my $grade = Grading->new();