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


Python git.Git类代码示例

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


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

示例1: test_git_resolve_revision_rev_not_found

def test_git_resolve_revision_rev_not_found(get_sha_mock):
    get_sha_mock.return_value = (None, False)
    url = 'git+https://git.example.com'
    rev_options = Git.make_rev_options('develop')

    new_options = Git.resolve_revision('.', url, rev_options)
    assert new_options.rev == 'develop'
开发者ID:pypa,项目名称:pip,代码行数:7,代码来源:test_vcs.py

示例2: git

def git():
    git_url = 'https://github.com/pypa/pip-test-package'
    sha = '5547fa909e83df8bd743d3978d6667497983a4b7'
    git = Git()
    git.get_url = Mock(return_value=git_url)
    git.get_revision = Mock(return_value=sha)
    return git
开发者ID:edmorley,项目名称:pip,代码行数:7,代码来源:test_vcs.py

示例3: test_check_rev_options_ref_not_found

def test_check_rev_options_ref_not_found(get_sha_mock):
    get_sha_mock.return_value = None
    git = Git()
    rev_options = git.make_rev_options('develop')

    new_options = git.check_rev_options('.', rev_options)
    assert new_options.rev == 'develop'
开发者ID:edmorley,项目名称:pip,代码行数:7,代码来源:test_install_vcs_git.py

示例4: test_check_rev_options_ref_exists

def test_check_rev_options_ref_exists(get_sha_mock):
    get_sha_mock.return_value = '123456'
    git = Git()
    rev_options = git.make_rev_options('develop')

    new_options = git.check_rev_options('.', rev_options)
    assert new_options.rev == '123456'
开发者ID:edmorley,项目名称:pip,代码行数:7,代码来源:test_install_vcs_git.py

示例5: test_git_resolve_revision_rev_exists

def test_git_resolve_revision_rev_exists(get_sha_mock):
    get_sha_mock.return_value = ('123456', False)
    git = Git()
    rev_options = git.make_rev_options('develop')

    url = 'git+https://git.example.com'
    new_options = git.resolve_revision('.', url, rev_options)
    assert new_options.rev == '123456'
开发者ID:jaraco,项目名称:pip,代码行数:8,代码来源:test_vcs.py

示例6: test_git_dir_ignored

def test_git_dir_ignored():
    """
    Test that a GIT_DIR environment variable is ignored.
    """
    git = Git()
    with TempDirectory() as temp:
        temp_dir = temp.path
        env = {'GIT_DIR': 'foo'}
        # If GIT_DIR is not ignored, then os.listdir() will return ['foo'].
        git.run_command(['init', temp_dir], cwd=temp_dir, extra_environ=env)
        assert os.listdir(temp_dir) == ['.git']
开发者ID:jaraco,项目名称:pip,代码行数:11,代码来源:test_vcs_git.py

示例7: test_get_short_refs_should_return_branch_name_and_commit_pair

def test_get_short_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_short_refs(version_pkg_path)
    assert result['master'] == commit, result
    assert result['branch0.1'] == commit, result
开发者ID:oz123,项目名称:pip,代码行数:11,代码来源:test_install_vcs_git.py

示例8: test_git_dir_ignored

def test_git_dir_ignored(tmpdir):
    """
    Test that a GIT_DIR environment variable is ignored.
    """
    repo_path = tmpdir / 'test-repo'
    repo_path.mkdir()
    repo_dir = str(repo_path)

    env = {'GIT_DIR': 'foo'}
    # If GIT_DIR is not ignored, then os.listdir() will return ['foo'].
    Git.run_command(['init', repo_dir], cwd=repo_dir, extra_environ=env)
    assert os.listdir(repo_dir) == ['.git']
开发者ID:cjerdonek,项目名称:pip,代码行数:12,代码来源:test_vcs_git.py

示例9: 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:oz123,项目名称:pip,代码行数:12,代码来源:test_install_vcs_git.py

