Skip to content

Commit f90b8dc

Browse files
authored
feat(parsers): enable parsers to identify linked issues on a commit (#1109)
* refactor(parsers): add parser option validation to commit parsing * docs(api-parsers): add option documentation to parser options * feat(parsers): add `other_allowed_tags` option for commit parser options * feat(parser-custom): enable custom parsers to identify linked issues on a commit * test(parser-angular): add unit tests to verify parsing of issue numbers * test(parser-emoji): add unit tests to verify parsing of issue numbers * test(parser-scipy): add unit tests to verify parsing of issue numbers * fix(util): prevent git footers from being collapsed during parse * feat(parser-angular): automatically parse angular issue footers from commit messages * feat(parser-emoji): parse issue reference footers from commit messages * docs(commit-parsing): improve & expand commit parsing w/ parser descriptions * docs(changelog-templates): update examples using new `commit.linked_issues` attribute * chore(docs): update documentation configuration for team publishing
1 parent 4fde30e commit f90b8dc

File tree

19 files changed

+1749
-457
lines changed

19 files changed

+1749
-457
lines changed

docs/automatic-releases/github-actions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ outlines each supported input and its purpose.
7171
.. _gh_actions-psr-inputs-build:
7272

7373
``build``
74-
""""""""
74+
"""""""""
7575

7676
**Type:** ``Literal["true", "false"]``
7777

@@ -438,7 +438,7 @@ and any actions that were taken.
438438
.. _gh_actions-psr-outputs-is_prerelease:
439439

440440
``is_prerelease``
441-
""""""""""""""""
441+
"""""""""""""""""
442442

443443
**Type:** ``Literal["true", "false"]``
444444

docs/changelog_templates.rst

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ author, you are free to customize how these are presented in the rendered templa
557557

558558
.. note::
559559
If you are using a custom commit parser following the guide at
560-
:ref:`commit-parser-writing-your-own-parser`, your custom implementations of
560+
:ref:`commit_parser-custom_parser`, your custom implementations of
561561
:py:class:`ParseResult <semantic_release.commit_parser.token.ParseResult>`,
562562
:py:class:`ParseError <semantic_release.commit_parser.token.ParseError>`
563563
and :py:class:`ParsedCommit <semantic_release.commit_parser.token.ParsedCommit>`
@@ -569,7 +569,7 @@ are of type :py:class:`Version <semantic_release.version.version.Version>`. You
569569
use the ``as_tag()`` method to render these as the Git tag that they correspond to
570570
inside your template.
571571

572-
A :py:class:`Release <semantic_release.changelog.release_history.Release>`object
572+
A :py:class:`Release <semantic_release.changelog.release_history.Release>` object
573573
has an ``elements`` attribute, which has the same structure as the ``unreleased``
574574
attribute of a
575575
:py:class:`ReleaseHistory <semantic_release.changelog.release_history.ReleaseHistory>`;
@@ -592,7 +592,8 @@ type, it's recommended to use Jinja's
592592
`dictsort <https://jinja.palletsprojects.com/en/3.1.x/templates/#jinja-filters.dictsort>`_
593593
filter.
594594

595-
Each ``Release`` object also has the following attributes:
595+
Each :py:class:`Release <semantic_release.changelog.release_history.Release>`
596+
object also has the following attributes:
596597

597598
* ``tagger: git.Actor``: The tagger who tagged the release.
598599

@@ -601,8 +602,8 @@ Each ``Release`` object also has the following attributes:
601602
* ``tagged_date: datetime``: The date and time at which the release was tagged.
602603

603604
.. seealso::
604-
* :ref:`commit-parser-builtin`
605-
* :ref:`Commit Parser Tokens <commit-parser-tokens>`
605+
* :ref:`commit_parser-builtin`
606+
* :ref:`Commit Parser Tokens <commit_parser-tokens>`
606607
* `git.Actor <https://gitpython.readthedocs.io/en/stable/reference.html#git.objects.util.Actor>`_
607608
* `datetime.strftime Format Codes <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes>`_
608609

@@ -632,6 +633,8 @@ The filters provided vary based on the VCS configured and available features:
632633
633634
{{ "This is a long string that needs to be wrapped to a specific width" | autofit_text_width(40, 4) }}
634635
636+
**Markdown Output:**
637+
635638
.. code:: markdown
636639
637640
This is a long string that needs to be
@@ -669,6 +672,8 @@ The filters provided vary based on the VCS configured and available features:
669672
{{ "example/repo.git" | create_server_url }}
670673
{{ "example/repo" | create_server_url(None, "results=1", "section-header") }}
671674
675+
**Markdown Output:**
676+
672677
.. code:: markdown
673678
674679
https://example.com/example/repo.git
@@ -690,6 +695,8 @@ The filters provided vary based on the VCS configured and available features:
690695
{{ "releases/tags/v1.0.0" | create_repo_url }}
691696
{{ "issues" | create_repo_url("q=is%3Aissue+is%3Aclosed") }}
692697
698+
**Markdown Output:**
699+
693700
.. code:: markdown
694701
695702
https://example.com/example/repo/releases/tags/v1.0.0
@@ -706,6 +713,8 @@ The filters provided vary based on the VCS configured and available features:
706713
707714
{{ commit.hexsha | commit_hash_url }}
708715
716+
**Markdown Output:**
717+
709718
.. code:: markdown
710719
711720
https://example.com/example/repo/commit/a1b2c3d435657f5d339ba10c7b1ed81b460af51d
@@ -722,13 +731,15 @@ The filters provided vary based on the VCS configured and available features:
722731
723732
{{ "v1.0.0" | compare_url("v1.1.0") }}
724733
734+
**Markdown Output:**
735+
725736
.. code:: markdown
726737
727738
https://example.com/example/repo/compare/v1.0.0...v1.1.0
728739
729740
* ``issue_url (Callable[[IssueNumStr | IssueNumInt], UrlStr])``: given an issue
730741
number, return a URL to the issue on the remote vcs. In v9.12.2, this filter
731-
was updated to handle a string that has leading prefix symbols (ex. ``#29``)
742+
was updated to handle a string that has leading prefix symbols (ex. ``#32``)
732743
and will strip the prefix before generating the URL.
733744

734745
*Introduced in v9.6.0, Modified in v9.12.2.*
@@ -737,11 +748,19 @@ The filters provided vary based on the VCS configured and available features:
737748

738749
.. code:: jinja
739750
740-
{{ "29" | issue_url }}
751+
{# Add Links to issues annotated in the commit message
752+
# NOTE: commit.linked_issues is only available in v9.15.0 or greater
753+
#
754+
#}{% for issue_ref in commit.linked_issues
755+
%}{{ "- [%s](%s)" | format(issue_ref, issue_ref | issue_url)
756+
}}{% endfor
757+
%}
758+
759+
**Markdown Output:**
741760

742761
.. code:: markdown
743762
744-
https://example.com/example/repo/issues/29
763+
- [#32](https://example.com/example/repo/issues/32)
745764
746765
* ``merge_request_url (Callable[[MergeReqStr | MergeReqInt], UrlStr])``: given a
747766
merge request number, return a URL to the merge request in the remote. This is
@@ -764,6 +783,8 @@ The filters provided vary based on the VCS configured and available features:
764783
}}
765784
{# commit.linked_merge_request is only available in v9.13.0 or greater #}
766785
786+
**Markdown Output:**
787+
767788
.. code:: markdown
768789
769790
[#29](https://example.com/example/repo/-/merge_requests/29)
@@ -781,13 +802,16 @@ The filters provided vary based on the VCS configured and available features:
781802

782803
.. code:: jinja
783804
784-
{{
805+
{# Create a link to the merge request associated with the commit
806+
# NOTE: commit.linked_merge_request is only available in v9.13.0 or greater
807+
#}{{
785808
"[%s](%s)" | format(
786809
commit.linked_merge_request,
787810
commit.linked_merge_request | pull_request_url
788811
)
789812
}}
790-
{# commit.linked_merge_request is only available in v9.13.0 or greater #}
813+
814+
**Markdown Output:**
791815

792816
.. code:: markdown
793817

0 commit comments

Comments
 (0)