mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[Downloader] Catch and handle erorr in update_all when target repository/branch is missing (#3080)
* [Downloader] Catch and handle erorr in update_all when target repository/branch is removed from remote * Rewrite fix, remove ctx from repo_manager, edit docstring, add annotations * Text formatting * Group failed repo messages into padded table, catch single updated repo fails * Error catching v2; repo_manager design change * Docstrings, typos and changelog * Add Optional to update_repos annotatition * Wrong logic * Clear-er log message. * add format_failed_repos, change _repo_update for failed messages * Merge cog updating with fail repo logic; Filter out failed repos * Merge cog updating with fail repo logic; Cog updating logic shuffled to support sending fails at the end * Docstring typo * format_failed_repos - proper docstring * repo_manager.update_repos argument name fix * downloader._cog_checkforupdates added missed failed message * downloader._cog_update_logic place back return on some errors * Purge unused stuff from downloader._repo_update * downloader._cog_update_logic Change exception catching * _cog_update_logic purging obsolete * Remove obsolete 'message' from _cog_checkforupdates * Fix forgotten ctx.send * Wording * Removed obsolete 'message' * Fix wrong type hint in , update docstring * repo update logic fix * format_failed_repos type hint and docstring repair * Extend _get_cogs_to_check with 'update_repos' * Fix type mangling in _get_cogs_to_check * fix: typo Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com> * _repo_update; Added single repo up-to-date message
This commit is contained in:
@@ -795,7 +795,10 @@ class Repo(RepoJSONMixin):
|
||||
-------
|
||||
`tuple` of `str`
|
||||
:py:code`(old commit hash, new commit hash)`
|
||||
|
||||
|
||||
Raises
|
||||
-------
|
||||
`UpdateError` - if git pull results with non-zero exit code
|
||||
"""
|
||||
old_commit = await self.latest_commit()
|
||||
|
||||
@@ -1134,28 +1137,58 @@ class RepoManager:
|
||||
Tuple[Repo, Tuple[str, str]]
|
||||
A 2-`tuple` with Repo object and a 2-`tuple` of `str`
|
||||
containing old and new commit hashes.
|
||||
|
||||
"""
|
||||
repo = self._repos[repo_name]
|
||||
old, new = await repo.update()
|
||||
return (repo, (old, new))
|
||||
|
||||
async def update_all_repos(self) -> Dict[Repo, Tuple[str, str]]:
|
||||
"""Call `Repo.update` on all repositories.
|
||||
async def update_repos(
|
||||
self, repos: Optional[Iterable[Repo]] = None
|
||||
) -> Tuple[Dict[Repo, Tuple[str, str]], List[str]]:
|
||||
"""Calls `Repo.update` on passed repositories and
|
||||
catches failing ones.
|
||||
|
||||
Calling without params updates all currently installed repos.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
repos: Iterable
|
||||
Iterable of Repos, None to update all
|
||||
|
||||
Returns
|
||||
-------
|
||||
Dict[Repo, Tuple[str, str]]
|
||||
tuple of Dict and list
|
||||
A mapping of `Repo` objects that received new commits to
|
||||
a 2-`tuple` of `str` containing old and new commit hashes.
|
||||
|
||||
|
||||
`list` of failed `Repo` names
|
||||
"""
|
||||
failed = []
|
||||
ret = {}
|
||||
for repo_name, __ in self._repos.items():
|
||||
repo, (old, new) = await self.update_repo(repo_name)
|
||||
|
||||
# select all repos if not specified
|
||||
if not repos:
|
||||
repos = self.repos
|
||||
|
||||
for repo in repos:
|
||||
try:
|
||||
updated_repo, (old, new) = await self.update_repo(repo.name)
|
||||
except errors.UpdateError as err:
|
||||
log.error(
|
||||
"Repository '%s' failed to update. URL: '%s' on branch '%s'",
|
||||
repo.name,
|
||||
repo.url,
|
||||
repo.branch,
|
||||
exc_info=err,
|
||||
)
|
||||
|
||||
failed.append(repo.name)
|
||||
continue
|
||||
|
||||
if old != new:
|
||||
ret[repo] = (old, new)
|
||||
return ret
|
||||
ret[updated_repo] = (old, new)
|
||||
|
||||
return ret, failed
|
||||
|
||||
async def _load_repos(self, set_repos: bool = False) -> Dict[str, Repo]:
|
||||
ret = {}
|
||||
|
||||
Reference in New Issue
Block a user