erplibre/script/git/git_repo_update_group.py
Mathieu Benoit 0e5441ac39 [ADD] commentaires : un relevé non bloquant, sa règle, le code nettoyé
Rien ne relevait les commentaires hors convention. L'outil lit commentaires et
docstrings, jamais le code autour, et rend deux familles inégales :
l'identifiant — adresse, courriel, chemin de compte, nom de la liste privée —
est une trouvaille ; le récit — témoignage, date, personne — un signal à relire.

Le hook pre-commit le lance sur l'index, sort toujours en 0 — un contrôle
bloquant à cette échelle se fait désinstaller — et parle quand l'outil échoue.
La règle du générateur et sa doc portent le nettoyage au fur et à mesure, et
l'exemple d'un interdit s'invente : base, adresse, compte et hôte en prennent un.

L'écran du contexte est posé, sans entrée de menu. Vérifié : 252 tests des six
fichiers d'essai touchés passent.

--- EN ---

Nothing reported the comments that break the convention. The tool reads
comments and docstrings, never the code around them, and returns two unequal
families: identifying data — address, e-mail, account path, private-list name
— is a finding; narrative — witness marker, date, person — a signal to re-read.

The pre-commit hook runs it on the index, always exits 0 — a blocking check at
that scale gets uninstalled — and speaks when the tool fails. The generator
rule and its doc carry the clean-up as you go, and a forbidden thing's example
is invented: a real database, address, account and host each take one.

The context screen is in place, with no menu entry. Checked: 252 tests of the
six touched fixture files pass.

Assisted-by: Claude Opus 5
2026-08-30 06:08:30 -04:00

134 lines
4 KiB
Python
Executable file

#!/usr/bin/env python3
# © 2021-2026 TechnoLibre (http://www.technolibre.ca)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
import argparse
import logging
import os
import sys
new_path = os.path.normpath(
os.path.join(os.path.dirname(__file__), "..", "..")
)
sys.path.append(new_path)
from script.execute import execute
from script.git.git_tool import GitTool
_logger = logging.getLogger(__name__)
def get_config():
"""Parse command line arguments, extracting the config file name,
returning the union of config file and command line arguments
:return: dict of config file settings and command line arguments
"""
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""\
Update config.conf file with group specified in manifest file.
""",
epilog="""\
""",
)
parser.add_argument(
"--group",
default="",
help="Prod by default, use 'dev' for manifest/default.dev.xml",
)
parser.add_argument(
"--extra-addons-path",
default="",
help="Separate by , to add extra path for config addons_path",
)
parser.add_argument(
"--ignore-odoo-path",
action="store_true",
help="Will remove odoo path, need this feature for OpenUpgrade when Odoo <= 13",
)
parser.add_argument(
"--from_backup_path",
help="Will read backup path and whitelist the repo",
)
parser.add_argument(
"--from_backup_name",
help="Will read backup name and whitelist the repo",
)
parser.add_argument(
"--add_repo",
help="Add repo, separate by ; for list",
)
parser.add_argument(
"--database",
help="Add repo from module found into database.",
)
args = parser.parse_args()
return args
def main():
config = get_config()
git_tool = GitTool()
execute_cmd = execute.Execute()
index_to_remove = len(os.getcwd()) + 1
filter_group = config.group if config.group else None
whitelist = []
if config.from_backup_path or config.from_backup_name:
# script/database/get_repo_from_backup.py
# --backup_name pir_prod_5_dec_2025_2026-02-04_14h27m54s.zip
if config.from_backup_path:
cmd = f"./script/database/get_repo_from_backup.py --backup_path {config.from_backup_path}"
else:
cmd = f"./script/database/get_repo_from_backup.py --backup_name {config.from_backup_name}"
status, output = execute_cmd.exec_command_live(
cmd,
quiet=True,
source_erplibre=False,
single_source_erplibre=True,
return_status_and_output=True,
)
for line in output:
repo_name = line[index_to_remove:].strip()
whitelist.append(repo_name)
if config.database:
cmd = f"./script/database/get_module_list_from_database.py --database {config.database}"
status, output = execute_cmd.exec_command_live(
cmd,
quiet=True,
source_erplibre=False,
single_source_erplibre=True,
return_status_and_output=True,
)
str_module = ";".join(output)
cmd = f'./script/database/get_repo_from_module.py --module "{str_module}"'
status, output = execute_cmd.exec_command_live(
cmd,
quiet=True,
source_erplibre=False,
single_source_erplibre=True,
return_status_and_output=True,
)
for line in output:
repo_name = line[index_to_remove:].strip()
whitelist.append(repo_name)
if config.add_repo:
extra_repos = [a.strip() for a in config.add_repo.split(";")]
else:
extra_repos = []
git_tool.generate_generate_config(
filter_group=filter_group,
extra_path=config.extra_addons_path,
ignore_odoo_path=config.ignore_odoo_path,
add_repos=extra_repos,
whitelist=whitelist,
)
if __name__ == "__main__":
main()