[pkg-perl-tools] 02/02: dpt-salsa: githashes: write to files
gregor herrmann
gregoa at debian.org
Sat Feb 17 17:48:32 UTC 2018
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to branch master
in repository pkg-perl-tools.
commit 257b6a8d8c0aab514e787604e953c8e2414b751d
Author: gregor herrmann <gregoa at debian.org>
Date: Sat Feb 17 18:27:07 2018 +0100
dpt-salsa: githashes: write to files
unfortunately this is quite slow, unclear if we can really use this
Gbp-Dch: ignore
---
scripts/salsa | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/scripts/salsa b/scripts/salsa
index 9a69173..5beb8d5 100755
--- a/scripts/salsa
+++ b/scripts/salsa
@@ -10,6 +10,7 @@ use GitLab::API::v4::Constants qw( :all );
use Git;
use JSON;
use utf8::all;
+use File::Spec;
# config
## defaults
@@ -26,6 +27,7 @@ my %config = (
perl_team_modules_packages_id => 2666,
perl_team_modules_attic_path => 'perl-team/modules/attic',
perl_team_modules_attic_id => 2667,
+ packages => '',
);
## update from environment / config file
@@ -35,6 +37,8 @@ foreach ( keys %config ) {
my $KEY = 'DPT_SALSA_' . uc($_);
$config{$_} = $ENV{$KEY} if $ENV{$KEY};
}
+## also read DPT_PACKAGES
+$config{packages} = $ENV{DPT_PACKAGES};
# commandline
## options
@@ -358,8 +362,15 @@ sub mrconfig {
}
## githashes
-## XXX: TODO: this is a sketch
sub githashes {
+ die 'DPT_PACKAGES not set.' unless $config{packages};
+ my $outdir = File::Spec->catdir( $config{packages}, '..', '.git.hashes' );
+ die "Can't find directory '$outdir'." unless -d $outdir;
+
+ my @currentfiles = glob("$outdir/*");
+ s{$outdir/}{}o for @currentfiles;
+ my %currentfiles = map( ( $_ => 1 ), @currentfiles );
+
my $paginator = $api->paginator(
'group_projects',
$config{perl_team_modules_packages_id},
@@ -377,9 +388,17 @@ sub githashes {
$repohashes->{branches} = $repobranches if $repobranches;
# $repohashes->{trunk} seems to be a PET artifact and not used by compare-hashes
- # XXX outfh
- say prettyjson($repohashes);
+ my $outfile = File::Spec->catfile( $outdir, $repo->{name} );
+ open( my $fh, '>', "$outfile.new" )
+ or die "Can't open '$outfile.new': $!";
+ print $fh prettyjson($repohashes);
+ close $fh;
+ rename "$outfile.new", "$outfile"
+ or die "Can't rename '$outfile.new' to '$outfile': $!";
+ delete $currentfiles{ $repo->{name} };
}
+
+ unlink "$outdir/$_" for keys %currentfiles;
}
# helper functions
@@ -661,8 +680,6 @@ Helper for creating F<.git.hashes/PKGNAME> files for all active packages of
the I<modules> subgroup of the I<perl-team> group which are then used by
B<compare-hashes> in F<.mrconfig>.
-B<WARNING>: Currently just a stub.
-
=head3 I<current_user> [--json]
Outputs information about the user whose I<GitLab> token is used.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git
More information about the Pkg-perl-cvs-commits
mailing list