コード例 #1
0
ファイル: setup.py プロジェクト: lamby/pyerfa
def guess_next_dev(version):
    from setuptools_scm import git
    from setuptools_scm.version import guess_next_version

    erfa_version = git.parse(LIBERFADIR)
    if not erfa_version.exact:
        warn(f'liberfa/erfa not at a tagged release, but at {erfa_version}')

    erfa_tag = erfa_version.format_with("{tag}")
    version_string = str(version.tag)

    if version.exact:
        if not version_string.startswith(erfa_tag):
            warn(
                f'tag {version_string} does not start with liberfa/erfa tag {erfa_tag}'
            )

        return version_string

    else:
        if erfa_tag > version_string:
            guessed = erfa_tag
        elif 'dev' in version_string or len(version_string.split('.')) > 3:
            return guess_next_version(version.tag)
        else:
            guessed = version_string.partition("+")[0] + '.1'
        return version.format_with("{guessed}.dev{distance}", guessed=guessed)
コード例 #2
0
def test_case_mismatch_on_windows_git(tmpdir):
    """Case insensitive path checks on Windows"""
    p = tmpdir.ensure("CapitalizedDir", dir=1)

    do("git init", p)
    res = parse(str(p).lower())
    assert res is not None
コード例 #3
0
ファイル: test_git.py プロジェクト: rth/setuptools_scm
def test_version_from_git(wd):
    assert wd.version == "0.1.dev0"

    assert git.parse(str(wd.cwd), git.DEFAULT_DESCRIBE).branch == "master"

    wd.commit_testfile()
    assert wd.version.startswith("0.1.dev1+g")
    assert not wd.version.endswith("1-")

    wd("git tag v0.1")
    assert wd.version == "0.1"

    wd.write("test.txt", "test2")
    assert wd.version.startswith("0.2.dev0+g")

    wd.commit_testfile()
    assert wd.version.startswith("0.2.dev1+g")

    wd("git tag version-0.2")
    assert wd.version.startswith("0.2")

    wd.commit_testfile()
    wd("git tag version-0.2.post210+gbe48adfpost3+g0cc25f2")
    with pytest.warns(UserWarning,
                      match="tag '.*' will be stripped of its suffix '.*'"):
        assert wd.version.startswith("0.2")

    wd.commit_testfile()
    wd("git tag 17.33.0-rc")
    assert wd.version == "17.33.0rc0"
コード例 #4
0
def test_case_mismatch_on_windows_git(tmpdir):
    """Case insensitive path checks on Windows"""
    p = tmpdir.ensure("CapitalizedDir", dir=1)

    do('git init', p)
    res = parse(str(p).lower())
    assert res is not None
コード例 #5
0
ファイル: scm_version.py プロジェクト: liberfa/pyerfa
    def _guess_next_dev(version, liberfadir=None):
        if liberfadir is None:
            liberfadir = pathlib.Path(
                __file__).parent.parent.parent / 'liberfa' / 'erfa'

        erfa_version = git.parse(liberfadir)
        if not erfa_version.exact:
            warn(
                f'liberfa/erfa not at a tagged release, but at {erfa_version}')

        erfa_tag = erfa_version.format_with("{tag}")
        version_string = str(version.tag)

        if version.exact:
            if not version_string.startswith(erfa_tag):
                warn(f'tag {version_string} does not start with '
                     f'liberfa/erfa tag {erfa_tag}')

            return version_string

        else:
            if erfa_tag > version_string:
                guessed = erfa_tag
            elif 'dev' in version_string or len(version_string.split('.')) > 3:
                return guess_next_version(version.tag)
            else:
                guessed = version_string.partition("+")[0] + '.1'
            return version.format_with("{guessed}.dev{distance}",
                                       guessed=guessed)
コード例 #6
0
def parse_git(root, **kwargs):
    """
    Parse function for setuptools_scm
    """
    from setuptools_scm.git import parse

    kwargs["describe_command"] = "git describe --dirty --tags --long"
    return parse(root, **kwargs)
