mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
More debugging on pygit2
This commit is contained in:
parent
5779722440
commit
368ee2ac38
1 changed files with 43 additions and 0 deletions
|
@ -733,6 +733,10 @@ class GitProvider:
|
||||||
"""
|
"""
|
||||||
Remove stale refs so that they are no longer seen as fileserver envs
|
Remove stale refs so that they are no longer seen as fileserver envs
|
||||||
"""
|
"""
|
||||||
|
print(
|
||||||
|
"DGM class GItProvider clean_stale_refs entry",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
cleaned = []
|
cleaned = []
|
||||||
cmd_str = "git remote prune origin"
|
cmd_str = "git remote prune origin"
|
||||||
|
|
||||||
|
@ -756,6 +760,10 @@ class GitProvider:
|
||||||
output = cmd.communicate()[0]
|
output = cmd.communicate()[0]
|
||||||
output = output.decode(__salt_system_encoding__)
|
output = output.decode(__salt_system_encoding__)
|
||||||
if cmd.returncode != 0:
|
if cmd.returncode != 0:
|
||||||
|
print(
|
||||||
|
f"DGM class GitProvider, cmd returncode not 0, Failed to prune stale branches for '{self.role}' remote '{self.id}'. Output from '{cmd_str}' follows:\n'{output}'",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
log.warning(
|
log.warning(
|
||||||
"Failed to prune stale branches for %s remote '%s'. "
|
"Failed to prune stale branches for %s remote '%s'. "
|
||||||
"Output from '%s' follows:\n%s",
|
"Output from '%s' follows:\n%s",
|
||||||
|
@ -765,16 +773,31 @@ class GitProvider:
|
||||||
output,
|
output,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
print(
|
||||||
|
f"DGM class GitProvider, cmd returncode 0, output '{output}'",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
marker = " * [pruned] "
|
marker = " * [pruned] "
|
||||||
for line in salt.utils.itertools.split(output, "\n"):
|
for line in salt.utils.itertools.split(output, "\n"):
|
||||||
if line.startswith(marker):
|
if line.startswith(marker):
|
||||||
cleaned.append(line[len(marker) :].strip())
|
cleaned.append(line[len(marker) :].strip())
|
||||||
if cleaned:
|
if cleaned:
|
||||||
|
dgm_str_stale_refs = ", ".join(cleaned)
|
||||||
|
print(
|
||||||
|
f"DGM class GitProvider, '{self.role}' pruned the following stale refs: '{dgm_str_stale_refs}'",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
log.debug(
|
log.debug(
|
||||||
"%s pruned the following stale refs: %s",
|
"%s pruned the following stale refs: %s",
|
||||||
self.role,
|
self.role,
|
||||||
", ".join(cleaned),
|
", ".join(cleaned),
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
"DGM class GitProvider, cmd returncode 0, cleaned is empty",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
|
|
||||||
return cleaned
|
return cleaned
|
||||||
|
|
||||||
def clear_lock(self, lock_type="update"):
|
def clear_lock(self, lock_type="update"):
|
||||||
|
@ -2088,8 +2111,16 @@ class Pygit2(GitProvider):
|
||||||
"""
|
"""
|
||||||
Clean stale local refs so they don't appear as fileserver environments
|
Clean stale local refs so they don't appear as fileserver environments
|
||||||
"""
|
"""
|
||||||
|
print(
|
||||||
|
f"DGM class pygit2 clean_stale_refs, local_refs '{local_refs}'",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
if pygit2.GIT_FETCH_PRUNE:
|
if pygit2.GIT_FETCH_PRUNE:
|
||||||
|
print(
|
||||||
|
"DGM class pygit2 clean_stale_refs, pygit2.GIT_FETCH_PRUNE is set",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
# Don't need to clean anything, pygit2 can do it by itself
|
# Don't need to clean anything, pygit2 can do it by itself
|
||||||
return []
|
return []
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -2103,6 +2134,10 @@ class Pygit2(GitProvider):
|
||||||
PYGIT2_VERSION,
|
PYGIT2_VERSION,
|
||||||
self.id,
|
self.id,
|
||||||
)
|
)
|
||||||
|
print(
|
||||||
|
f"DGM class pygit2 clean_stale_refs, The installed version of pygit2 '{PYGIT2_VERSION}' does not support detecting stale refs for authenticated remotes, saltenvs will not reflect branches/tags removed from remote '{self.id}'",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
return []
|
return []
|
||||||
return super().clean_stale_refs()
|
return super().clean_stale_refs()
|
||||||
|
|
||||||
|
@ -2293,6 +2328,10 @@ class Pygit2(GitProvider):
|
||||||
)
|
)
|
||||||
|
|
||||||
if received_objects != 0:
|
if received_objects != 0:
|
||||||
|
print(
|
||||||
|
f"DGM class pygit2 _fetch, role '{self.role}' received '{received_objects}' objects for remote '{self.id}'",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
log.debug(
|
log.debug(
|
||||||
"%s received %s objects for remote '%s'",
|
"%s received %s objects for remote '%s'",
|
||||||
self.role,
|
self.role,
|
||||||
|
@ -2300,6 +2339,10 @@ class Pygit2(GitProvider):
|
||||||
self.id,
|
self.id,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
print(
|
||||||
|
f"DGM class pygit2 _fetch, 'role {self.role}' remote '{self.id}' is up-to-date",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
log.debug("%s remote '%s' is up-to-date", self.role, self.id)
|
log.debug("%s remote '%s' is up-to-date", self.role, self.id)
|
||||||
refs_post = self.repo.listall_references()
|
refs_post = self.repo.listall_references()
|
||||||
cleaned = self.clean_stale_refs(local_refs=refs_post)
|
cleaned = self.clean_stale_refs(local_refs=refs_post)
|
||||||
|
|
Loading…
Add table
Reference in a new issue