Final Class Yiisoft\YiiDevTool\Infrastructure\Changelog
| Inheritance | Yiisoft\ |
|---|
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| TYPES | [ 'Chg', 'Bug', 'New', 'Enh', ] | Yiisoft\ |
Method Details
| public mixed __construct ( string $path ) | ||
| $path | string | |
public function __construct(private string $path) {}
| public void addEntry ( string $text ) | ||
| $text | string | |
public function addEntry(string $text): void
{
$replaces = $this->replaceInFile(
'/^(## \d+\.\d+\.\d+ under development\n)\n(?:- no changes in this release\.|- Initial release\.)$/m' ,
<<<MARKDOWN
$1
- $text
MARKDOWN,
$this->path,
);
if ($replaces === 0) {
$this->replaceInFile(
'/^(##\s\d+\.\d+\.\d+\sunder\sdevelopment\n)$/m',
<<<MARKDOWN
$1
- $text
MARKDOWN,
$this->path,
);
}
}
| public void close ( Yiisoft\ | ||
| $version | Yiisoft\ |
|
public function close(Version $version): void
{
$this->replaceInFile(
'/\d+\.\d+\.\d+ under development/' ,
$version . ' ' . date('F d, Y'),
$this->path,
);
}
| public array{list | ||
| $version | ?\ |
|
public function getReleaseLog(?Version $version = null): array
{
return $this->splitChangelog($version?->asString());
}
| public list | ||
| $version | Yiisoft\ |
|
public function getReleaseNotes(Version $version): array
{
[, $changelog] = $this->splitChangelog($version->asString());
return $changelog;
}
| public void open ( Yiisoft\ | ||
| $version | Yiisoft\ |
|
public function open(Version $version): void
{
$headline = "## $version under development\n" ;
$headline .= "\n- no changes in this release.\n" ;
$lines = explode("\n" , file_get_contents($this->path));
$hl = [
array_shift($lines),
array_shift($lines),
];
array_unshift($lines, $headline);
file_put_contents($this->path, implode("\n" , [...$hl, ...$lines]));
}
| public void resort ( ) |
public function resort(): void
{
// split the file into relevant parts
[$start, $rawChangelog, $end] = $this->splitChangelog();
$changelog = [];
foreach ($rawChangelog as $i => $line) {
$line = rtrim($line);
if ($line === '') {
continue;
}
if (preg_match('/^- (New|Chg|Enh|Bug)( #\d+(, #\d+)*)?: .+/' , $line, $m)) {
$o = ['New' => 'C', 'Chg' => 'D', 'Enh' => 'E', 'Bug' => 'F'];
$key = $o[$m[1]] . ' ' . (!empty($m[2]) ? $m[2] : 'AAAA') . $i;
} else {
$key = 'B' . $i;
}
$changelog[$key] = $line;
}
ksort($changelog);
file_put_contents($this->path, implode("\n" , array_merge($start, $changelog, $end)));
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.