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
def test_should_cache_git_sha(tmpdir: Path) -> None: repo_path = os.fspath(_create_test_package(tmpdir, name="mypkg")) commit = Git.get_revision(repo_path) # a link referencing a sha should be cached url = "git+https://g.c/o/r@" + commit + "#egg=mypkg" req = ReqMock(link=Link(url), source_dir=repo_path) assert wheel_builder._should_cache(cast(InstallRequirement, req)) # a link not referencing a sha should not be cached url = "git+https://g.c/o/r@master#egg=mypkg" req = ReqMock(link=Link(url), source_dir=repo_path) assert not wheel_builder._should_cache(cast(InstallRequirement, req))
def test_from_link_vcs_with_source_dir_obtains_commit_id(tmpdir: Path) -> None: repo_path = tmpdir / "test-repo" repo_path.mkdir() repo_dir = os.fspath(repo_path) Git.run_command(["init"], cwd=repo_dir) (repo_path / "somefile").touch() Git.run_command(["add", "."], cwd=repo_dir) Git.run_command(["commit", "-m", "commit msg"], cwd=repo_dir) commit_id = Git.get_revision(repo_dir) direct_url = direct_url_from_link(Link("git+https://g.c/u/p.git"), source_dir=repo_dir) assert direct_url.url == "https://g.c/u/p.git" assert isinstance(direct_url.info, VcsInfo) assert direct_url.info.commit_id == commit_id
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