コード例 #7
0
ファイル: __init__.py プロジェクト: timkpaine/arrow
 def parse_git(root, **kwargs):
     """
     Parse function for setuptools_scm that ignores tags for non-C++
     subprojects, e.g. apache-arrow-js-XXX tags.
     """
     from setuptools_scm.git import parse
     kwargs['describe_command'] = \
         "git describe --dirty --tags --long --match 'apache-arrow-[0-9].*'"
     return parse(root, **kwargs)
コード例 #8
0
ファイル: __init__.py プロジェクト: emkornfield/arrow
 def parse_git(root, **kwargs):
     """
     Parse function for setuptools_scm that ignores tags for non-C++
     subprojects, e.g. apache-arrow-js-XXX tags.
     """
     from setuptools_scm.git import parse
     kwargs['describe_command'] = \
         "git describe --dirty --tags --long --match 'apache-arrow-[0-9].*'"
     return parse(root, **kwargs)
コード例 #9
0
ファイル: setup.py プロジェクト: siyuan0322/GraphScope
def parse_version(root, **kwargs):
    """
    Parse function for setuptools_scm that first tries to read '../VERSION' file
    to get a version number.
    """
    from setuptools_scm.git import parse
    from setuptools_scm.version import meta

    version_file = os.path.join(repo_root, "..", "VERSION")
    if os.path.isfile(version_file):
        with open(version_file, "r", encoding="utf-8") as fp:
            return meta(fp.read().strip())
    return parse(root, **kwargs)
コード例 #10
0
def test_git_getdate(wd):
    # TODO: case coverage for git wd parse
    today = date.today()

    def parse_date():
        return git.parse(os.fspath(wd.cwd)).node_date

    git_wd = git.GitWorkdir(os.fspath(wd.cwd))
    assert git_wd.get_head_date() is None
    assert parse_date() == today

    wd.commit_testfile()
    assert git_wd.get_head_date() == today
    meta = git.parse(os.fspath(wd.cwd))
    assert meta.node_date == today
コード例 #11
0
def parse_with_fetch(*args, **kwargs) -> str:
    """If the repo is found to be shallow, fetch a full.

    By default, RTD does a fetch --limit 50, if a tag is not
    present in the last 50 commits, the version reported by setuptools_scm
    will be incorrect and appears as ``v0.1.dev...`` in the towncrier changelog.
    Another approach is to enable ``DONT_SHALLOW_CLONE`` for the repo
    https://docs.readthedocs.io/en/stable/feature-flags.html#feature-flags
    This was done for ansible-navigator on the day of this commit.

    :param args: The arguments
    :param kwargs: The keyword arguments
    :returns: The parsed version
    """
    assert "pre_parse" not in kwargs
    return parse(*args, pre_parse=fetch_on_shallow, **kwargs)
コード例 #12
0
def test_version_from_git(wd):
    assert wd.version == "0.1.dev0"

    assert git.parse(str(wd.cwd), git.DEFAULT_DESCRIBE).branch == "master"

    wd.commit_testfile()
    assert wd.version.startswith("0.1.dev1+g")
    assert not wd.version.endswith("1-")

    wd("git tag v0.1")
    assert wd.version == "0.1"

    wd.write("test.txt", "test2")
    assert wd.version.startswith("0.2.dev0+g")

    wd.commit_testfile()
    assert wd.version.startswith("0.2.dev1+g")

    wd("git tag version-0.2")
    assert wd.version.startswith("0.2")

    wd.commit_testfile()
    wd("git tag version-0.2.post210+gbe48adfpost3+g0cc25f2")
    with pytest.warns(UserWarning,
                      match="tag '.*' will be stripped of its suffix '.*'"):
        assert wd.version.startswith("0.2")

    wd.commit_testfile()
    wd("git tag 17.33.0-rc")
    assert wd.version == "17.33.0rc0"

    # custom normalization
    assert wd.get_version(normalize=False) == "17.33.0-rc"
    assert wd.get_version(version_cls=NonNormalizedVersion) == "17.33.0-rc"
    assert (wd.get_version(
        version_cls="setuptools_scm.NonNormalizedVersion") == "17.33.0-rc")
