Skip to content
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

fix #727: correctly handle incomplete archivals from setuptools_scm_g… #732

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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