#!/usr/bin/env perl use strict; use warnings; use Path::Tiny; # ATTENTION DISTRO REPACKAGERS: do NOT use fresh copies of these files # from their source; it is important to include the original versions # of the files as they were packaged with this cpan distribution, or # surprising behaviour may occur. chomp(my $dirty = `git status --untracked --porcelain share`); !length($dirty) and die 'Cannot proceed: share/ is not dirty. Run "git submodule update --remote"'; chomp($dirty = `git status --untracked --porcelain Changes`); length($dirty) and die 'Cannot proceed: Changes is already dirty'; chomp(my $ls_tree = `git ls-tree HEAD share`); my (undef, undef, $old_sha) = split(/\s/, $ls_tree); chomp(my $status = `git submodule status`); my ($new_sha) = split(' ', $status, 2); $new_sha =~ s/^\+//; my ($remote_spec) = path('.gitmodules')->slurp_utf8 =~ m{url\s+=\s+git://(.+)\.git$}m; my $diff_link = 'https://'.$remote_spec.'/compare/'.$old_sha.'...'.$new_sha; my ($seen_next, $seen_blank); path('Changes')->edit_lines_utf8(sub { if ($seen_next ||= /^\{\{\$NEXT\}\}/ and not $seen_blank and /^$/) { s/^$/ - updated test suite:\n $diff_link\n/; $seen_blank = 1; } }); exec 'git commit -m"update test suite to latest commit" Changes share';