Skip to content

Commit 065808a

Browse files
abnradoering
authored andcommitted
vcs: remove unused git code
1 parent 65e80c0 commit 065808a

File tree

2 files changed

+0
-101
lines changed

2 files changed

+0
-101
lines changed

src/poetry/core/vcs/git.py

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -244,67 +244,6 @@ def version(self) -> tuple[int, int, int]:
244244
return (0, 0, 0)
245245
return int(version.group(1)), int(version.group(2)), int(version.group(3))
246246

247-
def clone(self, repository: str, dest: Path) -> str:
248-
self._check_parameter(repository)
249-
cmd = [
250-
"clone",
251-
"--filter=blob:none",
252-
"--recurse-submodules",
253-
"--",
254-
repository,
255-
str(dest),
256-
]
257-
# Blobless clones introduced in Git 2.17
258-
if self.version < (2, 17):
259-
cmd.remove("--filter=blob:none")
260-
return self.run(*cmd)
261-
262-
def checkout(self, rev: str, folder: Path | None = None) -> str:
263-
args = []
264-
if folder is None and self._work_dir:
265-
folder = self._work_dir
266-
267-
if folder:
268-
args += [
269-
"--git-dir",
270-
(folder / ".git").as_posix(),
271-
"--work-tree",
272-
folder.as_posix(),
273-
]
274-
275-
self._check_parameter(rev)
276-
277-
args += ["checkout", "--recurse-submodules", rev]
278-
279-
return self.run(*args)
280-
281-
def rev_parse(self, rev: str, folder: Path | None = None) -> str:
282-
args = []
283-
if folder is None and self._work_dir:
284-
folder = self._work_dir
285-
286-
self._check_parameter(rev)
287-
288-
# We need "^0" (an alternative to "^{commit}") to ensure that the
289-
# commit SHA of the commit the tag points to is returned, even in
290-
# the case of annotated tags.
291-
#
292-
# We deliberately avoid the "^{commit}" syntax itself as on some
293-
# platforms (cygwin/msys to be specific), the braces are interpreted
294-
# as special characters and would require escaping, while on others
295-
# they should not be escaped.
296-
args += ["rev-parse", rev + "^0"]
297-
298-
return self.run(*args, folder=folder)
299-
300-
def get_current_branch(self, folder: Path | None = None) -> str:
301-
if folder is None and self._work_dir:
302-
folder = self._work_dir
303-
304-
output = self.run("symbolic-ref", "--short", "HEAD", folder=folder)
305-
306-
return output.strip()
307-
308247
def get_ignored_files(self, folder: Path | None = None) -> list[str]:
309248
args = []
310249
if folder is None and self._work_dir:
@@ -323,23 +262,6 @@ def get_ignored_files(self, folder: Path | None = None) -> list[str]:
323262

324263
return output.strip().split("\n")
325264

326-
def remote_urls(self, folder: Path | None = None) -> dict[str, str]:
327-
output = self.run(
328-
"config", "--get-regexp", r"remote\..*\.url", folder=folder
329-
).strip()
330-
331-
urls = {}
332-
for url in output.splitlines():
333-
name, url = url.split(" ", 1)
334-
urls[name.strip()] = url.strip()
335-
336-
return urls
337-
338-
def remote_url(self, folder: Path | None = None) -> str:
339-
urls = self.remote_urls(folder=folder)
340-
341-
return urls.get("remote.origin.url", urls[next(iter(urls.keys()))])
342-
343265
def run(self, *args: Any, **kwargs: Any) -> str:
344266
folder = kwargs.pop("folder", None)
345267
if folder:
@@ -358,10 +280,3 @@ def run(self, *args: Any, **kwargs: Any) -> str:
358280
.decode()
359281
.strip()
360282
)
361-
362-
def _check_parameter(self, parameter: str) -> None:
363-
"""
364-
Checks a git parameter to avoid unwanted code execution.
365-
"""
366-
if parameter.strip().startswith("-"):
367-
raise GitError(f"Invalid Git parameter: {parameter}")

tests/vcs/test_vcs.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from poetry.core.utils._compat import WINDOWS
1313
from poetry.core.vcs import get_vcs
1414
from poetry.core.vcs.git import Git
15-
from poetry.core.vcs.git import GitError
1615
from poetry.core.vcs.git import GitUrl
1716
from poetry.core.vcs.git import ParsedUrl
1817
from poetry.core.vcs.git import _reset_executable
@@ -440,21 +439,6 @@ def test_parse_url_should_fail() -> None:
440439
ParsedUrl.parse(url)
441440

442441

443-
def test_git_clone_raises_error_on_invalid_repository() -> None:
444-
with pytest.raises(GitError):
445-
Git().clone("-u./payload", Path("foo"))
446-
447-
448-
def test_git_checkout_raises_error_on_invalid_repository() -> None:
449-
with pytest.raises(GitError):
450-
Git().checkout("-u./payload")
451-
452-
453-
def test_git_rev_parse_raises_error_on_invalid_repository() -> None:
454-
with pytest.raises(GitError):
455-
Git().rev_parse("-u./payload")
456-
457-
458442
@pytest.mark.skipif(
459443
not WINDOWS,
460444
reason=(

0 commit comments

Comments
 (0)