Test fetch behavior
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
@@ -138,7 +138,13 @@ class RepoTool:
|
||||
return False
|
||||
|
||||
log.info(f"Cloning repository from url: {url}")
|
||||
self._repo = Repo.clone_from(url, to_path = self._path, progress = GitRemoteProgress(), bare = True)
|
||||
self._repo = Repo.clone_from(
|
||||
url,
|
||||
to_path = self._path,
|
||||
progress = GitRemoteProgress(),
|
||||
bare = True,
|
||||
mirror = True
|
||||
)
|
||||
self._initialized = True
|
||||
self._bare = self._repo.bare
|
||||
|
||||
@@ -154,10 +160,24 @@ class RepoTool:
|
||||
remote = self._repo.remotes[0]
|
||||
log.debug(f"Fetching remote: {remote.name} url: {next(remote.urls)}")
|
||||
self._last_fetch_data = remote.fetch(
|
||||
"+refs/heads/*:refs/heads/*",
|
||||
["+refs/heads/*:refs/heads/*", "+refs/tags/*:refs/tags/*"],
|
||||
progress = GitRemoteProgress(),
|
||||
kill_after_timeout = 60,
|
||||
prune = True
|
||||
)
|
||||
log.debug("Fetch finished!")
|
||||
return True
|
||||
|
||||
@__check_initialized
|
||||
def repo_fingerprint(self) -> Union[str, bool]:
|
||||
log.debug("Getting repo fingerprint")
|
||||
# reference count
|
||||
ref_count = self._repo.git.rev_list(count = True, all = True)
|
||||
tags = [f"{tag.name}/{tag.commit}" for tag in self._repo.tags]
|
||||
branches = [f"{branch.name}/{branch.commit}" for branch in self._repo.branches]
|
||||
log.debug(f"{ref_count} references, {len(tags)} tags, {len(branches)} branches")
|
||||
cumulative = f"{ref_count} {'.'.join(tags)} {' '.join(branches)}".encode()
|
||||
import hashlib
|
||||
x = hashlib.sha256(cumulative).hexdigest()
|
||||
log.debug(f"Repo fingerprint is {x}")
|
||||
return x
|
||||
|
||||
Reference in New Issue
Block a user