From 1226237c7d2b012117dd504240732986ec9ffec4 Mon Sep 17 00:00:00 2001 From: Alexander Nitsche Date: Fri, 31 Mar 2023 13:28:06 +0200 Subject: [PATCH] Update the README.md copyright claim on release --- build/classes/ReleaseManager.php | 12 ++++++++++-- tests/build/ReleaseManagerTest.php | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/build/classes/ReleaseManager.php b/build/classes/ReleaseManager.php index 4ee482a..d87fc51 100644 --- a/build/classes/ReleaseManager.php +++ b/build/classes/ReleaseManager.php @@ -182,20 +182,28 @@ protected function updateReadme() if (strpos($line, "Version $this->tag") === 0) { $readmeContent .= str_replace($this->tag, $this->releaseTag, $line); $readmeState += 1; + } elseif (strpos($line, 'Copyright') === 0) { + $readmeContent .= preg_replace('#2011(\s*)-(\s*)[0-9]+#', '2011${1}-${2}'.date('Y'), $line, 1, $count); + if ($count === 1) { + $readmeState += 2; + } } elseif (strpos($line, $this->tag) === 0) { $readmeContent .= str_replace($this->tag, "$changelog\n$this->tag", $line); - $readmeState += 2; + $readmeState += 4; } else { $readmeContent .= $line; } } file_put_contents($this->readmeFile, $readmeContent); - if ($readmeState < 3) { + if ($readmeState < 7) { if (!($readmeState & 1)) { $errors[] = sprintf("Missing note 'Version %s' of the last release below the title.", $this->tag); } if (!($readmeState & 2)) { + $errors[] = "Missing copyright claim 'Copyright © 2011-{year} Martijn van der Lee.'"; + } + if (!($readmeState & 4)) { $errors[] = sprintf("Missing changelog entry '%s: ..' from the last release.", $this->tag); } if (isset($errors)) { diff --git a/tests/build/ReleaseManagerTest.php b/tests/build/ReleaseManagerTest.php index a6f9662..75f31b8 100644 --- a/tests/build/ReleaseManagerTest.php +++ b/tests/build/ReleaseManagerTest.php @@ -48,6 +48,8 @@ public function delegateSucceeds() ======== Version 1.5.3 +Copyright © 2011-2019 Martijn van der Lee. + .. Changes @@ -70,6 +72,8 @@ public function delegateSucceeds() ======== Version 1.5.4 +Copyright © 2011-'.date('Y').' Martijn van der Lee. + .. Changes @@ -113,6 +117,8 @@ public function delegateFailsIfReadmeFormatChanges() ======== Version v1.5.3 +© 2011-2019 Martijn van der Lee. + .. Changes @@ -134,6 +140,7 @@ public function delegateFailsIfReadmeFormatChanges() Could not update README.md. The format has probably changed: [ "Missing note \'Version 1.5.3\' of the last release below the title.", + "Missing copyright claim \'Copyright © 2011-{year} Martijn van der Lee.\'", "Missing changelog entry \'1.5.3: ..\' from the last release." ] Aborting.