mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -05:00
Merge branch 'V3/develop' into V3/develop
This commit is contained in:
@@ -91,6 +91,10 @@ class Downloader(commands.Cog):
|
||||
if self._init_task is not None:
|
||||
self._init_task.cancel()
|
||||
|
||||
async def red_delete_data_for_user(self, **kwargs):
|
||||
""" Nothing to delete """
|
||||
return
|
||||
|
||||
def create_init_task(self):
|
||||
def _done_callback(task: asyncio.Task) -> None:
|
||||
exc = task.exception()
|
||||
@@ -303,10 +307,22 @@ class Downloader(commands.Cog):
|
||||
hashes: Dict[Tuple[Repo, str], Set[InstalledModule]] = defaultdict(set)
|
||||
for module in modules:
|
||||
module.repo = cast(Repo, module.repo)
|
||||
if module.repo.commit != module.commit and await module.repo.is_ancestor(
|
||||
module.commit, module.repo.commit
|
||||
):
|
||||
hashes[(module.repo, module.commit)].add(module)
|
||||
if module.repo.commit != module.commit:
|
||||
try:
|
||||
should_add = await module.repo.is_ancestor(module.commit, module.repo.commit)
|
||||
except errors.UnknownRevision:
|
||||
# marking module for update if the saved commit data is invalid
|
||||
last_module_occurrence = await module.repo.get_last_module_occurrence(
|
||||
module.name
|
||||
)
|
||||
if last_module_occurrence is not None and not last_module_occurrence.disabled:
|
||||
if last_module_occurrence.type == InstallableType.COG:
|
||||
cogs_to_update.add(last_module_occurrence)
|
||||
elif last_module_occurrence.type == InstallableType.SHARED_LIBRARY:
|
||||
libraries_to_update.add(last_module_occurrence)
|
||||
else:
|
||||
if should_add:
|
||||
hashes[(module.repo, module.commit)].add(module)
|
||||
|
||||
update_commits = []
|
||||
for (repo, old_hash), modules_to_check in hashes.items():
|
||||
@@ -776,8 +792,12 @@ class Downloader(commands.Cog):
|
||||
if rev is not None
|
||||
else ""
|
||||
)
|
||||
+ _("\nYou can load them using `{prefix}load <cogs>`").format(
|
||||
prefix=ctx.clean_prefix
|
||||
+ _(
|
||||
"\nYou can load them using {command_1}."
|
||||
" To see end user data statements, you can use {command_2}."
|
||||
).format(
|
||||
command_1=inline(f"{ctx.clean_prefix}load <cogs>"),
|
||||
command_2=inline(f"{ctx.clean_prefix}cog info <repo_name> <cog_name>"),
|
||||
)
|
||||
+ message
|
||||
)
|
||||
@@ -1075,7 +1095,7 @@ class Downloader(commands.Cog):
|
||||
|
||||
if updates_available:
|
||||
updated_cognames, message = await self._update_cogs_and_libs(
|
||||
cogs_to_update, libs_to_update
|
||||
ctx, cogs_to_update, libs_to_update, current_cog_versions=cogs_to_check
|
||||
)
|
||||
else:
|
||||
if repos:
|
||||
@@ -1182,15 +1202,24 @@ class Downloader(commands.Cog):
|
||||
return
|
||||
|
||||
msg = _(
|
||||
"Information on {cog_name}:\n{description}\n\n"
|
||||
"Made by: {author}\nRequirements: {requirements}"
|
||||
"Information on {cog_name}:\n"
|
||||
"{description}\n\n"
|
||||
"End user data statement:\n"
|
||||
"{end_user_data_statement}\n\n"
|
||||
"Made by: {author}\n"
|
||||
"Requirements: {requirements}"
|
||||
).format(
|
||||
cog_name=cog.name,
|
||||
description=cog.description or "",
|
||||
end_user_data_statement=(
|
||||
cog.end_user_data_statement
|
||||
or _("Author of the cog didn't provide end user data statement.")
|
||||
),
|
||||
author=", ".join(cog.author) or _("Missing from info.json"),
|
||||
requirements=", ".join(cog.requirements) or "None",
|
||||
)
|
||||
await ctx.send(box(msg))
|
||||
for page in pagify(msg):
|
||||
await ctx.send(box(page))
|
||||
|
||||
async def is_installed(
|
||||
self, cog_name: str
|
||||
@@ -1380,8 +1409,13 @@ class Downloader(commands.Cog):
|
||||
return (cogs_to_check, failed)
|
||||
|
||||
async def _update_cogs_and_libs(
|
||||
self, cogs_to_update: Iterable[Installable], libs_to_update: Iterable[Installable]
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
cogs_to_update: Iterable[Installable],
|
||||
libs_to_update: Iterable[Installable],
|
||||
current_cog_versions: Iterable[InstalledModule],
|
||||
) -> Tuple[Set[str], str]:
|
||||
current_cog_versions_map = {cog.name: cog for cog in current_cog_versions}
|
||||
failed_reqs = await self._install_requirements(cogs_to_update)
|
||||
if failed_reqs:
|
||||
return (
|
||||
@@ -1396,12 +1430,34 @@ class Downloader(commands.Cog):
|
||||
|
||||
updated_cognames: Set[str] = set()
|
||||
if installed_cogs:
|
||||
updated_cognames = {cog.name for cog in installed_cogs}
|
||||
updated_cognames = set()
|
||||
cogs_with_changed_eud_statement = set()
|
||||
for cog in installed_cogs:
|
||||
updated_cognames.add(cog.name)
|
||||
current_eud_statement = current_cog_versions_map[cog.name].end_user_data_statement
|
||||
if current_eud_statement != cog.end_user_data_statement:
|
||||
cogs_with_changed_eud_statement.add(cog.name)
|
||||
if len(installed_cogs) > 1:
|
||||
message += _("\nUpdated: ") + humanize_list(tuple(map(inline, updated_cognames)))
|
||||
else:
|
||||
message += _("\n{cog} updated.").format(
|
||||
cog=humanize_list(tuple(map(inline, updated_cognames)))
|
||||
message += _("\n{cog} updated.").format(cog=updated_cognames[0])
|
||||
if cogs_with_changed_eud_statement:
|
||||
if len(cogs_with_changed_eud_statement) > 1:
|
||||
message += (
|
||||
_("\nEnd user data statements of these cogs have changed: ")
|
||||
+ humanize_list(tuple(map(inline, cogs_with_changed_eud_statement)))
|
||||
+ _("\nYou can use {command} to see the updated statements.\n").format(
|
||||
command=inline(f"{ctx.clean_prefix}cog info <repo_name> <cog_name>")
|
||||
)
|
||||
else:
|
||||
message += (
|
||||
_("End user data statements for {cog} have been changed.").format(
|
||||
cog=cogs_with_changed_eud_statement[0]
|
||||
)
|
||||
+ _("\nYou can use {command} to see the updated statements.\n").format(
|
||||
command=inline(f"{ctx.clean_prefix}cog info <repo_name> <cog_name>")
|
||||
)
|
||||
)
|
||||
)
|
||||
if failed_cogs:
|
||||
cognames = [cog.name for cog in failed_cogs]
|
||||
@@ -1519,7 +1575,11 @@ class Downloader(commands.Cog):
|
||||
cog_name = self.cog_name_from_instance(cog)
|
||||
installed, cog_installable = await self.is_installed(cog_name)
|
||||
if installed:
|
||||
made_by = humanize_list(cog_installable.author) or _("Missing from info.json")
|
||||
made_by = (
|
||||
humanize_list(cog_installable.author)
|
||||
if cog_installable.author
|
||||
else _("Missing from info.json")
|
||||
)
|
||||
repo_url = (
|
||||
_("Missing from installed repos")
|
||||
if cog_installable.repo is None
|
||||
|
||||
Reference in New Issue
Block a user