|
7 | 7 | import logging
|
8 | 8 | from pathlib import Path
|
9 | 9 |
|
10 |
| -import git |
| 10 | +from git.cmd import Git |
| 11 | +from git.repo import Repo |
11 | 12 |
|
12 | 13 | PRIMER_DIRECTORY_PATH = Path("tests") / ".pylint_primer_tests"
|
13 | 14 |
|
@@ -92,22 +93,22 @@ def lazy_clone(self) -> str: # pragma: no cover
|
92 | 93 | "depth": 1,
|
93 | 94 | }
|
94 | 95 | logging.info("Directory does not exists, cloning: %s", options)
|
95 |
| - repo = git.Repo.clone_from(**options) |
96 |
| - return repo.head.object.hexsha |
| 96 | + repo = Repo.clone_from( |
| 97 | + url=self.url, to_path=self.clone_directory, branch=self.branch, depth=1 |
| 98 | + ) |
| 99 | + return str(repo.head.object.hexsha) |
97 | 100 |
|
98 |
| - remote_sha1_commit = ( |
99 |
| - git.cmd.Git().ls_remote(self.url, self.branch).split("\t")[0] |
100 |
| - ) |
101 |
| - local_sha1_commit = git.Repo(self.clone_directory).head.object.hexsha |
| 101 | + remote_sha1_commit = Git().ls_remote(self.url, self.branch).split("\t")[0] |
| 102 | + local_sha1_commit = Repo(self.clone_directory).head.object.hexsha |
102 | 103 | if remote_sha1_commit != local_sha1_commit:
|
103 | 104 | logging.info(
|
104 | 105 | "Remote sha is '%s' while local sha is '%s': pulling new commits",
|
105 | 106 | remote_sha1_commit,
|
106 | 107 | local_sha1_commit,
|
107 | 108 | )
|
108 |
| - repo = git.Repo(self.clone_directory) |
| 109 | + repo = Repo(self.clone_directory) |
109 | 110 | origin = repo.remotes.origin
|
110 | 111 | origin.pull()
|
111 | 112 | else:
|
112 | 113 | logging.info("Repository already up to date.")
|
113 |
| - return remote_sha1_commit |
| 114 | + return str(remote_sha1_commit) |
0 commit comments