Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions build/classes/ReleaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 &copy; 2011-{year} Martijn van der Lee.'";
}
if (!($readmeState & 4)) {
$errors[] = sprintf("Missing changelog entry '%s: ..' from the last release.", $this->tag);
}
if (isset($errors)) {
Expand Down
7 changes: 7 additions & 0 deletions tests/build/ReleaseManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function delegateSucceeds()
========
Version 1.5.3

Copyright &copy; 2011-2019 Martijn van der Lee.

..

Changes
Expand All @@ -70,6 +72,8 @@ public function delegateSucceeds()
========
Version 1.5.4

Copyright &copy; 2011-'.date('Y').' Martijn van der Lee.

..

Changes
Expand Down Expand Up @@ -113,6 +117,8 @@ public function delegateFailsIfReadmeFormatChanges()
========
Version v1.5.3

&copy; 2011-2019 Martijn van der Lee.

..

Changes
Expand All @@ -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 &copy; 2011-{year} Martijn van der Lee.\'",
"Missing changelog entry \'1.5.3: ..\' from the last release."
]
Aborting.
Expand Down