forked from camas/setuptools-git-ver
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Add tag_filter config option #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
91d6bf5
Implement tag_filter
vortechs2000 079c862
Filter fxn returns Optional[str]
pre-commit-ci[bot] 755acac
Fix up Optional[str] -> str | None
pre-commit-ci[bot] 4557584
Fix abbreviated var name
vortechs2000 60f26f0
Use GIT_COMMITTER_DATE env var during commit
vortechs2000 c88041a
Fix up tests now that commit date is set
vortechs2000 d4bd9e9
Use filter instead of changing tags
vortechs2000 ea32050
Cleanup tag filter tests based on review
vortechs2000 251b483
Update and cleanup tag_filter docs
vortechs2000 801f177
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1997bbc
Fix `'time' imported but not used` flake8 error
vortechs2000 bd3a265
Fix GIT_COMMITER_DATE env var set
vortechs2000 07c9738
Use try/finally to ensure env var reset
vortechs2000 d717cb4
Revert mistaken log level change
vortechs2000 a03cfe1
Revert "fix" to test_tag_sort_by_tag_date()
vortechs2000 34cd12d
Cleanup unnecessary dictionary usage
vortechs2000 6705fb2
Exercise the regexp error case for tag filters
vortechs2000 25a8098
Merge remote-tracking branch 'upstream/master' into add_tag_prefix
vortechs2000 1724aa7
Missed load_callable API change
vortechs2000 3cbb3ef
load_tag_filter -> _load_tag_filter
vortechs2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ Config options | |
sort_by | ||
branch_formatter | ||
tag_formatter | ||
tag_filter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.. _tag_filter-option: | ||
|
||
``tag_filter`` | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Callback to be used for filtering tag names before formatting and template | ||
substitution. | ||
|
||
.. note:: | ||
|
||
This option is completely ignored if :ref:`version-file` schema is used. | ||
This is because all tags are set on ``master`` / ``main`` branch, | ||
so commits to other branches like ``develop`` are tagless. | ||
|
||
.. note:: | ||
|
||
This option is completely ignored if :ref:`version-callback` schema is used, | ||
because git commit history is not fetched in such a case. | ||
|
||
Type | ||
^^^^^ | ||
``str`` | ||
|
||
Default value | ||
^^^^^^^^^^^^^ | ||
``None`` | ||
|
||
Usage | ||
^^^^^^ | ||
|
||
Set when multiple products are tagged in a single repo. | ||
|
||
If, for example, your repo has: | ||
|
||
- ``product_x/1.2.0`` | ||
- ``product_x/1.2.1`` | ||
- ``product_x/1.3.0`` | ||
- ``product_y/2.0.0`` | ||
- ``product_y/2.1.0`` | ||
|
||
and you only want versions from ``product_y``, simply set: | ||
|
||
.. code:: toml | ||
|
||
tag_filter = "product_y/(?P<tag>.*)" | ||
|
||
This will limit the tags considered to those that start with ``product_y``. | ||
|
||
You will likely still need to construct a :ref:`tag-formatter-option` that | ||
takes the entire tag into consideration. To make thing easier, you can often | ||
use the same regexp/callback for the filter that you would use for the | ||
formatter. | ||
|
||
Possible values | ||
^^^^^^^^^^^^^^^ | ||
- ``None`` | ||
|
||
Disables this feature | ||
|
||
- function full name in format ``"some.module:function_name"`` | ||
|
||
Function should have signature ``(str) -> str | None``. It accepts original | ||
tag name and returns the tag name (or subset thereof) if it should be in | ||
the list and None if it is to be filtered out. When a formatter is | ||
required, it it often easiest to use the same function for both the filter | ||
and the formatter, following the rules for the formatter function. | ||
|
||
.. warning:: | ||
|
||
Exception will be raised if module or function/lambda is missing or has invalid signature | ||
|
||
- regexp like ``"tag-prefix/.*"`` or ``"tag-prefix/(?P<tag>.*)"`` | ||
|
||
|
||
The ``<tag>`` group isn't required for the filter, but makes it simpler to | ||
share with the formatter option. | ||
|
||
.. warning:: | ||
|
||
Exception will be raised if regexp is invalid | ||
|
||
.. warning:: | ||
|
||
If regexp doesn't match any tag, the filter will return the empty list, and | ||
the default "0.0.1" version will be selected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.