OCA / odoo-module-migrator

Python library to migrate odoo base code from a version to another
GNU Affero General Public License v3.0
123 stars 112 forks source link

Can't fetch previous branch in shallow repository #43

Closed joao-p-marques closed 3 years ago

joao-p-marques commented 3 years ago

When trying to migrate with the --format-patch option, you will sometimes get an error when trying to fetch the commits from the previous version due to a big difference in the commit history:

fatal: bad revision 'origin/14.0..origin/13.0'

That will cause the script to fail:

➤ odoo-module-migrate -m $MODULE --init-version-name 13.0 --target-version-name 14.0 --no-commit --format-patch
10:39:37   INFO        Creating new branch '14.0-mig-payment_redsys' ...
Switched to a new branch '14.0-mig-payment_redsys'
fatal: bad revision 'origin/14.0..origin/13.0'
10:39:37   WARNING     No valid module found for 'payment_redsys' in the directory '/home/jota/Documents/Tecnativa/plantillas/devel-14.0/odoo/custom/src/l10n-spain'
Traceback (most recent call last):
  File "/home/jota/.local/bin/odoo-module-migrate", line 8, in <module>
    sys.exit(main())
  File "/home/jota/.local/pipx/venvs/odoo-module-migrator/lib64/python3.9/site-packages/odoo_module_migrate/__main__.py", line 124, in main
    migration = Migration(
  File "/home/jota/.local/pipx/venvs/odoo-module-migrator/lib64/python3.9/site-packages/odoo_module_migrate/migration.py", line 87, in __init__
    raise ConfigException("No modules found to migrate. Exiting.")
odoo_module_migrate.exception.ConfigException: No modules found to migrate. Exiting.

This script could automatically detect that and perform a git fetch [--unshallow] previous to the format patch.

When you do it manually, it works:

jota@localhost:~/D/T/p/d/o/c/s/l10n-spain|14.0✓
➤ git fetch origin
remote: Enumerating objects: 56197, done.
remote: Counting objects: 100% (56197/56197), done.
remote: Compressing objects: 100% (17352/17352), done.
remote: Total 56197 (delta 37907), reused 55972 (delta 37683), pack-reused 0
Receiving objects: 100% (56197/56197), 71.00 MiB | 1.86 MiB/s, done.
Resolving deltas: 100% (37907/37907), done.
From https://github.com/OCA/l10n-spain
 * [new branch]        10.0       -> origin/10.0
 * [new branch]        11.0       -> origin/11.0
 * [new branch]        12.0       -> origin/12.0
 * [new branch]        13.0       -> origin/13.0
 * [new branch]        4.2        -> origin/4.2
 * [new branch]        5.0        -> origin/5.0
 * [new branch]        6.0        -> origin/6.0
 * [new branch]        6.1        -> origin/6.1
 * [new branch]        7.0        -> origin/7.0
 * [new branch]        8.0        -> origin/8.0
 * [new branch]        9.0        -> origin/9.0
jota@localhost:~/D/T/p/d/o/c/s/l10n-spain|14.0✓
➤ odoo-module-migrate -m $MODULE --init-version-name 13.0 --target-version-name 14.0 --no-commit --format-patch
10:48:14   INFO        Creating new branch '14.0-mig-payment_redsys' ...
Switched to a new branch '14.0-mig-payment_redsys'
10:48:14   INFO        [payment_redsys] Running migration from 13.0 to 14.0
10:48:14   INFO        Bump version to 14.0.1.0.0