Commit 85fe021f authored by gregor herrmann's avatar gregor herrmann

Merge branch 'lastactivity'

parents 71868c66 925322c6
......@@ -137,10 +137,6 @@ if ( $command eq 'version' ) {
kgb();
} elsif ( $command eq 'mrconfig' ) {
mrconfig();
} elsif ( $command eq 'githashes' ) {
say STDERR
"W: githashes() is deprecated and its functionality integrated into mrconfig(). Calling mrconfig() now.";
mrconfig();
} elsif ( $command eq 'help' ) {
pod2usage(1);
} else {
......@@ -455,16 +451,17 @@ sub mrconfig {
or die "Can't open '$mroutfile.new': $!";
my @mrstanzas;
# githashes
my $hashesoutdir
= File::Spec->catdir( $config{packages}, '..', '.git.hashes' );
-d $hashesoutdir
or mkdir($hashesoutdir)
or die "Can't find or create directory '$hashesoutdir': $!";
# lastactivity
my $lastactivityoutdir
= File::Spec->catdir( $config{packages}, '..', '.lastactivity' );
-d $lastactivityoutdir
or mkdir($lastactivityoutdir)
or die "Can't find or create directory '$lastactivityoutdir': $!";
my @currenthashesfiles = glob("$hashesoutdir/*");
s{$hashesoutdir/}{}o for @currenthashesfiles;
my %currenthashesfiles = map( ( $_ => 1 ), @currenthashesfiles );
my @currentlastactivityfiles = glob("$lastactivityoutdir/*");
s{$lastactivityoutdir/}{}o for @currentlastactivityfiles;
my %currentlastactivityfiles
= map( ( $_ => 1 ), @currentlastactivityfiles );
# parallel
my $jobs = $opts{parallel} || 1;
......@@ -497,7 +494,7 @@ sub mrconfig {
);
while ( my $repo = trypaginator($paginator) ) {
my $reponame = $repo->{name};
delete $currenthashesfiles{$reponame};
delete $currentlastactivityfiles{$reponame};
if ($pm) {
$pm->start and next;
......@@ -515,35 +512,22 @@ sub mrconfig {
say $mrfh $mrstanza;
}
# githashes
my ( $repotags, $repobranches, $repohashes );
# "try" api calls so we don't die in the loop
my ( $tags, $branches );
# disable tags retrieval to save time
# try { $tags = $api->tags( $repo->{id} ); };
# $repotags->{ 'refs/tags/' . $_->{name} } = $_->{commit}->{id}
# foreach @{$tags};
# $repohashes->{tags} = $repotags if $repotags;
try { $branches = $api->branches( $repo->{id} ); };
$repobranches->{ 'refs/heads/' . $_->{name} } = $_->{commit}->{id}
foreach @{$branches};
$repohashes->{branches} = $repobranches if $repobranches;
# $repohashes->{trunk} seems to be a PET artifact and not used by compare-hashes
# write file if $repohashes is not empty
my $hashesoutfile = File::Spec->catfile( $hashesoutdir, $reponame );
if ($repohashes) {
open( my $hashesfh, '>', "$hashesoutfile.new" )
or die "Can't open '$hashesoutfile.new': $!";
print $hashesfh prettyjson($repohashes);
close $hashesfh;
rename "$hashesoutfile.new", "$hashesoutfile"
# lastactivity
my $lastactivityoutfile
= File::Spec->catfile( $lastactivityoutdir, $reponame );
my $lastactivity = $repo->{last_activity_at};
if ($lastactivity) {
open( my $lastactivityfh, '>', "$lastactivityoutfile.new" )
or die "Can't open '$lastactivityoutfile.new': $!";
print $lastactivityfh $lastactivity;
close $lastactivityfh;
rename "$lastactivityoutfile.new", "$lastactivityoutfile"
or die
"Can't rename '$hashesoutfile.new' to '$hashesoutfile': $!";
"Can't rename '$lastactivityoutfile.new' to '$lastactivityoutfile': $!";
} else {
if ( -f "$hashesoutfile" ) {
unlink "$hashesoutfile"
or die "Can't delete stale '$hashesoutfile': $!";
if ( -f "$lastactivityoutfile" ) {
unlink "$lastactivityoutfile"
or die "Can't delete stale '$lastactivityoutfile': $!";
}
}
......@@ -564,8 +548,8 @@ sub mrconfig {
rename "$mroutfile.new", "$mroutfile"
or die "Can't rename '$mroutfile.new' to '$mroutfile': $!";
# githashes
unlink "$hashesoutdir/$_" for keys %currenthashesfiles;
# lastactivity
unlink "$lastactivityoutdir/$_" for keys %currentlastactivityfiles;
}
# helper functions
......@@ -882,18 +866,14 @@ F<.mrconfig>.
=item *
F<.git.hashes/PKGNAME> files in the local clone of
F<.lastactivity/PKGNAME> files in the local clone of
C<meta.git> 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>.
I<perl-team> group which are then used by B<compare-lastactivity> in F<.mrconfig>.
=back
With C<--parallel> L<Parallel::ForkManager> is employed for parallelism.
=head3 I<githashes>
DEPRECATED. Functionality merged into C<mrconfig()>.
=head3 I<current_user> [--json]
Outputs information about the user whose I<GitLab> token is used.
......
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