Skip to content
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 @@
v1.15.2
=======

* fix issue #128: return None when a scm specific parse fails in a worktree to ease parse reuse


v1.15.1
=======

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def scm_config():
local_scheme=get_local_node_and_date,
)


with open('README.rst') as fp:
long_description = fp.read()

Expand Down
5 changes: 4 additions & 1 deletion setuptools_scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ def parse(root, describe_command=DEFAULT_DESCRIBE, pre_parse=warn_on_shallow):
"""
if not has_command('git'):
return
wd = GitWorkdir(root)

wd = GitWorkdir.from_potential_worktree(root)
if wd is None:
return
if pre_parse:
pre_parse(wd)
rev_node = wd.node()
Expand Down
2 changes: 2 additions & 0 deletions setuptools_scm/hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def parse(root):
if not has_command('hg'):
return
l = do('hg id -i -t', root).split()
if not l:
return
node = l.pop(0)
tags = tags_to_versions(l)
# filter tip in degraded mode on old setuptools
Expand Down
6 changes: 6 additions & 0 deletions testing/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ def test_find_files_stop_at_root_git(wd):
assert integration.find_files(str(wd.cwd/'project')) == []


@pytest.mark.issue(128)
def test_parse_no_worktree(tmpdir):
ret = git.parse(str(tmpdir))
assert ret is None


def test_alphanumeric_tags_match(wd):
wd.commit_testfile()
wd('git tag newstyle-development-started')
Expand Down
9 changes: 8 additions & 1 deletion testing/test_mercurial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from setuptools_scm import format_version
from setuptools_scm.hg import archival_to_version
from setuptools_scm.hg import archival_to_version, parse
from setuptools_scm import integration

import pytest
Expand All @@ -12,6 +12,7 @@ def wd(wd):
wd.commit_command = 'hg commit -m test-{reason} -u test -d "0 0"'
return wd


archival_mapping = {
'1.0': {'tag': '1.0'},
'1.1.dev3+n000000000000': {
Expand Down Expand Up @@ -101,3 +102,9 @@ def test_version_in_merge(wd):
wd.commit_testfile()
wd('hg merge --tool :merge')
assert wd.version is not None


@pytest.mark.issue(128)
def test_parse_no_worktree(tmpdir):
ret = parse(str(tmpdir))
assert ret is None