Final Class Yiisoft\YiiDevTool\Infrastructure\Changelog
| Inheritance | Yiisoft\YiiDevTool\Infrastructure\Changelog |
|---|
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| TYPES | [ 'Chg', 'Bug', 'New', 'Enh', ] | Yiisoft\YiiDevTool\Infrastructure\Changelog |
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\YiiDevTool\Infrastructure\Version $version ) | ||
| $version | Yiisoft\YiiDevTool\Infrastructure\Version | |
public function close(Version $version): void
{
$this->replaceInFile(
'/\d+\.\d+\.\d+ under development/',
$version . ' ' . date('F d, Y'),
$this->path
);
}
| public string[] getReleaseLog ( Yiisoft\YiiDevTool\Infrastructure\Version|null $version = null ) | ||
| $version | Yiisoft\YiiDevTool\Infrastructure\Version|null | |
public function getReleaseLog(?Version $version = null): array
{
return $this->splitChangelog($version?->asString());
}
| public string[] getReleaseNotes ( Yiisoft\YiiDevTool\Infrastructure\Version $version ) | ||
| $version | Yiisoft\YiiDevTool\Infrastructure\Version | |
public function getReleaseNotes(Version $version): array
{
[, $changelog] = $this->splitChangelog($version->asString());
return $changelog;
}
| public void open ( Yiisoft\YiiDevTool\Infrastructure\Version $version ) | ||
| $version | Yiisoft\YiiDevTool\Infrastructure\Version | |
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)));
}
Signup or Login in order to comment.