示例10: test_get_remote_url__no_remote

def test_get_remote_url__no_remote(script, tmpdir):
    """
    Test a repo with no remote.
    """
    repo_dir = tmpdir / 'temp-repo'
    repo_dir.mkdir()
    repo_dir = str(repo_dir)

    script.run('git', 'init', cwd=repo_dir)

    with pytest.raises(RemoteNotFoundError):
        Git.get_remote_url(repo_dir)
开发者ID:cjerdonek,项目名称:pip,代码行数:12,代码来源:test_vcs_git.py

示例11: test_git_work_tree_ignored

def test_git_work_tree_ignored():
    """
    Test that a GIT_WORK_TREE environment variable is ignored.
    """
    git = Git()
    with TempDirectory() as temp:
        temp_dir = temp.path
        git.run_command(['init', temp_dir], cwd=temp_dir)
        # Choose a directory relative to the cwd that does not exist.
        # If GIT_WORK_TREE is not ignored, then the command will error out
        # with: "fatal: This operation must be run in a work tree".
        env = {'GIT_WORK_TREE': 'foo'}
        git.run_command(['status', temp_dir], extra_environ=env, cwd=temp_dir)
开发者ID:jaraco,项目名称:pip,代码行数:13,代码来源:test_vcs_git.py

示例12: test_git__get_url_rev__idempotent

def test_git__get_url_rev__idempotent():
    """
    Check that Git.get_url_rev_and_auth() is idempotent for what the code calls
    "stub URLs" (i.e. URLs that don't contain "://").

    Also check that it doesn't change self.url.
    """
    url = '[email protected]:MyProject#egg=MyProject'
    result1 = Git.get_url_rev_and_auth(url)
    result2 = Git.get_url_rev_and_auth(url)
    expected = ('[email protected]:MyProject', None, (None, None))
    assert result1 == expected
    assert result2 == expected
开发者ID:pypa,项目名称:pip,代码行数:13,代码来源:test_vcs.py

示例13: test_git_work_tree_ignored

def test_git_work_tree_ignored(tmpdir):
    """
    Test that a GIT_WORK_TREE environment variable is ignored.
    """
    repo_path = tmpdir / 'test-repo'
    repo_path.mkdir()
    repo_dir = str(repo_path)

    Git.run_command(['init', repo_dir], cwd=repo_dir)
    # Choose a directory relative to the cwd that does not exist.
    # If GIT_WORK_TREE is not ignored, then the command will error out
    # with: "fatal: This operation must be run in a work tree".
    env = {'GIT_WORK_TREE': 'foo'}
    Git.run_command(['status', repo_dir], extra_environ=env, cwd=repo_dir)
开发者ID:cjerdonek,项目名称:pip,代码行数:14,代码来源:test_vcs_git.py

示例14: test_git__get_netloc_and_auth

def test_git__get_netloc_and_auth(args, expected):
    """
    Test VersionControl.get_netloc_and_auth().
    """
    netloc, scheme = args
    actual = Git.get_netloc_and_auth(netloc, scheme)
    assert actual == expected
开发者ID:pypa,项目名称:pip,代码行数:7,代码来源:test_vcs.py

示例15: test_get_current_branch

def test_get_current_branch(script):
    repo_dir = str(script.scratch_path)

    script.run('git', 'init', cwd=repo_dir)
    sha = do_commit(script, repo_dir)

    assert Git.get_current_branch(repo_dir) == 'master'

    # Switch to a branch with the same SHA as "master" but whose name
    # is alphabetically after.
    checkout_new_branch(script, repo_dir, 'release')
    assert Git.get_current_branch(repo_dir) == 'release'

    # Also test the detached HEAD case.
    checkout_ref(script, repo_dir, sha)
    assert Git.get_current_branch(repo_dir) is None
开发者ID:cjerdonek,项目名称:pip,代码行数:16,代码来源:test_vcs_git.py


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