| 1 |
#!/usr/bin/env perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Path::Tiny; |
| 5 |
|
| 6 |
# ATTENTION DISTRO REPACKAGERS: do NOT use fresh copies of these files |
| 7 |
# from their source; it is important to include the original versions |
| 8 |
# of the files as they were packaged with this cpan distribution, or |
| 9 |
# surprising behaviour may occur. |
| 10 |
|
| 11 |
chomp(my $dirty = `git status --untracked --porcelain share`); |
| 12 |
!length($dirty) and die 'Cannot proceed: share/ is not dirty. Run "git submodule update --remote"'; |
| 13 |
|
| 14 |
chomp($dirty = `git status --untracked --porcelain Changes`); |
| 15 |
length($dirty) and die 'Cannot proceed: Changes is already dirty'; |
| 16 |
|
| 17 |
chomp(my $ls_tree = `git ls-tree HEAD share`); |
| 18 |
my (undef, undef, $old_sha) = split(/\s/, $ls_tree); |
| 19 |
|
| 20 |
chomp(my $status = `git submodule status`); |
| 21 |
my ($new_sha) = split(' ', $status, 2); |
| 22 |
$new_sha =~ s/^\+//; |
| 23 |
|
| 24 |
my ($remote_spec) = path('.gitmodules')->slurp_utf8 =~ m{url\s+=\s+git://(.+)\.git$}m; |
| 25 |
my $diff_link = 'https://'.$remote_spec.'/compare/'.$old_sha.'...'.$new_sha; |
| 26 |
|
| 27 |
my ($seen_next, $seen_blank); |
| 28 |
path('Changes')->edit_lines_utf8(sub { |
| 29 |
if ($seen_next ||= /^\{\{\$NEXT\}\}/ and not $seen_blank and /^$/) { |
| 30 |
s/^$/ - updated test suite:\n $diff_link\n/; |
| 31 |
$seen_blank = 1; |
| 32 |
} |
| 33 |
}); |
| 34 |
|
| 35 |
exec 'git commit -m"update test suite to latest commit" Changes share'; |