コード例 #13
0
def test_git_parse_shallow_fail(shallow_wd):
    with pytest.raises(ValueError) as einfo:
        git.parse(str(shallow_wd), pre_parse=git.fail_on_shallow)

    assert "git fetch" in str(einfo.value)
コード例 #14
0
def test_git_parse_shallow_warns(shallow_wd, recwarn):
    git.parse(str(shallow_wd))
    msg = recwarn.pop()
    assert "is shallow and may cause errors" in str(msg.message)
コード例 #15
0
 def parse_date():
     return git.parse(os.fspath(wd.cwd)).node_date
コード例 #16
0
 def parse(root, config):
     try:
         return parse_pkginfo(root, config)
     except OSError:
         return git.parse(root, config=config) or hg.parse(root,
                                                           config=config)
コード例 #17
0
def test_parse_call_order(wd):
    git.parse(str(wd.cwd), git.DEFAULT_DESCRIBE)
コード例 #18
0
ファイル: test_git.py プロジェクト: pypa/setuptools_scm
def test_git_shallow_autocorrect(shallow_wd, recwarn):
    git.parse(str(shallow_wd), pre_parse=git.fetch_on_shallow)
    msg = recwarn.pop()
    assert 'git fetch was used to rectify' in str(msg.message)
    git.parse(str(shallow_wd), pre_parse=git.fail_on_shallow)
コード例 #19
0
ファイル: test_git.py プロジェクト: pypa/setuptools_scm
def test_git_parse_shallow_warns(shallow_wd, recwarn):
    git.parse(str(shallow_wd))
    msg = recwarn.pop()
    assert 'is shallow and may cause errors' in str(msg.message)
コード例 #20
0
ファイル: setup.py プロジェクト: isabella232/apigentools
def parse_fetch_on_shallow(root):
    from setuptools_scm.git import parse, fetch_on_shallow

    return parse(root, pre_parse=fetch_on_shallow)
コード例 #21
0
def test_git_shallow_autocorrect(shallow_wd, recwarn):
    git.parse(str(shallow_wd), pre_parse=git.fetch_on_shallow)
    msg = recwarn.pop()
    assert "git fetch was used to rectify" in str(msg.message)
    git.parse(str(shallow_wd), pre_parse=git.fail_on_shallow)
コード例 #22
0
ファイル: test_git.py プロジェクト: pypa/setuptools_scm
def test_parse_no_worktree(tmpdir):
    ret = git.parse(str(tmpdir))
    assert ret is None
コード例 #23
0
def test_parse_no_worktree(tmpdir):
    ret = git.parse(str(tmpdir))
    assert ret is None
コード例 #24
0
ファイル: test_git.py プロジェクト: rth/setuptools_scm
def test_git_gone(wd, monkeypatch):
    monkeypatch.setenv("PATH", str(wd.cwd / "not-existing"))
    with pytest.raises(EnvironmentError, match="'git' was not found"):
        git.parse(str(wd.cwd), git.DEFAULT_DESCRIBE)
コード例 #25
0
ファイル: test_git.py プロジェクト: pypa/setuptools_scm
def test_git_parse_shallow_fail(shallow_wd):
    with pytest.raises(ValueError) as einfo:
        git.parse(str(shallow_wd), pre_parse=git.fail_on_shallow)

    assert 'git fetch' in str(einfo.value)
コード例 #26
0
ファイル: setup.py プロジェクト: stjordanis/jupyter-flex
def parse_git(root, **kwargs):
    from setuptools_scm.git import parse

    kwargs[
        "describe_command"] = 'git describe --dirty --tags --long --match "[0-9].*"'
    return parse(root, **kwargs)