2017-06-12 19:23:23 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use v5.10;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use File::Slurp qw(slurp write_file);
|
|
|
|
use File::stat;
|
|
|
|
use File::Touch;
|
2018-06-29 12:51:20 +02:00
|
|
|
use File::chdir;
|
|
|
|
use File::Spec;
|
2017-06-12 19:23:23 +02:00
|
|
|
use Data::Dumper qw(Dumper);
|
|
|
|
use Carp;
|
|
|
|
use Term::ANSIColor;
|
|
|
|
use Term::ReadKey;
|
2017-11-20 10:41:52 +01:00
|
|
|
use List::Util qw(first);
|
2017-06-12 19:23:23 +02:00
|
|
|
use Clone qw(clone);
|
2020-12-18 16:43:20 +01:00
|
|
|
use LWP::UserAgent;
|
2017-06-12 19:23:23 +02:00
|
|
|
|
|
|
|
sub get_deps {
|
|
|
|
my ($config, %fdeps) = @_;
|
|
|
|
|
|
|
|
my %deps;
|
|
|
|
|
|
|
|
return { } unless $config =~ /\{\s*deps\s*,\s*\[(.*?)\]/s;
|
|
|
|
my $sdeps = $1;
|
|
|
|
|
2017-06-27 14:56:00 +02:00
|
|
|
while ($sdeps =~ /\{\s* (\w+) \s*,\s* ".*?" \s*,\s* \{\s*git \s*,\s* "(.*?)" \s*,\s*
|
|
|
|
(?:
|
|
|
|
(?:{\s*tag \s*,\s* "(.*?)") |
|
|
|
|
"(.*?)" |
|
|
|
|
( \{ (?: (?-1) | [^{}]+ )+ \} ) )/sgx) {
|
2017-06-12 19:23:23 +02:00
|
|
|
next unless not %fdeps or exists $fdeps{$1};
|
|
|
|
$deps{$1} = { repo => $2, commit => $3 || $4 };
|
|
|
|
}
|
|
|
|
return \%deps;
|
|
|
|
}
|
|
|
|
my (%info_updates, %top_deps_updates, %sub_deps_updates, @operations);
|
2017-07-14 15:08:06 +02:00
|
|
|
my $epoch = 1;
|
2017-06-12 19:23:23 +02:00
|
|
|
|
|
|
|
sub top_deps {
|
|
|
|
state %deps;
|
2017-07-14 15:08:06 +02:00
|
|
|
state $my_epoch = $epoch;
|
|
|
|
if (not %deps or $my_epoch != $epoch) {
|
|
|
|
$my_epoch = $epoch;
|
2017-06-12 19:23:23 +02:00
|
|
|
my $config = slurp "rebar.config";
|
|
|
|
croak "Unable to extract floating_deps" unless $config =~ /\{floating_deps, \[(.*?)\]/s;
|
|
|
|
|
|
|
|
my $fdeps = $1;
|
|
|
|
$fdeps =~ s/\s*//g;
|
|
|
|
my %fdeps = map { $_ => 1 } split /,/, $fdeps;
|
|
|
|
%deps = %{get_deps($config, %fdeps)};
|
|
|
|
}
|
|
|
|
return {%deps, %top_deps_updates};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub update_deps_repos {
|
2017-07-14 15:08:06 +02:00
|
|
|
my ($force) = @_;
|
2017-06-12 19:23:23 +02:00
|
|
|
my $deps = top_deps();
|
2017-07-14 15:08:06 +02:00
|
|
|
$epoch++;
|
2017-06-12 19:23:23 +02:00
|
|
|
mkdir(".deps-update") unless -d ".deps-update";
|
|
|
|
for my $dep (keys %{$deps}) {
|
|
|
|
my $dd = ".deps-update/$dep";
|
|
|
|
if (not -d $dd) {
|
|
|
|
say "Downloading $dep...";
|
|
|
|
my $repo = $deps->{$dep}->{repo};
|
2017-06-28 16:47:31 +02:00
|
|
|
$repo =~ s!^https?://github.com/!git\@github.com:!;
|
2021-02-19 17:33:58 +01:00
|
|
|
system("git", "-C", ".deps-update", "clone", $repo, $dep);
|
2017-07-14 15:08:06 +02:00
|
|
|
} elsif (time() - stat($dd)->mtime > 24 * 60 * 60 or $force) {
|
2017-06-12 19:23:23 +02:00
|
|
|
say "Updating $dep...";
|
2017-06-28 16:36:59 +02:00
|
|
|
system("git", "-C", $dd, "pull");
|
2017-06-12 19:23:23 +02:00
|
|
|
touch($dd)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sub_deps {
|
|
|
|
state %sub_deps;
|
2017-07-14 15:08:06 +02:00
|
|
|
state $my_epoch = $epoch;
|
|
|
|
if (not %sub_deps or $my_epoch != $epoch) {
|
|
|
|
$my_epoch = $epoch;
|
2017-06-12 19:23:23 +02:00
|
|
|
my $deps = top_deps();
|
|
|
|
for my $dep (keys %{$deps}) {
|
|
|
|
my $rc = ".deps-update/$dep/rebar.config";
|
|
|
|
$sub_deps{$dep} = { };
|
|
|
|
next unless -f $rc;
|
|
|
|
$sub_deps{$dep} = get_deps(scalar(slurp($rc)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {%sub_deps, %sub_deps_updates};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub rev_deps_helper {
|
|
|
|
my ($rev_deps, $dep) = @_;
|
|
|
|
if (not exists $rev_deps->{$dep}->{indirect}) {
|
|
|
|
my %deps = %{$rev_deps->{$dep}->{direct} || {}};
|
|
|
|
for (keys %{$rev_deps->{$dep}->{direct}}) {
|
|
|
|
%deps = (%deps, %{rev_deps_helper($rev_deps, $_)});
|
|
|
|
}
|
|
|
|
$rev_deps->{$dep}->{indirect} = \%deps;
|
|
|
|
}
|
|
|
|
return $rev_deps->{$dep}->{indirect};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub rev_deps {
|
|
|
|
state %rev_deps;
|
2017-07-14 15:08:06 +02:00
|
|
|
state $deps_epoch = $epoch;
|
|
|
|
if (not %rev_deps or $deps_epoch != $epoch) {
|
|
|
|
$deps_epoch = $epoch;
|
2017-06-12 19:23:23 +02:00
|
|
|
my $sub_deps = sub_deps();
|
|
|
|
for my $dep (keys %$sub_deps) {
|
|
|
|
$rev_deps{$_}->{direct}->{$dep} = 1 for keys %{$sub_deps->{$dep}};
|
|
|
|
}
|
|
|
|
for my $dep (keys %$sub_deps) {
|
|
|
|
$rev_deps{$dep}->{indirect} = rev_deps_helper(\%rev_deps, $dep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return \%rev_deps;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub update_changelog {
|
|
|
|
my ($dep, $version, @reasons) = @_;
|
|
|
|
my $cl = ".deps-update/$dep/CHANGELOG.md";
|
|
|
|
return if not -f $cl;
|
|
|
|
my $reason = join "\n", map {"* $_"} @reasons;
|
|
|
|
my $content = slurp($cl);
|
|
|
|
if (not $content =~ /^# Version $version/) {
|
2017-07-20 11:43:25 +02:00
|
|
|
$content = "# Version $version\n\n$reason\n\n$content";
|
2017-06-12 19:23:23 +02:00
|
|
|
} else {
|
|
|
|
$content =~ s/(# Version $version\n\n)/$1$reason\n/;
|
|
|
|
}
|
|
|
|
write_file($cl, $content);
|
|
|
|
}
|
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
sub edit_changelog {
|
|
|
|
my ($dep, $version) = @_;
|
|
|
|
my $cl = ".deps-update/$dep/CHANGELOG.md";
|
|
|
|
|
|
|
|
return if not -f $cl;
|
|
|
|
|
|
|
|
my $top_deps = top_deps();
|
|
|
|
my $git_info = deps_git_info();
|
|
|
|
|
|
|
|
say color("red"), "$dep", color("reset"), " ($top_deps->{$dep}->{commit}):";
|
|
|
|
say " $_" for @{$git_info->{$dep}->{new_commits}};
|
|
|
|
say "";
|
|
|
|
|
|
|
|
my $content = slurp($cl);
|
|
|
|
my $old_content = $content;
|
|
|
|
|
|
|
|
if (not $content =~ /^# Version $version/) {
|
|
|
|
$content = "# Version $version\n\n* \n\n$content";
|
|
|
|
} else {
|
|
|
|
$content =~ s/(# Version $version\n\n)/$1* \n/;
|
|
|
|
}
|
|
|
|
write_file($cl, $content);
|
|
|
|
|
|
|
|
system("$ENV{EDITOR} $cl");
|
|
|
|
|
|
|
|
my $new_content = slurp($cl);
|
|
|
|
if ($new_content eq $content) {
|
|
|
|
write_file($cl, $old_content);
|
|
|
|
} else {
|
|
|
|
system("git", "-C", ".deps-update/$dep", "commit", "-a", "-m", "Update changelog");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-12 19:23:23 +02:00
|
|
|
sub update_app_src {
|
|
|
|
my ($dep, $version) = @_;
|
|
|
|
my $app = ".deps-update/$dep/src/$dep.app.src";
|
|
|
|
return if not -f $app;
|
|
|
|
my $content = slurp($app);
|
2019-02-26 11:52:00 +01:00
|
|
|
$content =~ s/(\{\s*vsn\s*,\s*)".*"/$1"$version"/;
|
2017-06-12 19:23:23 +02:00
|
|
|
write_file($app, $content);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub update_deps_versions {
|
|
|
|
my ($config_path, %deps) = @_;
|
|
|
|
my $config = slurp $config_path;
|
|
|
|
|
|
|
|
for (keys %deps) {
|
2017-06-28 16:36:59 +02:00
|
|
|
$config =~ s/(\{\s*$_\s*,\s*".*?"\s*,\s*\{\s*git\s*,\s*".*?"\s*,\s*)(?:{\s*tag\s*,\s*"(.*?)"\s*}|"(.*?)")/$1\{tag, "$deps{$_}"}/s;
|
2017-06-12 19:23:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
write_file($config_path, $config);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub cmp_ver {
|
|
|
|
my @a = split /(\d+)/, $a;
|
|
|
|
my @b = split /(\d+)/, $b;
|
|
|
|
my $is_num = 1;
|
|
|
|
|
|
|
|
return - 1 if $#a == 0;
|
|
|
|
return 1 if $#b == 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
my $ap = shift @a;
|
|
|
|
my $bp = shift @b;
|
|
|
|
$is_num = 1 - $is_num;
|
|
|
|
|
|
|
|
if (defined $ap) {
|
|
|
|
if (defined $bp) {
|
|
|
|
if ($is_num) {
|
|
|
|
next if $ap == $bp;
|
|
|
|
return 1 if $ap > $bp;
|
|
|
|
return - 1;
|
|
|
|
} else {
|
2020-12-18 16:42:41 +01:00
|
|
|
next if $ap eq $bp or $ap eq "" or $bp eq "";
|
2017-06-12 19:23:23 +02:00
|
|
|
return 1 if $ap gt $bp;
|
|
|
|
return - 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} elsif (defined $bp) {
|
|
|
|
return - 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub deps_git_info {
|
|
|
|
state %info;
|
2017-07-14 15:08:06 +02:00
|
|
|
state $my_epoch = $epoch;
|
|
|
|
if (not %info or $my_epoch != $epoch) {
|
|
|
|
$my_epoch = $epoch;
|
2017-06-12 19:23:23 +02:00
|
|
|
my $deps = top_deps();
|
|
|
|
for my $dep (keys %{$deps}) {
|
|
|
|
my $dir = ".deps-update/$dep";
|
|
|
|
my @tags = `git -C "$dir" tag`;
|
|
|
|
chomp(@tags);
|
|
|
|
@tags = sort cmp_ver @tags;
|
|
|
|
my $last_tag = $tags[$#tags];
|
|
|
|
my @new = `git -C $dir log --oneline $last_tag..origin/master`;
|
|
|
|
my $new_tag = $last_tag;
|
|
|
|
$new_tag =~ s/(\d+)$/$1+1/e;
|
|
|
|
chomp(@new);
|
2019-02-26 11:52:00 +01:00
|
|
|
|
|
|
|
my $cl = ".deps-update/$dep/CHANGELOG.md";
|
|
|
|
my $content = slurp($cl, err_mode => "quiet") // "";
|
|
|
|
if ($content =~ /^# Version (\S+)/) {
|
|
|
|
if (!grep({$_ eq $1} @tags) && $1 ne $new_tag) {
|
|
|
|
$new_tag = $1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-12 19:23:23 +02:00
|
|
|
$info{$dep} = { last_tag => $last_tag, new_commits => \@new, new_tag => $new_tag };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return { %info, %info_updates };
|
|
|
|
}
|
|
|
|
|
|
|
|
sub show_commands {
|
|
|
|
my %commands = @_;
|
|
|
|
my @keys;
|
|
|
|
while (@_) {
|
|
|
|
push @keys, shift;
|
|
|
|
shift;
|
|
|
|
}
|
|
|
|
for (@keys) {
|
|
|
|
say color("red"), $_, color("reset"), ") $commands{$_}";
|
|
|
|
}
|
|
|
|
ReadMode(4);
|
2019-02-26 11:52:00 +01:00
|
|
|
my $wkey = "";
|
2017-06-12 19:23:23 +02:00
|
|
|
while (1) {
|
|
|
|
my $key = ReadKey(0);
|
2019-02-26 11:52:00 +01:00
|
|
|
$wkey = substr($wkey.$key, -2);
|
2017-06-12 19:23:23 +02:00
|
|
|
if (defined $commands{uc($key)}) {
|
|
|
|
ReadMode(0);
|
|
|
|
say "";
|
|
|
|
return uc($key);
|
2019-02-26 11:52:00 +01:00
|
|
|
} elsif (defined $commands{uc($wkey)}) {
|
|
|
|
ReadMode(0);
|
|
|
|
say "";
|
|
|
|
return uc($wkey);
|
2017-06-12 19:23:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub schedule_operation {
|
|
|
|
my ($type, $dep, $tag, $reason, $op) = @_;
|
|
|
|
|
|
|
|
my $idx = first { $operations[$_]->{dep} eq $dep } 0..$#operations;
|
|
|
|
|
|
|
|
if (defined $idx) {
|
2017-06-14 13:59:02 +02:00
|
|
|
my $mop = $operations[$idx];
|
|
|
|
if (defined $op) {
|
|
|
|
my $oidx = first { $mop->{operations}->[$_]->[0] eq $op->[0] } 0..$#{$mop->{operations}};
|
|
|
|
if (defined $oidx) {
|
|
|
|
$mop->{reasons}->[$oidx] = $reason;
|
|
|
|
$mop->{operations}->[$oidx] = $op;
|
|
|
|
} else {
|
|
|
|
push @{$mop->{reasons}}, $reason;
|
|
|
|
push @{$mop->{operations}}, $op;
|
|
|
|
}
|
|
|
|
}
|
2017-06-12 19:23:23 +02:00
|
|
|
return if $type eq "update";
|
2017-06-14 13:59:02 +02:00
|
|
|
$mop->{type} = $type;
|
2017-06-12 19:23:23 +02:00
|
|
|
$info_updates{$dep}->{new_commits} = [];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $info = deps_git_info();
|
|
|
|
|
|
|
|
$top_deps_updates{$dep} = {commit => $tag};
|
|
|
|
$info_updates{$dep} = {last_tag => $tag, new_tag => $tag,
|
|
|
|
new_commits => $type eq "tupdate" ? [] : $info->{$dep}->{new_commits}};
|
|
|
|
|
|
|
|
my $rev_deps = rev_deps();
|
|
|
|
@operations = sort {
|
|
|
|
exists $rev_deps->{$a->{dep}}->{indirect}->{$b->{dep}} ? -1 :
|
|
|
|
exists $rev_deps->{$b->{dep}}->{indirect}->{$a->{dep}} ? 1 : $a->{dep} cmp $b->{dep}
|
|
|
|
} (@operations, {
|
|
|
|
type => $type,
|
|
|
|
dep => $dep,
|
|
|
|
version => $tag,
|
|
|
|
reasons => ($reason ? [$reason] : []),
|
|
|
|
operations => ($op ? [$op] : [])}
|
|
|
|
);
|
|
|
|
|
|
|
|
my $sub_deps = sub_deps();
|
|
|
|
|
|
|
|
for (keys %{$rev_deps->{$dep}->{direct}}) {
|
|
|
|
schedule_operation("update", $_, $info->{$_}->{new_tag}, "Updating $dep to version $tag.", [$dep, $tag]);
|
|
|
|
$sub_deps_updates{$_} = $sub_deps_updates{$_} || clone($sub_deps->{$_});
|
|
|
|
$sub_deps_updates{$_}->{$dep}->{commit} = $tag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub git_tag {
|
|
|
|
my ($dep, $ver, $msg) = @_;
|
|
|
|
|
|
|
|
system("git", "-C", ".deps-update/$dep", "commit", "-a", "-m", $msg);
|
2021-02-12 20:40:40 +01:00
|
|
|
system("git", "-C", ".deps-update/$dep", "tag", $ver, "-a", "-m", $msg);
|
2017-06-12 19:23:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub git_push {
|
|
|
|
my ($dep) = @_;
|
|
|
|
system("git", "-C", ".deps-update/$dep", "push");
|
|
|
|
system("git", "-C", ".deps-update/$dep", "push", "--tags");
|
|
|
|
}
|
|
|
|
|
2018-06-29 12:51:20 +02:00
|
|
|
sub check_hex_files {
|
|
|
|
my ($dep) = @_;
|
|
|
|
my $app = ".deps-update/$dep/src/$dep.app.src";
|
|
|
|
return if not -f $app;
|
|
|
|
my $content = slurp($app);
|
|
|
|
my @paths;
|
|
|
|
if ($content =~ /{\s*files\s*,\s*\[([^\]]+)\]/) {
|
|
|
|
my $list = $1;
|
|
|
|
push @paths, $1 while $list =~ /"([^"]*?)"/g;
|
|
|
|
} else {
|
|
|
|
@paths = (
|
|
|
|
"src", "c_src", "include", "rebar.config.script", "priv",
|
|
|
|
"rebar.config", "rebar.lock", "README*", "readme*", "LICENSE*",
|
|
|
|
"license*", "NOTICE");
|
|
|
|
}
|
|
|
|
local $CWD = ".deps-update/$dep";
|
|
|
|
my @interesting_files = map {File::Spec->canonpath($_)} glob("rebar.config* src/*.erl src/*.app.src c_src/*.c c_src/*.cpp \
|
|
|
|
c_src/*.h c_src/*.hpp include/*.hrl");
|
|
|
|
|
|
|
|
my @matching_files;
|
|
|
|
for my $path (@paths) {
|
|
|
|
if (-d $path) {
|
|
|
|
push @matching_files, map {File::Spec->canonpath($_)} glob("$path/*");
|
|
|
|
} else {
|
|
|
|
push @matching_files, map {File::Spec->canonpath($_)} glob($path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
my %diff;
|
|
|
|
@diff{ @interesting_files } = undef;
|
|
|
|
delete @diff{ @matching_files };
|
|
|
|
my @diff = keys %diff;
|
|
|
|
if (@diff) {
|
|
|
|
print color("red"), "Dependency ", color("bold red"), $dep, color("reset"), color("red"), " files section doesn't match: ",
|
|
|
|
join(" ", @diff), color("reset"), "\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-12 19:23:23 +02:00
|
|
|
update_deps_repos();
|
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
MAIN:
|
2017-06-12 19:23:23 +02:00
|
|
|
while (1) {
|
|
|
|
my $top_deps = top_deps();
|
|
|
|
my $git_info = deps_git_info();
|
|
|
|
print color("bold blue"), "Dependences with newer tags:\n", color("reset");
|
|
|
|
my $old_deps = 0;
|
|
|
|
for my $dep (sort keys %$top_deps) {
|
|
|
|
next unless $git_info->{$dep}->{last_tag} ne $top_deps->{$dep}->{commit};
|
|
|
|
say color("red"), "$dep", color("reset"), ": $top_deps->{$dep}->{commit} -> $git_info->{$dep}->{last_tag}";
|
|
|
|
$old_deps = 1;
|
|
|
|
}
|
|
|
|
say "(none)" if not $old_deps;
|
|
|
|
say "";
|
|
|
|
|
|
|
|
print color("bold blue"), "Dependences that have commits after last tags:\n", color("reset");
|
|
|
|
my $changed_deps = 0;
|
|
|
|
for my $dep (sort keys %$top_deps) {
|
|
|
|
next unless @{$git_info->{$dep}->{new_commits}};
|
|
|
|
say color("red"), "$dep", color("reset"), " ($top_deps->{$dep}->{commit}):";
|
|
|
|
say " $_" for @{$git_info->{$dep}->{new_commits}};
|
|
|
|
$changed_deps = 1;
|
|
|
|
}
|
|
|
|
say "(none)" if not $changed_deps;
|
|
|
|
say "";
|
|
|
|
|
2018-06-29 12:51:20 +02:00
|
|
|
for my $dep (sort keys %$top_deps) {
|
|
|
|
check_hex_files($dep);
|
|
|
|
}
|
|
|
|
|
2017-06-12 19:23:23 +02:00
|
|
|
my $cmd = show_commands($old_deps ? (U => "Update dependency") : (),
|
|
|
|
$changed_deps ? (T => "Tag new release") : (),
|
|
|
|
@operations ? (A => "Apply changes") : (),
|
2022-01-24 01:01:39 +01:00
|
|
|
R => "Refresh repositories",
|
2020-12-18 16:43:20 +01:00
|
|
|
H => "What release to Hex",
|
2017-06-12 19:23:23 +02:00
|
|
|
E => "Exit");
|
|
|
|
last if $cmd eq "E";
|
|
|
|
|
|
|
|
if ($cmd eq "U") {
|
|
|
|
while (1) {
|
|
|
|
my @deps_to_update;
|
|
|
|
my @od;
|
|
|
|
my $idx = 1;
|
|
|
|
for my $dep (sort keys %$top_deps) {
|
|
|
|
next unless $git_info->{$dep}->{last_tag} ne $top_deps->{$dep}->{commit};
|
|
|
|
$od[$idx] = $dep;
|
|
|
|
push @deps_to_update, $idx++, "Update $dep to $git_info->{$dep}->{last_tag}";
|
|
|
|
}
|
|
|
|
last if $idx == 1;
|
|
|
|
my $cmd = show_commands(@deps_to_update, E => "Exit");
|
|
|
|
last if $cmd eq "E";
|
|
|
|
|
|
|
|
my $dep = $od[$cmd];
|
|
|
|
schedule_operation("update", $dep, $git_info->{$dep}->{last_tag});
|
|
|
|
|
|
|
|
$top_deps = top_deps();
|
|
|
|
$git_info = deps_git_info();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-14 15:08:06 +02:00
|
|
|
if ($cmd eq "R") {
|
|
|
|
update_deps_repos(1);
|
|
|
|
}
|
2020-12-18 16:43:20 +01:00
|
|
|
if ($cmd eq "H") {
|
|
|
|
my $ua = LWP::UserAgent->new();
|
|
|
|
for my $dep (sort keys %$top_deps) {
|
|
|
|
say "checking https://hex.pm/packages/$dep/$git_info->{$dep}->{last_tag}";
|
|
|
|
my $res = $ua->head("https://hex.pm/packages/$dep/$git_info->{$dep}->{last_tag}");
|
|
|
|
if ($res->code == 404) {
|
|
|
|
say color("red"), "$dep", color("reset"), " ($top_deps->{$dep}->{commit})";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-12 19:23:23 +02:00
|
|
|
if ($cmd eq "T") {
|
|
|
|
while (1) {
|
|
|
|
my @deps_to_tag;
|
|
|
|
my @od;
|
|
|
|
my $idx = 1;
|
2019-02-26 11:52:00 +01:00
|
|
|
my $count = 0;
|
|
|
|
for my $dep (sort keys %$top_deps) {
|
|
|
|
next unless @{$git_info->{$dep}->{new_commits}};
|
|
|
|
$count++;
|
|
|
|
}
|
2017-06-12 19:23:23 +02:00
|
|
|
for my $dep (sort keys %$top_deps) {
|
|
|
|
next unless @{$git_info->{$dep}->{new_commits}};
|
|
|
|
$od[$idx] = $dep;
|
2019-02-26 11:52:00 +01:00
|
|
|
my $id = $idx++;
|
|
|
|
$id = sprintf "%02d", $id if $count > 9;
|
|
|
|
push @deps_to_tag, $id, "Tag $dep with version $git_info->{$dep}->{new_tag}";
|
2017-06-12 19:23:23 +02:00
|
|
|
}
|
|
|
|
last if $idx == 1;
|
|
|
|
my $cmd = show_commands(@deps_to_tag, E => "Exit");
|
|
|
|
last if $cmd eq "E";
|
|
|
|
|
|
|
|
my $dep = $od[$cmd];
|
|
|
|
my $d = $git_info->{$dep};
|
|
|
|
schedule_operation("tupdate", $dep, $d->{new_tag});
|
|
|
|
|
|
|
|
$top_deps = top_deps();
|
|
|
|
$git_info = deps_git_info();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
my $changelog_updated = 0;
|
2017-06-12 19:23:23 +02:00
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
if ($cmd eq "A") {
|
|
|
|
APPLY: {
|
|
|
|
$top_deps = top_deps();
|
|
|
|
$git_info = deps_git_info();
|
|
|
|
my $sub_deps = sub_deps();
|
|
|
|
|
|
|
|
for my $dep (keys %$top_deps) {
|
|
|
|
for my $sdep (keys %{$sub_deps->{$dep}}) {
|
|
|
|
next if not defined $top_deps->{$sdep} or
|
|
|
|
$sub_deps->{$dep}->{$sdep}->{commit} eq $top_deps->{$sdep}->{commit};
|
|
|
|
say "$dep $sdep ", $sub_deps->{$dep}->{$sdep}->{commit}, " <=> $sdep ",
|
|
|
|
$top_deps->{$sdep}->{commit};
|
|
|
|
schedule_operation("update", $dep, $git_info->{$dep}->{new_tag},
|
|
|
|
"Updating $sdep to version $top_deps->{$sdep}->{commit}.",
|
|
|
|
[ $sdep, $top_deps->{$sdep}->{commit} ]);
|
|
|
|
}
|
2017-06-12 19:23:23 +02:00
|
|
|
}
|
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
%info_updates = ();
|
|
|
|
%top_deps_updates = ();
|
|
|
|
%sub_deps_updates = ();
|
2017-06-12 19:23:23 +02:00
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
$top_deps = top_deps();
|
|
|
|
$git_info = deps_git_info();
|
|
|
|
$sub_deps = sub_deps();
|
2017-06-12 19:23:23 +02:00
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
print color("bold blue"), "List of operations:\n", color("reset");
|
2017-06-14 13:59:02 +02:00
|
|
|
for my $op (@operations) {
|
2017-07-20 11:43:25 +02:00
|
|
|
print color("red"), $op->{dep}, color("reset"),
|
|
|
|
" ($top_deps->{$op->{dep}}->{commit} -> $op->{version})";
|
|
|
|
if (@{$op->{operations}}) {
|
|
|
|
say ":";
|
|
|
|
say " $_->[0] -> $_->[1]" for @{$op->{operations}};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
say "";
|
2017-06-14 13:59:02 +02:00
|
|
|
}
|
2017-07-20 11:43:25 +02:00
|
|
|
}
|
2017-06-14 13:59:02 +02:00
|
|
|
|
2017-07-20 11:43:25 +02:00
|
|
|
say "";
|
|
|
|
my %to_tag;
|
|
|
|
if (not $changelog_updated) {
|
|
|
|
for my $op (@operations) {
|
|
|
|
if ($git_info->{$op->{dep}}->{last_tag} ne $op->{version}) {
|
|
|
|
$to_tag{$op->{dep}} = $op->{version};
|
|
|
|
}
|
|
|
|
}
|
2017-06-14 13:59:02 +02:00
|
|
|
}
|
2017-07-20 11:43:25 +02:00
|
|
|
my $cmd = show_commands(A => "Apply", (%to_tag ? (U => "Update Changelogs") : ()), E => "Exit");
|
|
|
|
if ($cmd eq "U") {
|
|
|
|
for my $dep (keys %to_tag) {
|
|
|
|
edit_changelog($dep, $to_tag{$dep});
|
|
|
|
}
|
|
|
|
redo APPLY;
|
|
|
|
}
|
|
|
|
elsif ($cmd eq "A") {
|
|
|
|
my %top_changes;
|
|
|
|
for my $op (@operations) {
|
|
|
|
update_changelog($op->{dep}, $op->{version}, @{$op->{reasons}})
|
|
|
|
if @{$op->{reasons}};
|
2017-11-20 10:41:52 +01:00
|
|
|
update_deps_versions(".deps-update/$op->{dep}/rebar.config", map {@{$_}[0,1] } @{$op->{operations}})
|
2017-07-20 11:43:25 +02:00
|
|
|
if @{$op->{operations}};
|
|
|
|
if ($git_info->{$op->{dep}}->{last_tag} ne $op->{version}) {
|
|
|
|
update_app_src($op->{dep}, $op->{version});
|
|
|
|
git_tag($op->{dep}, $op->{version}, "Release $op->{version}");
|
|
|
|
}
|
|
|
|
|
|
|
|
$top_changes{$op->{dep}} = $op->{version};
|
|
|
|
}
|
|
|
|
update_deps_versions("rebar.config", %top_changes);
|
|
|
|
for my $op (@operations) {
|
|
|
|
if ($git_info->{$op->{dep}}->{last_tag} ne $op->{version}) {
|
|
|
|
git_push($op->{dep});
|
|
|
|
}
|
2017-06-14 13:59:02 +02:00
|
|
|
}
|
2017-07-20 11:43:25 +02:00
|
|
|
last MAIN;
|
2017-06-12 19:23:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|