diff options
author | Yves Orton <demerphq@gmail.com> | 2023-03-11 18:39:39 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-03-14 20:09:25 +0800 |
commit | 801c406dcd5a9fb54b1bd7963e65cce5ca0abfde (patch) | |
tree | 37a18b2a8166ee189b982e990ab8f200e80be0ab /Porting | |
parent | ebe383d6a79112134a70899dc806e75866bfddee (diff) | |
download | perl-801c406dcd5a9fb54b1bd7963e65cce5ca0abfde.tar.gz |
Porting/cmpVERSION.pl - handle missing tags more gracefully
Today Mauke had a surprise where he was on the latest commit but
cmp_version.t kept failing. It turned out that his personal github
clone was missing the most recent tags, and thus confusing the test.
Since we now release a new tag monthly we can detect that this is
happening and skip the test with some helpful diagnositcs on how
to fix it.
Diffstat (limited to 'Porting')
-rwxr-xr-x | Porting/cmpVERSION.pl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Porting/cmpVERSION.pl b/Porting/cmpVERSION.pl index 6c805136e3..9686a25725 100755 --- a/Porting/cmpVERSION.pl +++ b/Porting/cmpVERSION.pl @@ -82,6 +82,29 @@ unless ($tag_exists eq $tag_to_compare) { exit 0; } +my $commit_epoch = `git log -1 --format="%ct"`; +chomp($commit_epoch); +my $tag_epoch = `git for-each-ref --format="%(taggerdate:unix)" refs/tags/$tag_to_compare`; +chomp($tag_epoch); +if ($commit_epoch - $tag_epoch > 60 * 24 * 60 * 60) { + my $months = sprintf "%.2f", ($commit_epoch - $tag_epoch) / (30 * 24 * 60 * 60); + my $message= + "Tag '$tag_to_compare' is very old compared to the most recent commit.\n" + . "We normally release a new version every month, and this one is $months months\n" + . "older than the current commit. You probably have not synchronized your tags.\n" + . "This is common with github clones. You can try the following:\n" + . "\n" + . " git remote add -f upstream git\@github.com:Perl/perl5.git\n" + . "\n" + . "to fix your checkout.\n"; + die "$0: $message" unless $tap; + $message= "$message"; + $message=~s/^/# /mg; + print STDERR "\n$message"; + print "1..0 # SKIP: Tag '$tag_to_compare' is $months months old. Update your tags!\n"; + exit 0; +} + my %upstream_files; if ($exclude_upstream) { unshift @INC, 'Porting'; |