Skip to content

Commit 38855ed

Browse files
committed
Auto-linking of issues and usernames in CHANGELOG during the build
1 parent ca1e2fc commit 38855ed

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

CHANGELOG.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Nothing yet
1414

1515
## 1.2.4 - 2025-06-16
1616
### Fixed
17-
- The key of a scalar value after a compound value is lost (#125). Thanks [@smiletoeverybody](https://github.com/smiletoeverybody)
17+
- The key of a scalar value after a compound value is lost ([#125](https://github.com/halaxa/json-machine/issues/125)). Thanks [@smiletoeverybody](https://github.com/smiletoeverybody)
1818

1919
<br>
2020

@@ -27,14 +27,14 @@ Standard parsing speed boost (non-recursive, non-debug) about + 50 %. Further im
2727

2828
## 1.2.2 - 2025-04-30
2929
### Changed
30-
- Leaner release package (#124). Thanks [@robotomarvin](https://github.com/robotomarvin)
30+
- Leaner release package ([#124](https://github.com/halaxa/json-machine/issues/124)). Thanks [@robotomarvin](https://github.com/robotomarvin)
3131

3232
<br>
3333

3434
## 1.2.1 - 2025-04-25
3535
### Fixed
36-
- File autoloading without composer (#122). Thanks [@bahco](https://github.com/bahco)
37-
- Crash on `null` value in `RecursiveItems` (#119). Thanks [@bark92](https://github.com/bark92)
36+
- File autoloading without composer ([#122](https://github.com/halaxa/json-machine/issues/122)). Thanks [@bahco](https://github.com/bahco)
37+
- Crash on `null` value in `RecursiveItems` ([#119](https://github.com/halaxa/json-machine/issues/119)). Thanks [@bark92](https://github.com/bark92)
3838
<br>
3939

4040
## 1.2.0 - 2024-11-24
@@ -48,7 +48,7 @@ Standard parsing speed boost (non-recursive, non-debug) about + 50 %. Further im
4848
- Support for PHP 8.4
4949
- Exception on misspelled option name suggests a correct one.
5050
### Fixed
51-
- Wrong key when combining list and scalar value pointers (#110). Thanks [@daniel-sc](https://github.com/daniel-sc)
51+
- Wrong key when combining list and scalar value pointers ([#110](https://github.com/halaxa/json-machine/issues/110)). Thanks [@daniel-sc](https://github.com/daniel-sc)
5252
### Removed
5353
- Removed support for PHP 7.0, 7.1
5454
<br>
@@ -59,13 +59,13 @@ Standard parsing speed boost (non-recursive, non-debug) about + 50 %. Further im
5959
- Support for PHP 8.3
6060
- Added PHPStan to build pipeline
6161
### Fixed
62-
- Fixed the case when non-intersecting pointers were considered intersecting (#106). Thanks [@XedinUnknown](https://github.com/XedinUnknown)
62+
- Fixed the case when non-intersecting pointers were considered intersecting ([#106](https://github.com/halaxa/json-machine/issues/106)). Thanks [@XedinUnknown](https://github.com/XedinUnknown)
6363

6464
<br>
6565

6666
## 1.1.3 - 2022-10-12
6767
### Fixed
68-
- Fix the parsing of nested sub-trees that use wildcards (#83). Thanks [@cerbero90](https://github.com/cerbero90)
68+
- Fix the parsing of nested sub-trees that use wildcards ([#83](https://github.com/halaxa/json-machine/issues/83)). Thanks [@cerbero90](https://github.com/cerbero90)
6969

7070
<br>
7171

@@ -74,8 +74,8 @@ Standard parsing speed boost (non-recursive, non-debug) about + 50 %. Further im
7474
- PHP 8.2 support
7575

7676
### Fixed
77-
- Meaningful error on invalid token. (#86)
78-
- Added missing return type annotation. (#84)
77+
- Meaningful error on invalid token. ([#86](https://github.com/halaxa/json-machine/issues/86))
78+
- Added missing return type annotation. ([#84](https://github.com/halaxa/json-machine/issues/84))
7979

8080
<br>
8181

@@ -174,7 +174,7 @@ https://stackoverflow.com/questions/63706550
174174

175175
## 0.6.1
176176
### Fixed bugs
177-
- Empty dict at the end of an item was causing Syntax error in the next item. Reason: closing `}` did not set object key expectation to `false`. (#41 via PR #42).
177+
- Empty dict at the end of an item was causing Syntax error in the next item. Reason: closing `}` did not set object key expectation to `false`. ([#41](https://github.com/halaxa/json-machine/issues/41) via PR [#42](https://github.com/halaxa/json-machine/issues/42)).
178178

179179
<br>
180180

build/update-changelog.php

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,42 @@
1111
exit(1);
1212
}
1313

14-
$releaseDate = date('Y-m-d');
15-
$changelogMatch = '## master';
16-
$changelogReplace = "$changelogMatch
14+
$changelogContents = addReleaseHeading($changelogContents, $version);
15+
$changelogContents = linkifyUsernames($changelogContents);
16+
$changelogContents = linkifyIssues($changelogContents);
17+
18+
file_put_contents($changelogPath, $changelogContents);
19+
20+
21+
22+
function addReleaseHeading(string $changelogContents, $version): string
23+
{
24+
$releaseDate = date('Y-m-d');
25+
$changelogMatch = '## master';
26+
$changelogReplace = "$changelogMatch
1727
Nothing yet
1828
1929
<br>
2030
2131
## $version - $releaseDate";
2232

23-
file_put_contents($changelogPath, str_replace($changelogMatch, $changelogReplace, $changelogContents));
33+
return str_replace($changelogMatch, $changelogReplace, $changelogContents);
34+
}
35+
36+
function linkifyUsernames(string $changelogContents): string
37+
{
38+
return preg_replace(
39+
'/([^\[]\s*)@([a-zA-Z-]+)(\s*[^\]])/',
40+
'$1[@$2](https://github.com/$2)$3',
41+
$changelogContents
42+
);
43+
}
44+
45+
function linkifyIssues(string $changelogContents): string
46+
{
47+
return preg_replace(
48+
'/([^\[]\s*)#(\d+)(\s*[^\]])/',
49+
'$1[#$2](https://github.com/halaxa/json-machine/issues/$2)$3',
50+
$changelogContents
51+
);
52+
}

0 commit comments

Comments
 (0)