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

Add ability to update changelog in update-deps-releases

This commit is contained in:
Paweł Chmielowski 2017-07-20 11:43:25 +02:00
parent ed17586cf0
commit b1082a96c9

View File

@ -122,13 +122,46 @@ sub update_changelog {
my $reason = join "\n", map {"* $_"} @reasons; my $reason = join "\n", map {"* $_"} @reasons;
my $content = slurp($cl); my $content = slurp($cl);
if (not $content =~ /^# Version $version/) { if (not $content =~ /^# Version $version/) {
$content = "# Version $version\n\n$reason\n\n$content" $content = "# Version $version\n\n$reason\n\n$content";
} else { } else {
$content =~ s/(# Version $version\n\n)/$1$reason\n/; $content =~ s/(# Version $version\n\n)/$1$reason\n/;
} }
write_file($cl, $content); write_file($cl, $content);
} }
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");
}
}
sub update_app_src { sub update_app_src {
my ($dep, $version) = @_; my ($dep, $version) = @_;
my $app = ".deps-update/$dep/src/$dep.app.src"; my $app = ".deps-update/$dep/src/$dep.app.src";
@ -292,6 +325,7 @@ sub git_push {
update_deps_repos(); update_deps_repos();
MAIN:
while (1) { while (1) {
my $top_deps = top_deps(); my $top_deps = top_deps();
my $git_info = deps_git_info(); my $git_info = deps_git_info();
@ -371,7 +405,10 @@ while (1) {
} }
} }
my $changelog_updated = 0;
if ($cmd eq "A") { if ($cmd eq "A") {
APPLY: {
$top_deps = top_deps(); $top_deps = top_deps();
$git_info = deps_git_info(); $git_info = deps_git_info();
my $sub_deps = sub_deps(); my $sub_deps = sub_deps();
@ -380,9 +417,11 @@ while (1) {
for my $sdep (keys %{$sub_deps->{$dep}}) { for my $sdep (keys %{$sub_deps->{$dep}}) {
next if not defined $top_deps->{$sdep} or next if not defined $top_deps->{$sdep} or
$sub_deps->{$dep}->{$sdep}->{commit} eq $top_deps->{$sdep}->{commit}; $sub_deps->{$dep}->{$sdep}->{commit} eq $top_deps->{$sdep}->{commit};
say "$dep $sdep ",$sub_deps->{$dep}->{$sdep}->{commit}," <=> $sdep ",$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}, schedule_operation("update", $dep, $git_info->{$dep}->{new_tag},
"Updating $sdep to version $top_deps->{$sdep}->{commit}.", [$sdep, $top_deps->{$sdep}->{commit}]); "Updating $sdep to version $top_deps->{$sdep}->{commit}.",
[ $sdep, $top_deps->{$sdep}->{commit} ]);
} }
} }
@ -396,18 +435,34 @@ while (1) {
print color("bold blue"), "List of operations:\n", color("reset"); print color("bold blue"), "List of operations:\n", color("reset");
for my $op (@operations) { for my $op (@operations) {
print color("red"), $op->{dep}, color("reset"), " ($top_deps->{$op->{dep}}->{commit} -> $op->{version})"; print color("red"), $op->{dep}, color("reset"),
" ($top_deps->{$op->{dep}}->{commit} -> $op->{version})";
if (@{$op->{operations}}) { if (@{$op->{operations}}) {
say ":"; say ":";
say " $_->[0] -> $_->[1]" for @{$op->{operations}}; say " $_->[0] -> $_->[1]" for @{$op->{operations}};
} else { }
else {
say ""; say "";
} }
} }
say ""; say "";
my $cmd = show_commands(A => "Apply", E => "Exit"); my %to_tag;
if ($cmd eq "A") { if (not $changelog_updated) {
for my $op (@operations) {
if ($git_info->{$op->{dep}}->{last_tag} ne $op->{version}) {
$to_tag{$op->{dep}} = $op->{version};
}
}
}
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; 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}})
@ -427,7 +482,8 @@ while (1) {
git_push($op->{dep}); git_push($op->{dep});
} }
} }
last; last MAIN;
}
} }
} }
} }