Skip to content

Commit

Permalink
#91 - Placeholder {number} does not # before Issue or PR number
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
miroslavpojer committed Oct 14, 2024
1 parent f512978 commit 4f2ccb2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions release_notes_generator/action_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions release_notes_generator/model/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 ""
Expand All @@ -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 ""
Expand Down
6 changes: 3 additions & 3 deletions tests/release_notes/model/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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()


Expand Down
14 changes: 7 additions & 7 deletions tests/release_notes/test_release_notes_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4f2ccb2

Please sign in to comment.