Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V3 Downloader] bot_version info.json key not used #1866

palmtree5 opened this issue Jun 12, 2018 · 2 comments · Fixed by #2571

[V3 Downloader] bot_version info.json key not used #1866

palmtree5 opened this issue Jun 12, 2018 · 2 comments · Fixed by #2571
Status: Frozen Type: Enhancement


Copy link

palmtree5 commented Jun 12, 2018

Other bugs

What were you trying to do?

Try putting the minimum required bot version in the info.json

What were you expecting to happen?

This version to be checked

What actually happened?

There is no check for it in the code

How can we reproduce this issue?

  1. Put the bot_version key in the info.json with a value that should cause the cog to not install
  2. Try installing that cog
  3. Cog installed
@palmtree5 palmtree5 added Type: Bug V3 labels Jun 12, 2018
@palmtree5 palmtree5 added this to the Beta 17 milestone Jun 12, 2018
Copy link

Tobotimus commented Aug 1, 2018

Needs more discussion on how we want to use this key. At the very minimum I think it should give a warning when [p]cog update installs the latest version of a cog which has a higher bot version than the one installed. It could also give the warning and hold back the installation, then the user would need to do [p]cog update again once they've updated their bot. Same suggestions apply with [p]cog install.

I'm gonna freeze this until more progress has been made on #1683, as I think there are other features there with higher priority.

@Tobotimus Tobotimus removed this from the Beta 17 milestone Aug 13, 2018
@Tobotimus Tobotimus added Status: Frozen Category: Cogs and removed Category: Cogs labels Aug 13, 2018
calebj added a commit to calebj/Red-DiscordBot that referenced this issue Sep 12, 2018
- Repo and Installable
  - converted to abstract classes
    - standard interface lays groundwork for supporting more types
  - tests are more in-depth
  - Repo and subclasses
    - moved to new files
    - postpone reading folder contents until populate() called
    - seperated folder and git repo subtypes (folder and git)
  - no more MISSING_REPO folder, missing is an error now
  - move executor and subprocesses to RepoManager
  - UpdateResult: new object type describing generalized repo updates
- git and pip commands moved to new file and namespace
  - only uses -t {target} if NOT in a venv or virtualenv
- Downloader UI
  - error on invalid repo names
  - cog update command only updates requested cogs if given
    - also shows what cogs were updated, if any
  - better display for list commands

