From 4f2ccb224326683d1805fa8b819e2fcd9453db46 Mon Sep 17 00:00:00 2001 From: miroslavpojer Date: Mon, 14 Oct 2024 08:56:07 +0200 Subject: [PATCH] #91 - Placeholder {number} does not # before Issue or PR number - Removed the need to provide # in template of row - for record number. - Update of pull-request to GitHub link type. Removed Markdown format of link. --- README.md | 6 +++--- action.yml | 8 ++++---- release_notes_generator/action_inputs.py | 4 ++-- release_notes_generator/model/record.py | 8 ++++---- tests/release_notes/model/test_record.py | 6 +++--- tests/release_notes/test_release_notes_builder.py | 14 +++++++------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 265ac47e..a8df4fdf 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,12 @@ Generate Release Notes action is dedicated to enhance the quality and organizati ### `row-format-issue` - **Description**: The format of the row for the issue in the release notes. The format can contain placeholders for the issue `number`, `title`, and issues `pull-requests`. The placeholders are case-sensitive. - **Required**: No -- **Default**: `#{number} _{title}_ in {pull-requests}"` +- **Default**: `"{number} _{title}_ in {pull-requests}"` ### `row-format-pr` -- **Description**: The format of the row for the PR in the release notes. The format can contain placeholders for the PR `number`, `title`, and PR `pull-requests`. The placeholders are case-sensitive. +- **Description**: The format of the row for the PR in the release notes. The format can contain placeholders for the PR `number`, and `title`. The placeholders are case-sensitive. - **Required**: No -- **Default**: `#{number} _{title}_"` +- **Default**: `"{number} _{title}_"` ### `row-format-link-pr` - **Description**: If defined `true`, the PR row will begin with a `"PR: "` string. Otherwise, no prefix will be added. diff --git a/action.yml b/action.yml index c531a99a..1148a14e 100644 --- a/action.yml +++ b/action.yml @@ -56,13 +56,13 @@ inputs: required: false default: 'false' row-format-issue: - description: 'Format of the issue row in the release notes. Available placeholders: {link}, {title}, {pull-requests}. Placeholders are case-insensitive.' + description: 'Format of the issue row in the release notes. Available placeholders: {number}, {title}, {pull-requests}. Placeholders are case-insensitive.' required: false - default: '#{number} _{title}_ in {pull-requests}' + default: '{number} _{title}_ in {pull-requests}' row-format-pr: - description: 'Format of the pr row in the release notes. Available placeholders: {link}, {title}, {pull-requests}. Placeholders are case-insensitive.' + description: 'Format of the pr row in the release notes. Available placeholders: {number}, {title}, {pull-requests}. Placeholders are case-insensitive.' required: false - default: '#{number} _{title}_' + default: '{number} _{title}_' row-format-link-pr: description: 'Add prefix "PR:" before link to PR when not linked an Issue.' required: false diff --git a/release_notes_generator/action_inputs.py b/release_notes_generator/action_inputs.py index 519b689d..a650c3bb 100644 --- a/release_notes_generator/action_inputs.py +++ b/release_notes_generator/action_inputs.py @@ -167,14 +167,14 @@ def get_row_format_issue() -> str: """ Get the issue row format for the release notes. """ - return get_action_input(ROW_FORMAT_ISSUE, "#{number} _{title}_ in {pull-requests}").strip() + return get_action_input(ROW_FORMAT_ISSUE, "{number} _{title}_ in {pull-requests}").strip() @staticmethod def get_row_format_pr() -> str: """ Get the pr row format for the release notes. """ - return get_action_input(ROW_FORMAT_PR, "#{number} _{title}_").strip() + return get_action_input(ROW_FORMAT_PR, "{number} _{title}_").strip() @staticmethod def get_row_format_link_pr() -> bool: diff --git a/release_notes_generator/model/record.py b/release_notes_generator/model/record.py index f53236f7..ec2d7bdc 100644 --- a/release_notes_generator/model/record.py +++ b/release_notes_generator/model/record.py @@ -211,8 +211,8 @@ def pr_links(self) -> Optional[str]: if len(self.__pulls) == 0: return None - template = "[#{number}](https://github.com/{full_name}/pull/{number})" - res = [template.format(number=pull.number, full_name=self.__repo.full_name) for pull in self.__pulls] + template = "#{number}" + res = [template.format(number=pull.number) for pull in self.__pulls] return ", ".join(res) @@ -280,7 +280,7 @@ def to_chapter_row(self) -> str: if self.__gh_issue is None: p = self.__pulls[0] - format_values["number"] = p.number + format_values["number"] = f"#{p.number}" format_values["title"] = p.title format_values["authors"] = self.authors if self.authors is not None else "" format_values["contributors"] = self.contributors if self.contributors is not None else "" @@ -289,7 +289,7 @@ def to_chapter_row(self) -> str: row = f"{row_prefix}{pr_prefix}" + ActionInputs.get_row_format_pr().format(**format_values) else: - format_values["number"] = self.__gh_issue.number + format_values["number"] = f"#{self.__gh_issue.number}" format_values["title"] = self.__gh_issue.title format_values["pull-requests"] = self.pr_links if len(self.__pulls) > 0 else "" format_values["authors"] = self.authors if self.authors is not None else "" diff --git a/tests/release_notes/model/test_record.py b/tests/release_notes/model/test_record.py index 14c2b9db..d7df6ee3 100644 --- a/tests/release_notes/model/test_record.py +++ b/tests/release_notes/model/test_record.py @@ -100,7 +100,7 @@ def test_pr_contains_issue_mentions(record_with_no_issue_one_pull_closed, mocker def test_pr_links(record_with_no_issue_one_pull_closed): - expected_links = "[#123](https://github.com/org/repo/pull/123)" + expected_links = "#123" assert record_with_no_issue_one_pull_closed.pr_links == expected_links @@ -152,7 +152,7 @@ def test_to_chapter_row_with_pull_no_pr_prefix(record_with_no_issue_one_pull_clo def test_to_chapter_row_with_issue(record_with_issue_closed_one_pull): - expected_row = """#121 _Fix the bug_ in [#123](https://github.com/org/repo/pull/123) + expected_row = """#121 _Fix the bug_ in #123 - Fixed bug - Improved performance + More nice code @@ -166,7 +166,7 @@ def test_to_chapter_row_with_pull_no_rls_notes(record_with_no_issue_one_pull_clo def test_to_chapter_row_with_issue_no_rls_notes(record_with_issue_closed_one_pull_no_rls_notes): - expected_row = "#121 _Fix the bug_ in [#123](https://github.com/org/repo/pull/123)" + expected_row = "#121 _Fix the bug_ in #123" assert expected_row == record_with_issue_closed_one_pull_no_rls_notes.to_chapter_row() diff --git a/tests/release_notes/test_release_notes_builder.py b/tests/release_notes/test_release_notes_builder.py index 8959d87a..aeb57a55 100644 --- a/tests/release_notes/test_release_notes_builder.py +++ b/tests/release_notes/test_release_notes_builder.py @@ -138,7 +138,7 @@ def __init__(self, name): RELEASE_NOTES_NO_DATA_NO_EMPTY_CHAPTERS = RELEASE_NOTES_NO_DATA_NO_WARNING_NO_EMPTY_CHAPTERS RELEASE_NOTES_DATA_CUSTOM_CHAPTERS_ONE_LABEL = """### Chapter 1 🛠 -- #122 _I1+bug_ in [#101](https://github.com/org/repo/pull/101), [#102](https://github.com/org/repo/pull/102) +- #122 _I1+bug_ in #101, #102 - PR 101 1st release note - PR 101 2nd release note - PR 102 1st release note @@ -149,7 +149,7 @@ def __init__(self, name): """ RELEASE_NOTES_DATA_CUSTOM_CHAPTERS_MORE_LABELS_DUPLICITY_REDUCTION_ON = """### Chapter 1 🛠 -- #122 _I1+bug-enhancement_ in [#101](https://github.com/org/repo/pull/101), [#102](https://github.com/org/repo/pull/102) +- #122 _I1+bug-enhancement_ in #101, #102 - PR 101 1st release note - PR 101 2nd release note - PR 102 1st release note @@ -160,7 +160,7 @@ def __init__(self, name): """ RELEASE_NOTES_DATA_CUSTOM_CHAPTERS_MORE_LABELS_DUPLICITY_REDUCTION_OFF = """### New Features 🎉 -- #1 _I1+0PR+2L-bug-enhancement_ in [#101](https://github.com/org/repo/pull/101), [#102](https://github.com/org/repo/pull/102) +- #1 _I1+0PR+2L-bug-enhancement_ in #101, #102 - PR 101 1st release note - PR 101 2nd release note - PR 102 1st release note @@ -204,7 +204,7 @@ def __init__(self, name): """ RELEASE_NOTES_DATA_SERVICE_CHAPTERS_OPEN_ISSUE_AND_MERGED_PR_NO_USER_LABELS = """### Merged PRs Linked to 'Not Closed' Issue ⚠️ -- #122 _I1 open_ in [#101](https://github.com/org/repo/pull/101), [#102](https://github.com/org/repo/pull/102) +- #122 _I1 open_ in #101, #102 - PR 101 1st release note - PR 101 2nd release note - PR 102 1st release note @@ -233,7 +233,7 @@ def __init__(self, name): """ RELEASE_NOTES_DATA_CLOSED_ISSUE_WITH_PR_WITHOUT_USER_LABELS = """### Closed Issues without User Defined Labels ⚠️ -- #122 _I1_ in [#101](https://github.com/org/repo/pull/101), [#102](https://github.com/org/repo/pull/102) +- #122 _I1_ in #101, #102 - PR 101 1st release note - PR 101 2nd release note - PR 102 1st release note @@ -274,7 +274,7 @@ def __init__(self, name): """ RELEASE_NOTES_DATA_CLOSED_ISSUE_WITH_MERGED_PRS_WITHOUT_USER_LABELS = """### Closed Issues without User Defined Labels ⚠️ -- #121 _Fix the bug_ in [#123](https://github.com/org/repo/pull/123) +- #121 _Fix the bug_ in #123 - Fixed bug - Improved performance + More nice code @@ -285,7 +285,7 @@ def __init__(self, name): """ RELEASE_NOTES_DATA_CLOSED_ISSUE_WITH_MERGED_PRS_WITH_USER_LABELS = """### Chapter 1 🛠 -- #122 _I1+bug_ in [#123](https://github.com/org/repo/pull/123) +- #122 _I1+bug_ in #123 - Fixed bug - Improved performance