Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.83k stars 2.3k forks source link

[Downloader] Repos set with tag as branch break `[p]cog update` #3397

Open Jackenmen opened 4 years ago

Jackenmen commented 4 years ago

Command bugs

Command name

[p]cog update

What cog is this command from?

Downloader

What were you expecting to happen?

Cog update to proceed without error or at least to error gracefully.

What actually happened?

Got unhandled exception:

Exception in command 'cog update'
Traceback (most recent call last):
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/downloader/downloader.py", line 841, in _cog_update
    await self._cog_update_logic(ctx, cogs=cogs)
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/downloader/downloader.py", line 915, in _cog_update_logic
    cogs_to_check, check_failed = await self._get_cogs_to_check(repos=repos, cogs=cogs)
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/downloader/downloader.py", line 1159, in _get_cogs_to_check
    __, failed = await self._repo_manager.update_repos()
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/downloader/repo_manager.py", line 1175, in update_repos
    updated_repo, (old, new) = await self.update_repo(repo.name)
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/downloader/repo_manager.py", line 1142, in update_repo
    old, new = await repo.update()
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/downloader/repo_manager.py", line 805, in update
    await self.hard_reset()
  File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/downloader/repo_manager.py", line 785, in hard_reset
    raise errors.HardResetError(
redbot.cogs.downloader.errors.HardResetError: Some error occurred when trying to execute a hard reset on the repo at the following path: /home/ubuntu/red-local/cogs/RepoManager/repos/jack-rlstats31

How can we reproduce this issue?

  1. Add repo with a tag as a branch, i.e: [p]repo add jackcogs-test https://github.com/jack1142/JackCogs rlstats-3.1
  2. Run [p]cog update
Stonedestroyer commented 4 years ago

Main issue seems to be that tags can be retrived from origins/tags and the Downloader currently checks if it's a branch and not a tag.

Some solutions could be to do tags/tagname or not allowing tags.

Another one could be that the git repo is retrieved before hand and checks if it's valid before erroring out.