25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Show operations to perform before asking to apply them

This commit is contained in:
Paweł Chmielowski 2017-06-14 13:59:02 +02:00 committed by Paweł Chmielowski
parent 5f2dcc51ce
commit 10fcfa860a

View File

@ -52,7 +52,7 @@ sub update_deps_repos {
if (not -d $dd) { if (not -d $dd) {
say "Downloading $dep..."; say "Downloading $dep...";
my $repo = $deps->{$dep}->{repo}; my $repo = $deps->{$dep}->{repo};
$repo =~ s/^https?/git/; $repo =~ s!^https?://github/!git\@github.com:!;
system("git", "-C", ".deps-update", "clone", $repo); system("git", "-C", ".deps-update", "clone", $repo);
} elsif (time() - stat($dd)->mtime > 24 * 60 * 60) { } elsif (time() - stat($dd)->mtime > 24 * 60 * 60) {
say "Updating $dep..."; say "Updating $dep...";
@ -218,10 +218,19 @@ sub schedule_operation {
my $idx = first { $operations[$_]->{dep} eq $dep } 0..$#operations; my $idx = first { $operations[$_]->{dep} eq $dep } 0..$#operations;
if (defined $idx) { if (defined $idx) {
push @{$operations[$idx]->{reasons}}, $reason; my $mop = $operations[$idx];
push @{$operations[$idx]->{operations}}, $op; 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;
}
}
return if $type eq "update"; return if $type eq "update";
$operations[$idx]->{type} = $type; $mop->{type} = $type;
$info_updates{$dep}->{new_commits} = []; $info_updates{$dep}->{new_commits} = [];
return; return;
} }
@ -364,6 +373,20 @@ while (1) {
$git_info = deps_git_info(); $git_info = deps_git_info();
$sub_deps = sub_deps(); $sub_deps = sub_deps();
print color("bold blue"), "List of operations:\n", color("reset");
for my $op (@operations) {
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 "";
}
}
say "";
my $cmd = show_commands(A => "Apply", E => "Exit");
if ($cmd eq "A") {
my %top_changes; my %top_changes;
for my $op (@operations) { for my $op (@operations) {
update_changelog($op->{dep}, $op->{version}, @{$op->{reasons}}) update_changelog($op->{dep}, $op->{version}, @{$op->{reasons}})
@ -386,4 +409,5 @@ while (1) {
} }
last; last;
} }
}
} }