Skip to content

Commit 68d4d62

Browse files
authored
Merge pull request #62 from alexander-nitsche/task-update-copyright-note-on-release
Update the README.md copyright claim on release
2 parents 0acf4a3 + 1226237 commit 68d4d62

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

build/classes/ReleaseManager.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,28 @@ protected function updateReadme()
182182
if (strpos($line, "Version $this->tag") === 0) {
183183
$readmeContent .= str_replace($this->tag, $this->releaseTag, $line);
184184
$readmeState += 1;
185+
} elseif (strpos($line, 'Copyright') === 0) {
186+
$readmeContent .= preg_replace('#2011(\s*)-(\s*)[0-9]+#', '2011${1}-${2}'.date('Y'), $line, 1, $count);
187+
if ($count === 1) {
188+
$readmeState += 2;
189+
}
185190
} elseif (strpos($line, $this->tag) === 0) {
186191
$readmeContent .= str_replace($this->tag, "$changelog\n$this->tag", $line);
187-
$readmeState += 2;
192+
$readmeState += 4;
188193
} else {
189194
$readmeContent .= $line;
190195
}
191196
}
192197
file_put_contents($this->readmeFile, $readmeContent);
193198

194-
if ($readmeState < 3) {
199+
if ($readmeState < 7) {
195200
if (!($readmeState & 1)) {
196201
$errors[] = sprintf("Missing note 'Version %s' of the last release below the title.", $this->tag);
197202
}
198203
if (!($readmeState & 2)) {
204+
$errors[] = "Missing copyright claim 'Copyright &copy; 2011-{year} Martijn van der Lee.'";
205+
}
206+
if (!($readmeState & 4)) {
199207
$errors[] = sprintf("Missing changelog entry '%s: ..' from the last release.", $this->tag);
200208
}
201209
if (isset($errors)) {

tests/build/ReleaseManagerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public function delegateSucceeds()
4848
========
4949
Version 1.5.3
5050
51+
Copyright &copy; 2011-2019 Martijn van der Lee.
52+
5153
..
5254
5355
Changes
@@ -70,6 +72,8 @@ public function delegateSucceeds()
7072
========
7173
Version 1.5.4
7274
75+
Copyright &copy; 2011-'.date('Y').' Martijn van der Lee.
76+
7377
..
7478
7579
Changes
@@ -113,6 +117,8 @@ public function delegateFailsIfReadmeFormatChanges()
113117
========
114118
Version v1.5.3
115119
120+
&copy; 2011-2019 Martijn van der Lee.
121+
116122
..
117123
118124
Changes
@@ -134,6 +140,7 @@ public function delegateFailsIfReadmeFormatChanges()
134140
Could not update README.md. The format has probably changed:
135141
[
136142
"Missing note \'Version 1.5.3\' of the last release below the title.",
143+
"Missing copyright claim \'Copyright &copy; 2011-{year} Martijn van der Lee.\'",
137144
"Missing changelog entry \'1.5.3: ..\' from the last release."
138145
]
139146
Aborting.

0 commit comments

Comments
 (0)