-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate
80 lines (63 loc) · 2.06 KB
/
update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
BEGIN %*ENV<RAKUDO_PRECOMPILATION_PROGRESS> = 1;
my %*SUB-MAIN-OPTS = :named-anywhere;
use Git::Status:ver<0.0.1>:auth<zef:lizmat>;
use Ecosystem::Archive::Update:auth<zef:lizmat>;
unit sub MAIN(
Bool :$commit, #= when updating, also commit any changes
Bool :$push, #= when committing, also push any changes to repo
Bool :$verbose, #= be verbose in update results
Int :$degree, #= number of CPU's to use
Int :$batch, #= number of distributions at-a-time
Bool :$force-json, #= force updating of all JSON files
);
my $then;
sub msecs() { ((now - $then) * 1000).Int ~ ' msecs' }
run <git pull>, :!out;
say "Running updater v{Ecosystem::Archive::Update.^ver}";
$then = now;
my $ea = Ecosystem::Archive::Update.new(:$degree,:$batch);
say "Took &msecs() to read $ea.identities.elems() identities";
$then = now;
my %added = $ea.update(:$force-json);
"META.json".IO.spurt: $ea.meta-as-json;
say "Took &msecs() to add %added.elems() identities:";
say " $_" for %added.keys.sort;
if $verbose {
say "$ea.notes.elems() notes were made:";
say " $_" for $ea.notes;
}
else {
say "$ea.notes.elems() notes were made";
}
if $commit {
my $status := Git::Status.new;
my $archive = so $status.untracked.first: *.starts-with: 'archive';
my $meta = so $status.untracked.first: *.starts-with: 'meta';
if $archive || $meta {
run <git add archive meta>;
run <git commit META.json archive meta -m>, "Additions at {
DateTime.now.utc.Str.substr(0,16)
}";
if $push {
run <git push>;
}
elsif $verbose {
say "Did not push as --push was not specified";
}
}
else {
say "There was nothing to commit";
}
}
elsif $verbose {
say "Did not commit as --commit was not specified";
}
=begin pod
=head1 AUTHOR
Elizabeth Mattijsen <liz@raku.rocks>
=head1 COPYRIGHT AND LICENSE
Copyright 2022 Elizabeth Mattijsen
This script is free software; you can redistribute it and/or modify it under
the Artistic License 2.0.
=end pod
# vim: expandtab shiftwidth=4