Skip to content

Commit c271b52

Browse files
authored
Merge pull request #413 from TheHive-Project/411-fix-changelog-linkification-script
#411 - Fix changelog linkification script
2 parents 51deb0d + d3ed49c commit c271b52

File tree

2 files changed

+65
-41
lines changed

2 files changed

+65
-41
lines changed

docs/release-notes.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,41 @@
88

99
## 2.0.0b9 (2025-02-25)
1010
### Added
11-
* [#390](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Extend CaseEndpoint with apply_case_template method by [@Kamforka](https://github.com/Kamforka) in [#391](https://github.com/TheHive-Project/TheHive4py/pull/391)
12-
* [#354](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Add case endpoint docstrings by [@Kamforka](https://github.com/Kamforka) in [#399](https://github.com/TheHive-Project/TheHive4py/pull/399)
13-
* [#355](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Add changelog to docs by [@Kamforka](https://github.com/Kamforka) in [#400](https://github.com/TheHive-Project/TheHive4py/pull/400)
11+
* [#390](https://github.com/TheHive-Project/TheHive4py/issues/390) - Extend CaseEndpoint with apply_case_template method by [@Kamforka](https://github.com/Kamforka) in [#391](https://github.com/TheHive-Project/TheHive4py/pull/391)
12+
* [#354](https://github.com/TheHive-Project/TheHive4py/issues/354) - Add case endpoint docstrings by [@Kamforka](https://github.com/Kamforka) in [#399](https://github.com/TheHive-Project/TheHive4py/pull/399)
13+
* [#355](https://github.com/TheHive-Project/TheHive4py/issues/355) - Add changelog to docs by [@Kamforka](https://github.com/Kamforka) in [#400](https://github.com/TheHive-Project/TheHive4py/pull/400)
1414
### Removed
15-
* [#398](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Remove `update_share` method from case endpoint by [@Kamforka](https://github.com/Kamforka) in [#402](https://github.com/TheHive-Project/TheHive4py/pull/402)
15+
* [#398](https://github.com/TheHive-Project/TheHive4py/issues/398) - Remove `update_share` method from case endpoint by [@Kamforka](https://github.com/Kamforka) in [#402](https://github.com/TheHive-Project/TheHive4py/pull/402)
1616
### Fixed
17-
* [#388](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Enhance session's error parse method by [@Kamforka](https://github.com/Kamforka) in [#393](https://github.com/TheHive-Project/TheHive4py/pull/393)
18-
* [#389](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Fix types.cortex.OutputAnalyzerJob by [@Kamforka](https://github.com/Kamforka) in [#392](https://github.com/TheHive-Project/TheHive4py/pull/392)
19-
* [#395](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Fix InputAnalyzerJob type and add regression test by [@JuanTecedor](https://github.com/JuanTecedor) in [#397](https://github.com/TheHive-Project/TheHive4py/pull/397)
17+
* [#388](https://github.com/TheHive-Project/TheHive4py/issues/388) - Enhance session's error parse method by [@Kamforka](https://github.com/Kamforka) in [#393](https://github.com/TheHive-Project/TheHive4py/pull/393)
18+
* [#389](https://github.com/TheHive-Project/TheHive4py/issues/389) - Fix types.cortex.OutputAnalyzerJob by [@Kamforka](https://github.com/Kamforka) in [#392](https://github.com/TheHive-Project/TheHive4py/pull/392)
19+
* [#395](https://github.com/TheHive-Project/TheHive4py/issues/395) - Fix InputAnalyzerJob type and add regression test by [@JuanTecedor](https://github.com/JuanTecedor) in [#397](https://github.com/TheHive-Project/TheHive4py/pull/397)
2020
### Other
21-
* [#386](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Use TheHive 5.4.7 in integration tests by [@Kamforka](https://github.com/Kamforka) in [#387](https://github.com/TheHive-Project/TheHive4py/pull/387)
22-
* [#354](https://github.com/TheHive-Project/TheHive4py/pull/{pr_number}) - Add case endpoint docs by [@Kamforka](https://github.com/Kamforka) in [#394](https://github.com/TheHive-Project/TheHive4py/pull/394)
21+
* [#386](https://github.com/TheHive-Project/TheHive4py/issues/386) - Use TheHive 5.4.7 in integration tests by [@Kamforka](https://github.com/Kamforka) in [#387](https://github.com/TheHive-Project/TheHive4py/pull/387)
22+
* [#354](https://github.com/TheHive-Project/TheHive4py/issues/354) - Add case endpoint docs by [@Kamforka](https://github.com/Kamforka) in [#394](https://github.com/TheHive-Project/TheHive4py/pull/394)
2323

2424

2525
**Full Changelog**: [2.0.0b8...2.0.0b9](https://github.com/TheHive-Project/TheHive4py/compare/2.0.0b8...2.0.0b9)
2626

2727
## 2.0.0b8 (2025-01-15)
2828

2929
### Added
30-
* [#376](https://github.com/TheHive-Project/TheHive4py/pull/376) - Add `Has` query filter and fix deprecations, add warning for `Contains` filter by [@JuanTecedor](https://github.com/JuanTecedor) in [#377](https://github.com/TheHive-Project/TheHive4py/pull/377)
31-
* [#374](https://github.com/TheHive-Project/TheHive4py/pull/374) - Add new endpoint to be able to manage case templates by [@Anko59](https://github.com/Anko59) in [#375](https://github.com/TheHive-Project/TheHive4py/pull/375)
30+
* [#376](https://github.com/TheHive-Project/TheHive4py/issues/376) - Add `Has` query filter and fix deprecations, add warning for `Contains` filter by [@JuanTecedor](https://github.com/JuanTecedor) in [#377](https://github.com/TheHive-Project/TheHive4py/pull/377)
31+
* [#374](https://github.com/TheHive-Project/TheHive4py/issues/374) - Add new endpoint to be able to manage case templates by [@Anko59](https://github.com/Anko59) in [#375](https://github.com/TheHive-Project/TheHive4py/pull/375)
3232

3333
### Changed
34-
* [#370](https://github.com/TheHive-Project/TheHive4py/pull/370) - Enhance cortex endpoint with additional methods and types by [@Anko59](https://github.com/Anko59) in [#371](https://github.com/TheHive-Project/TheHive4py/pull/371)
35-
* [#376](https://github.com/TheHive-Project/TheHive4py/pull/376) - Fix outdated query filters to address corresponding TheHive warnings by [@JuanTecedor](https://github.com/JuanTecedor) in [#377](https://github.com/TheHive-Project/TheHive4py/pull/377)
36-
* [#380](https://github.com/TheHive-Project/TheHive4py/pull/380) - Update case and alert endpoint types by [@Kamforka](https://github.com/Kamforka) in [#383](https://github.com/TheHive-Project/TheHive4py/pull/383)
34+
* [#370](https://github.com/TheHive-Project/TheHive4py/issues/370) - Enhance cortex endpoint with additional methods and types by [@Anko59](https://github.com/Anko59) in [#371](https://github.com/TheHive-Project/TheHive4py/pull/371)
35+
* [#376](https://github.com/TheHive-Project/TheHive4py/issues/376) - Fix outdated query filters to address corresponding TheHive warnings by [@JuanTecedor](https://github.com/JuanTecedor) in [#377](https://github.com/TheHive-Project/TheHive4py/pull/377)
36+
* [#380](https://github.com/TheHive-Project/TheHive4py/issues/380) - Update case and alert endpoint types by [@Kamforka](https://github.com/Kamforka) in [#383](https://github.com/TheHive-Project/TheHive4py/pull/383)
3737

3838
### Deprecated
39-
* [#361](https://github.com/TheHive-Project/TheHive4py/pull/361) - Add deprecation warning for python 3.8 by [@Kamforka](https://github.com/Kamforka) in [#384](https://github.com/TheHive-Project/TheHive4py/pull/384)
40-
* [#376](https://github.com/TheHive-Project/TheHive4py/pull/376) - Deprecate `Contains` query filter in favour of `Has` by [@JuanTecedor](https://github.com/JuanTecedor) in [#377](https://github.com/TheHive-Project/TheHive4py/pull/377)
39+
* [#361](https://github.com/TheHive-Project/TheHive4py/issues/361) - Add deprecation warning for python 3.8 by [@Kamforka](https://github.com/Kamforka) in [#384](https://github.com/TheHive-Project/TheHive4py/pull/384)
40+
* [#376](https://github.com/TheHive-Project/TheHive4py/issues/376) - Deprecate `Contains` query filter in favour of `Has` by [@JuanTecedor](https://github.com/JuanTecedor) in [#377](https://github.com/TheHive-Project/TheHive4py/pull/377)
4141

4242
### Other
43-
* [#362](https://github.com/TheHive-Project/TheHive4py/pull/362) - Add release.yml to better control auto generated release notes by [@Kamforka](https://github.com/Kamforka) in [#379](https://github.com/TheHive-Project/TheHive4py/pull/379)
44-
* [#372](https://github.com/TheHive-Project/TheHive4py/pull/372) - Use TheHive 5.4.5 in integration tests by [@Kamforka](https://github.com/Kamforka) in [#373](https://github.com/TheHive-Project/TheHive4py/pull/373)
45-
* [#381](https://github.com/TheHive-Project/TheHive4py/pull/381) - Use TheHive 5.4.6 in integration tests by [@Kamforka](https://github.com/Kamforka) in [#382](https://github.com/TheHive-Project/TheHive4py/pull/382)
43+
* [#362](https://github.com/TheHive-Project/TheHive4py/issues/362) - Add release.yml to better control auto generated release notes by [@Kamforka](https://github.com/Kamforka) in [#379](https://github.com/TheHive-Project/TheHive4py/pull/379)
44+
* [#372](https://github.com/TheHive-Project/TheHive4py/issues/372) - Use TheHive 5.4.5 in integration tests by [@Kamforka](https://github.com/Kamforka) in [#373](https://github.com/TheHive-Project/TheHive4py/pull/373)
45+
* [#381](https://github.com/TheHive-Project/TheHive4py/issues/381) - Use TheHive 5.4.6 in integration tests by [@Kamforka](https://github.com/Kamforka) in [#382](https://github.com/TheHive-Project/TheHive4py/pull/382)
4646

4747
### New Contributors
4848
* [@Anko59](https://github.com/Anko59) made their first contribution in [#371](https://github.com/TheHive-Project/TheHive4py/pull/371)
@@ -63,18 +63,18 @@
6363
* [TheHiveApi.case.update](https://github.com/TheHive-Project/TheHive4py/blob/b3162f695368aefe200740acebd157dfba503e23/thehive4py/endpoints/case.py#L43) method's `case` argument is going to be retired in favor of the `fields` argument to conform with other endpoints update methods.
6464

6565
### Added
66-
* [#339](https://github.com/TheHive-Project/TheHive4py/pull/339) - add codecov action by [@Kamforka](https://github.com/Kamforka) in [#342](https://github.com/TheHive-Project/TheHive4py/pull/342)
67-
* [#339](https://github.com/TheHive-Project/TheHive4py/pull/339) - add workflow trigger on merge to main by [@Kamforka](https://github.com/Kamforka) in [#343](https://github.com/TheHive-Project/TheHive4py/pull/343)
68-
* [#347](https://github.com/TheHive-Project/TheHive4py/pull/347) - Add support for Python 3.13 by [@Kamforka](https://github.com/Kamforka) in [#349](https://github.com/TheHive-Project/TheHive4py/pull/349)
69-
* [#345](https://github.com/TheHive-Project/TheHive4py/pull/345) - Add initial mkdocs page by [@Kamforka](https://github.com/Kamforka) in [#346](https://github.com/TheHive-Project/TheHive4py/pull/346)
70-
* [#301](https://github.com/TheHive-Project/TheHive4py/pull/301) - Add client, alert and api reference docs by [@Kamforka](https://github.com/Kamforka) in [#350](https://github.com/TheHive-Project/TheHive4py/pull/350)
71-
* [#340](https://github.com/TheHive-Project/TheHive4py/pull/340) - Add retry mechanism by [@Kamforka](https://github.com/Kamforka) in [#344](https://github.com/TheHive-Project/TheHive4py/pull/344)
66+
* [#339](https://github.com/TheHive-Project/TheHive4py/issues/339) - add codecov action by [@Kamforka](https://github.com/Kamforka) in [#342](https://github.com/TheHive-Project/TheHive4py/pull/342)
67+
* [#339](https://github.com/TheHive-Project/TheHive4py/issues/339) - add workflow trigger on merge to main by [@Kamforka](https://github.com/Kamforka) in [#343](https://github.com/TheHive-Project/TheHive4py/pull/343)
68+
* [#347](https://github.com/TheHive-Project/TheHive4py/issues/347) - Add support for Python 3.13 by [@Kamforka](https://github.com/Kamforka) in [#349](https://github.com/TheHive-Project/TheHive4py/pull/349)
69+
* [#345](https://github.com/TheHive-Project/TheHive4py/issues/345) - Add initial mkdocs page by [@Kamforka](https://github.com/Kamforka) in [#346](https://github.com/TheHive-Project/TheHive4py/pull/346)
70+
* [#301](https://github.com/TheHive-Project/TheHive4py/issues/301) - Add client, alert and api reference docs by [@Kamforka](https://github.com/Kamforka) in [#350](https://github.com/TheHive-Project/TheHive4py/pull/350)
71+
* [#340](https://github.com/TheHive-Project/TheHive4py/issues/340) - Add retry mechanism by [@Kamforka](https://github.com/Kamforka) in [#344](https://github.com/TheHive-Project/TheHive4py/pull/344)
7272

7373
### Changed
7474
* Patch important note sections in README by [@Kamforka](https://github.com/Kamforka) in [#337](https://github.com/TheHive-Project/TheHive4py/pull/337)
7575
* Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows by [@dependabot](https://github.com/dependabot) in [#338](https://github.com/TheHive-Project/TheHive4py/pull/338)
76-
* [#301](https://github.com/TheHive-Project/TheHive4py/pull/301) - Adjust thehive4py title's font size by [@Kamforka](https://github.com/Kamforka) in [#357](https://github.com/TheHive-Project/TheHive4py/pull/357)
77-
* [#359](https://github.com/TheHive-Project/TheHive4py/pull/359) - Upgrade test integrator to use v5.4.2 by [@Kamforka](https://github.com/Kamforka) in [#360](https://github.com/TheHive-Project/TheHive4py/pull/360)
76+
* [#301](https://github.com/TheHive-Project/TheHive4py/issues/301) - Adjust thehive4py title's font size by [@Kamforka](https://github.com/Kamforka) in [#357](https://github.com/TheHive-Project/TheHive4py/pull/357)
77+
* [#359](https://github.com/TheHive-Project/TheHive4py/issues/359) - Upgrade test integrator to use v5.4.2 by [@Kamforka](https://github.com/Kamforka) in [#360](https://github.com/TheHive-Project/TheHive4py/pull/360)
7878

7979
### New Contributors
8080
* [@dependabot](https://github.com/dependabot) made their first contribution in [#338](https://github.com/TheHive-Project/TheHive4py/pull/338)
@@ -158,7 +158,7 @@ Merged Pull Requests
158158
## 2.0.0b2 (2022-08-20)
159159

160160
### What's Changed
161-
* [#250](https://github.com/TheHive-Project/TheHive4py/pull/250) - Implement list comment methods for alerts and cases by [@Kamforka](https://github.com/Kamforka) in [#251](https://github.com/TheHive-Project/TheHive4py/pull/251)
161+
* [#250](https://github.com/TheHive-Project/TheHive4py/issues/250) - Implement list comment methods for alerts and cases by [@Kamforka](https://github.com/Kamforka) in [#251](https://github.com/TheHive-Project/TheHive4py/pull/251)
162162
* [fr] ability to manage multi valued customfields by [@Kamforka](https://github.com/Kamforka) in [#253](https://github.com/TheHive-Project/TheHive4py/pull/253)
163163

164164

@@ -168,7 +168,7 @@ Merged Pull Requests
168168
## 2.0.0b1 (2022-08-05)
169169

170170
### What's Changed
171-
* [#250](https://github.com/TheHive-Project/TheHive4py/pull/250) - Implement list comment methods for alerts and cases by [@Kamforka](https://github.com/Kamforka) in [#251](https://github.com/TheHive-Project/TheHive4py/pull/251)
171+
* [#250](https://github.com/TheHive-Project/TheHive4py/issues/250) - Implement list comment methods for alerts and cases by [@Kamforka](https://github.com/Kamforka) in [#251](https://github.com/TheHive-Project/TheHive4py/pull/251)
172172

173173

174174
**Full Changelog**: [2.0.0b0...2.0.0b1](https://github.com/TheHive-Project/TheHive4py/compare/2.0.0b0...2.0.0b1)

scripts/linkify_release_notes.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,43 @@
33
import re
44

55

6-
def replace_pr_reference(match: re.Match) -> str:
7-
pr_number = match.groups()[0]
8-
pr_link = (
9-
f" [#{pr_number}]"
10-
"(https://github.com/TheHive-Project/TheHive4py/pull/{pr_number})"
6+
def replace_wrong_issue_link(match: re.Match) -> str:
7+
issue_number = match.groups()[0]
8+
issue_link = (
9+
f" [#{issue_number}]"
10+
f"(https://github.com/TheHive-Project/TheHive4py/issues/{issue_number}) -"
1111
)
12-
print(f"Replace `{match.group()}` by `{pr_link}`")
13-
return pr_link
12+
print(f"Replace `{match.group()}` by `{issue_link}`")
13+
return issue_link
1414

1515

16-
def linkify_pr_references(release_notes: str) -> str:
17-
pr_ref_pattern = r" #(\d+)"
16+
def fix_issue_links(release_notes: str) -> str:
17+
pattern = (
18+
r"\[#(\d+)\]\(https://github\.com/TheHive-Project/TheHive4py/pull/\d+\)\s+-"
19+
)
1820
linkified_release_notes = re.sub(
19-
pattern=pr_ref_pattern,
20-
repl=replace_pr_reference,
21+
pattern=pattern,
22+
repl=replace_wrong_issue_link,
23+
string=release_notes,
24+
)
25+
return linkified_release_notes
26+
27+
28+
def replace_issue_reference(match: re.Match) -> str:
29+
issue_number = match.groups()[0]
30+
issue_link = (
31+
f" [#{issue_number}]"
32+
f"(https://github.com/TheHive-Project/TheHive4py/issues/{issue_number})"
33+
)
34+
print(f"Replace `{match.group()}` by `{issue_link}`")
35+
return issue_link
36+
37+
38+
def linkify_issue_references(release_notes: str) -> str:
39+
issue_ref_pattern = r" #(\d+)"
40+
linkified_release_notes = re.sub(
41+
pattern=issue_ref_pattern,
42+
repl=replace_issue_reference,
2143
string=release_notes,
2244
)
2345
return linkified_release_notes
@@ -107,7 +129,7 @@ def main():
107129

108130
print(f"Checking linkification in '{release_notes_path}'")
109131
linkified_release_notes = release_notes
110-
linkified_release_notes = linkify_pr_references(
132+
linkified_release_notes = linkify_issue_references(
111133
release_notes=linkified_release_notes
112134
)
113135
linkified_release_notes = linkify_pr_urls(release_notes=linkified_release_notes)
@@ -118,6 +140,8 @@ def main():
118140
release_notes=linkified_release_notes
119141
)
120142

143+
linkified_release_notes = fix_issue_links(release_notes)
144+
121145
if linkified_release_notes == release_notes:
122146
print("Nothing to do, release notes are already linkified!")
123147
return

0 commit comments

Comments
 (0)