- Selective updating (req. by @mikeshardmind)
- Storage of installed cog version
- Use bot_version key in info.json (Cog-Creators#1866)
- Changelogs (epic @ Cog-Creators#1683)
@Tobotimus Tobotimus added Type: Enhancement and removed Type: Bug labels Oct 7, 2018
Copy link

jack1142 commented May 5, 2019

This was fixed with #2605, though it still doesn't check it with [p]cog update

@Tobotimus Tobotimus removed the V3 label Jun 29, 2019
jack1142 added a commit to jack1142/Red-DiscordBot that referenced this issue Nov 7, 2019
mikeshardmind pushed a commit that referenced this issue Nov 8, 2019
* feat(downloader): Install cog from specific commit in repo (initial commit)

- Repo and Installable have commit property now
- New class inheriting from Installable -
InstalledCog (old one from removed)
- New Repo.checkout() method, which is also async ctx manager
ref #2527

* fix(downloader): Keep information about repo's branch in config

- This is needed to make sure that repo can go back from detached state in some rare unexpected
- current branch is determined by `git symbolic-ref` now as this command errors for detached

* feat(downloader): Update repo without cogs, update single cog

The most important part of issue #2527 has been added here
- `[p]repo update` command added
- new conf format - nested dictionary repo_name->cog_name->cog_json
  installed libraries are now kept in conf too
  - `InstalledCog` renamed to `InstalledModule` - installed libraries use this class
  - `Downloader.installed_libraries()` and `Downloader.installed_modules()` added
  - `Downloader._add_to_installed()` and `Downloader._remove_from_installed()`
    now accept list of modules, of both cogs and libraries
- `[p]cog install` tells about fails of copying cog and installing shared libraries
- `[p]cog update` will truly update only chosen cogs (if provided) or cogs that need update
  - pinned cogs aren't checked
  - before update, repos are updated
  - to determine if update is needed `Repo.get_modified_modules()` is used
- `[p]cog pin` and `[p]cog unpin` commands for pinning/unpinning cogs added
- `Repo.checkout()` allows to choose ctx manager exit's checkout revision
- `Repo.install_cog()` returns `InstalledModule` now and raises CopyingError (maybe breaking?)
- `Repo.install_libraries()` returns 2-tuple of installed and failed libraries (maybe breaking?)
- `RepoManager.get_all_cogs()` added, which returns cogs from all repos
- `RepoManager.repos` property added, which contains tuple of `Repo`

* test(downloader): Repo.current_branch() throws an exception, when branch can't be determined

* style(downloader): rename _add_to_installed to _save_to_installed

This method is used for both adding and updating existing modules in Config

* refactor(downloader): add ctx.typing() for few commands

`[p]cog install` is nested hell, can't wait for moving install logic to separate method

* fix(downloader): refactor and fix `set` usage

* perf(downloader): update commits for ALL checked modules to omit diffs next time

This will also disable running git diff for cogs that have the same commit as the latest one

* style(downloader): few style improvements

- use of mutable object in method definition
- make Repo._get_full_sha1() public method
- too long
- don't use len to check if sequence is empty

* feat(downloader): add `[p]cog updateallfromrepos` and `[p]cog updatetoversion` commands

- moved cog update logic into `Downloader._cog_update_logic()` (lack of better name)
  - splitted
whole cog update process into smaller methods
  - might still need some improvements
- added new
methods to `Repo` class:
  - `is_on_branch()` to check if repo is currently checked out to branch

- `is_ancestor()` to check if one commit is ancestor of the other
- fix for
`Downloader._available_updates()` behaviour
broken by commit

* feat(downloader): try to find last commit where module is still present

- `Installable` now has `repo` attribute containing repo object or `None` if repo is
- `Downloader._install_cogs()` and `Downloader._reinstall_libraries()` are able to install
modules from different commits of repo
- `Repo.checkout()` as ctx manager will now exit to commit
which was active before checking out
- unification of `rev` and `hash` terms:
All function
parameters are explicitly called `hash`, if it can only be commit's full sha1 hash or `rev` if it
can be anything that names a commit object, see
- new
`Repo.get_last_module_occurence()` method, which gets module's Installable from last commit in which
it still occurs

* docs(downloader): Add basic description for `InstalledModule`

* fix(downloader): cog ignored during updates if its commit was missing

After config format update, commit string is empty until update and when such cog was checked and it
wasn't available in repo anymore, it was ignored

* refactor(downloader): Installing cogs from specific rev will pin them

* perf(downloader): Don't checkout when current commit equals target hash

- changes to `Repo.checkout()`:
  - `exit_to_rev` is now keyword only argument
  - added
`force_checkout` to force checkout even if `Repo.commit` value is the same as target hash

* refactor(downloader): Repo._run() stderr is redirected to debug log now

- added two keyword arguments:
  - `valid_exit_codes` which specifies valid exit codes, used to
determine if stderr should be sent as debug or error level in logging
  - `debug_only` which
specifies if stderr can be sent only as debug level in logging

* style(downloader): stop using `set` as arg name in `_load_repos()`

* feat(downloader): pass multiple cogs to `[p]cog (un)pin`

* refactor(downloader): accept module name instead of instance, fix spelling

* style(downloader): few small style changes

* fix(downloader): add type annotations + fixes based on them

- fix wrong type annotations and add a lot of new ones
- add checks for `Installable.repo` being `None`
- fix wrong return type in `Downloader._install_requirements`
- show repo names correctly when updating all repos
- fix error when some requirement fails to install

- type of `Repo.available_modules` is now consistent (always `tuple`)

* tests: use same event loop policy as in Red's code

* enhance(downloader): fully handle ambiguous revisions

* build(deps): add pytest-mock dependency to tests extra

* fix(downloader): minor fixes

* feat(downloader): add tool for editing Downloader's test repo

This script aims to help update the human-readable version of repo
used for git integration tests in ``redbot/tests/downloader_testrepo.export``
by exporting/importing it in/from provided directory.

Editing `downloader_git_test_repo.export` file manually is strongly discouraged,
especially editing any part of commit directives as that causes a change in the commit's hash.
Another problem devs could encounter when trying to manually edit that file
are editors that will use CRLF instead of LF for new line character(s) and therefore break it.

I also used `.gitattributes` to prevent autocrlf from breaking testrepo.

Also, if Git ever changes currently used SHA-1 to SHA-256 we will have to
update old hashes with new ones. But it's a small drawback,
when we can have human-readable version of repo.

Known limitations
``git fast-export`` exports commits without GPG signs so this script disables it in repo's config.
This also means devs shouldn't use ``--gpg-sign`` flag in ``git commit`` within the test repo.

* tests(downloader): add git tests and test repo for them

Also added Markdown file that is even more clear than export file
on what the test repo contains.
This is manually created but can be automated on later date.

* test(downloader): add more tests related to RepoManager

These tests use expected output that is already guaranteed by git tests.

* chore(CODEOWNERS): add jack1142 to Downloader's folders

I know this doesn't actually give any benefit to people that don't have
write permission to the repo but I saw other big fella devs doing this,
so I think this might be advisable.

* enhance(downloader): allow easy schema updates in future

* enhance(downloader): more typing fixes, add comments for clarity

* feat(downloader): add python and bot version check to update process

follow-up on #2605, this commit fully fixes #1866

* chore(changelog): add towncrier entries

* fix(downloader): use `*args` instead of `commands.Greedy`

* fix(downloader): hot-reload issue - `InstallableType` now inherits from `IntEnum`

There's desync of `InstallableType` class types due to hot-reload
and `IntEnum` allows for equality check between different types

* enhance(downloader): ensure there's no cog with same name installed

should fix #2927

* fix(downloader): last few changes before marking as ready for review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Status: Frozen Type: Enhancement
None yet

Successfully merging a pull request may close this issue.

3 participants