Skip to content

Commit

Permalink
Merge pull request #732 from RonnyPfannschmidt/fix-727-git-archival-n…
Browse files Browse the repository at this point in the history
…o-version-for-empty

fix #727: correctly handle incomplete archivals from setuptools_scm_g…
  • Loading branch information
RonnyPfannschmidt authored Jun 27, 2022
2 parents 21e58d4 + ae6cb5e commit 1ebac97
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v7.0.4
=======

* fix #727: correctly handle incomplete archivals from setuptools_scm_git_archival
* fix #691: correctly handle specifying root in pyproject.toml

v7.0.3
=======
* fix mercurial usage when pip primes a isolated environment
Expand Down
9 changes: 7 additions & 2 deletions src/setuptools_scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ def search_parent(dirname: _t.PathT) -> GitWorkdir | None:

def archival_to_version(
data: dict[str, str], config: Configuration | None = None
) -> ScmVersion:
) -> ScmVersion | None:
node: str | None
trace("data", data)
archival_describe = data.get("describe-name", DESCRIBE_UNSUPPORTED)
if DESCRIBE_UNSUPPORTED in archival_describe:
Expand All @@ -293,7 +294,11 @@ def archival_to_version(
if versions:
return meta(versions[0], config=config)
else:
return meta("0.0", node=data.get("node"), config=config)
node = data.get("node")
if node is not None:
return meta("0.0", node=node, config=config)
else:
return None


def parse_archival(
Expand Down
8 changes: 8 additions & 0 deletions testing/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,17 @@ def test_git_getdate_signed_commit(signed_commit_wd: WorkDir) -> None:
def test_git_archival_to_version(expected: str, from_data: dict[str, str]) -> None:
config = Configuration()
version = archival_to_version(from_data, config=config)
assert version is not None
assert (
format_version(
version, version_scheme="guess-next-dev", local_scheme="node-and-date"
)
== expected
)


@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/727")
def test_git_archival_node_missing_no_version() -> None:
config = Configuration()
version = archival_to_version({}, config=config)
assert version is None

0 comments on commit 1ebac97

Please sign in to comment.