Skip to content

Commit

Permalink
Use default setuptools-scm value for tag-pattern instead of empty s…
Browse files Browse the repository at this point in the history
…tring

Closes ofek#67
  • Loading branch information
edgarrmondragon committed Jul 1, 2024
1 parent e186a8b commit 8971d8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hatch_vcs/version_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def construct_setuptools_scm_config(self):
config = deepcopy(self.config_raw_options)
config.setdefault('root', self.root)

config.setdefault('tag_regex', self.config_tag_pattern)
# Only set for non-empty strings
if self.config_tag_pattern:
config.setdefault('tag_regex', self.config_tag_pattern)

# Only set for non-empty strings
if self.config_fallback_version:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_version_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-FileCopyrightText: 2022-present Ofek Lev <oss@ofek.dev>
#
# SPDX-License-Identifier: MIT
import warnings

import pytest

from hatch_vcs.version_source import VCSVersionSource
Expand All @@ -20,6 +22,17 @@ def test_not_string(self, new_project_basic):
with pytest.raises(TypeError, match='option `tag-pattern` must be a string'):
_ = version_source.config_tag_pattern

def test_no_tag_pattern(self, new_project_basic):
config = {}
version_source = VCSVersionSource(new_project_basic, config)

assert version_source.config_tag_pattern == ''

# Should not raise any deprecation warnings
with warnings.catch_warnings(category=DeprecationWarning):
warnings.simplefilter('error')
_ = version_source.get_version_data()


class TestFallbackVersion:
def test_correct(self, new_project_basic):
Expand Down

0 comments on commit 8971d8a

Please sign in to comment.