当前位置: 首页>>代码示例>>Python>>正文


Python git.Git类代码示例

本文整理汇总了Python中pip.vcs.git.Git的典型用法代码示例。如果您正苦于以下问题:Python Git类的具体用法?Python Git怎么用?Python Git使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Git类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_git_get_src_requirements

def test_git_get_src_requirements():
    git_url = "http://github.com/pypa/pip-test-package"
    refs = {
        "0.1": "a8992fc7ee17e5b9ece022417b64594423caca7c",
        "0.1.1": "7d654e66c8fa7149c165ddeffa5b56bc06619458",
        "0.1.2": "f1c1020ebac81f9aeb5c766ff7a772f709e696ee",
        "foo": "5547fa909e83df8bd743d3978d6667497983a4b7",
        "bar": "5547fa909e83df8bd743d3978d6667497983a4b7",
        "master": "5547fa909e83df8bd743d3978d6667497983a4b7",
        "origin/master": "5547fa909e83df8bd743d3978d6667497983a4b7",
        "origin/HEAD": "5547fa909e83df8bd743d3978d6667497983a4b7",
    }
    sha = refs["foo"]

    git = Git()
    git.get_url = Mock(return_value=git_url)
    git.get_revision = Mock(return_value=sha)
    git.get_refs = Mock(return_value=refs)
    dist = Mock()
    dist.egg_name = Mock(return_value="pip_test_package")
    ret = git.get_src_requirement(dist, location=".", find_tags=None)

    assert ret == "".join(
        [
            "git+http://github.com/pypa/pip-test-package",
            "@5547fa909e83df8bd743d3978d6667497983a4b7",
            "#egg=pip_test_package-bar",
        ]
    )
开发者ID:arcivanov,项目名称:pip,代码行数:29,代码来源:test_vcs.py

示例2: test_check_rev_options_should_handle_ambiguous_commit

def test_check_rev_options_should_handle_ambiguous_commit(branches_revs_mock,
                                                          tags_revs_mock):
    branches_revs_mock.return_value = {'master': '123456'}
    tags_revs_mock.return_value = {'0.1': '123456'}
    git = Git()

    result = git.check_rev_options('0.1', '.', [])
    assert result == ['123456'], result
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:8,代码来源:test_vcs_git.py

示例3: test_get_branch_revs_should_return_branch_name_and_commit_pair

def test_get_branch_revs_should_return_branch_name_and_commit_pair():
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = env.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    git = Git()
    result = git.get_branch_revs(version_pkg_path)
    assert result == {'master': commit, 'branch0.1': commit}
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:9,代码来源:test_vcs_git.py

示例4: test_get_refs_should_return_branch_name_and_commit_pair

def test_get_refs_should_return_branch_name_and_commit_pair(script):
    version_pkg_path = _create_test_package(script)
    script.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = script.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    git = Git()
    result = git.get_refs(version_pkg_path)
    assert result['master'] == commit, result
    assert result['branch0.1'] == commit, result
开发者ID:1stvamp,项目名称:pip,代码行数:9,代码来源:test_install_vcs_git.py

示例5: test_get_refs_should_return_tag_name_and_commit_pair

def test_get_refs_should_return_tag_name_and_commit_pair():
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run('git', 'tag', '0.1', cwd=version_pkg_path)
    env.run('git', 'tag', '0.2', cwd=version_pkg_path)
    commit = env.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    git = Git()
    result = git.get_refs(version_pkg_path)
    assert result['0.1'] == commit, result
    assert result['0.2'] == commit, result
开发者ID:Basis,项目名称:pip,代码行数:11,代码来源:test_install_vcs_git.py

示例6: test_check_version

def test_check_version(script):
    version_pkg_path = _create_test_package(script)
    script.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = script.run(
        'git', 'rev-parse', 'HEAD',
        cwd=version_pkg_path
    ).stdout.strip()
    git = Git()
    assert git.check_version(version_pkg_path, [commit])
    assert git.check_version(version_pkg_path, [commit[:7]])
    assert not git.check_version(version_pkg_path, ['branch0.1'])
    assert not git.check_version(version_pkg_path, ['abc123'])
开发者ID:AndydeCleyre,项目名称:pip,代码行数:12,代码来源:test_install_vcs_git.py

示例7: test_get_branch_revs_should_ignore_no_branch

def test_get_branch_revs_should_ignore_no_branch():
    env = reset_env()
    version_pkg_path = _create_test_package(env)
    env.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = env.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    # current branch here is "* (nobranch)"
    env.run('git', 'checkout', commit,
            cwd=version_pkg_path, expect_stderr=True)
    git = Git()
    result = git.get_branch_revs(version_pkg_path)
    assert result == {'master': commit, 'branch0.1': commit}
开发者ID:B-Rich,项目名称:heroku-buildpack-python,代码行数:12,代码来源:test_vcs_git.py

示例8: test_get_refs_should_ignore_no_branch

def test_get_refs_should_ignore_no_branch(script):
    version_pkg_path = _create_test_package(script)
    script.run('git', 'branch', 'branch0.1', cwd=version_pkg_path)
    commit = script.run('git', 'rev-parse', 'HEAD',
                     cwd=version_pkg_path).stdout.strip()
    # current branch here is "* (nobranch)"
    script.run('git', 'checkout', commit,
            cwd=version_pkg_path, expect_stderr=True)
    git = Git()
    result = git.get_refs(version_pkg_path)
    assert result['master'] == commit, result
    assert result['branch0.1'] == commit, result
开发者ID:1stvamp,项目名称:pip,代码行数:12,代码来源:test_install_vcs_git.py

示例9: git

def git():
    git_url = 'http://github.com/pypa/pip-test-package'
    refs = {
        '0.1': 'a8992fc7ee17e5b9ece022417b64594423caca7c',
        '0.1.1': '7d654e66c8fa7149c165ddeffa5b56bc06619458',
        '0.1.2': 'f1c1020ebac81f9aeb5c766ff7a772f709e696ee',
        'foo': '5547fa909e83df8bd743d3978d6667497983a4b7',
        'bar': '5547fa909e83df8bd743d3978d6667497983a4b7',
        'master': '5547fa909e83df8bd743d3978d6667497983a4b7',
        'origin/master': '5547fa909e83df8bd743d3978d6667497983a4b7',
        'origin/HEAD': '5547fa909e83df8bd743d3978d6667497983a4b7',
    }
    sha = refs['foo']

    git = Git()
    git.get_url = Mock(return_value=git_url)
    git.get_revision = Mock(return_value=sha)
    git.get_short_refs = Mock(return_value=refs)
    return git
开发者ID:Larry7,项目名称:pip,代码行数:19,代码来源:test_vcs.py

示例10: test_check_rev_options_should_handle_tag_name

def test_check_rev_options_should_handle_tag_name(get_refs_mock):
    get_refs_mock.return_value = {'master': '123456', '0.1': '123456'}
    git = Git()

    result = git.check_rev_options('0.1', '.', [])
    assert result == ['123456']
开发者ID:AndydeCleyre,项目名称:pip,代码行数:6,代码来源:test_install_vcs_git.py

示例11: get_url_rev

 def get_url_rev(self):
     url, rev = PipGit.get_url_rev(self)
     # cluggy temporary hack to get around non-uniform local URI handling
     if os.name == 'nt' and url[:8] == 'file:///' and not url[9] == ':':
         url = url[:8] + 'C:/cygwin/' + url[8:]
     return url, rev
开发者ID:diosmosis,项目名称:ryppl,代码行数:6,代码来源:git.py


注:本文中的pip.vcs.git.Git类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。