[FIX] format : rendre repo facultatif, et montrer ce qu'il a dit
Un échec de « repo forall » arrêtait tout : la liste des fichiers locaux, déjà obtenue, était jetée, et « make format » rendait 0 sans avoir formaté une ligne. Sa sortie d'erreur, capturée puis jetée, emportait la seule explication, et seule l'exception Python restait à l'écran. Google Repo n'ajoute pourtant que les dépôts rapatriés : il est joué sans check, ce qu'il a écrit est relayé, et les fichiers locaux sont formatés quand même. « Rien à formater » se dit au lieu d'une sortie muette, et un échec du dépôt lui-même rend non nul. Vérifié : avec un repo bouchonné qui échoue, son message s'affiche et le fichier local est formaté. --- EN --- A failing "repo forall" stopped everything: the local file list, already gathered, was dropped, and "make format" returned 0 without formatting a line. Its error output, captured then thrown away, carried the only explanation, and only the Python exception stayed on screen. Google Repo only adds the checked out repositories: it runs without check, whatever it wrote is relayed, and local files are formatted anyway. "Nothing to format" is said instead of a silent exit, and a failure of the repository itself returns non-zero. Checked: with a stub repo that fails, its message shows and the local file is formatted. Assisted-by: Claude Opus 5
This commit is contained in:
parent
5411b102a9
commit
f33aa8a64f
1 changed files with 25 additions and 4 deletions
|
|
@ -46,18 +46,33 @@ def get_modified_files():
|
|||
|
||||
lst_lines = [(".", lines_local)]
|
||||
|
||||
lines_project = []
|
||||
if lst_cmd_git_status_repo:
|
||||
print(" ".join(lst_cmd_git_status_repo))
|
||||
|
||||
# Google Repo est FACULTATIF ici : il n'ajoute que les dépôts
|
||||
# rapatriés. Son échec laissait pourtant tomber la liste locale
|
||||
# déjà obtenue, et « make format » rendait 0 sans avoir formaté
|
||||
# une ligne. Il est donc joué sans check, et ce qu'il a écrit est
|
||||
# RELAYÉ : capturée puis jetée, sa sortie d'erreur emportait la
|
||||
# seule explication — le hashbang de bin/repo est relatif, si bien
|
||||
# qu'un lancement hors de la racine échoue sans dire pourquoi.
|
||||
result = subprocess.run(
|
||||
lst_cmd_git_status_repo,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
lines_project = result.stdout.strip().split("\n\n")
|
||||
else:
|
||||
lines_project = []
|
||||
if result.returncode:
|
||||
print(
|
||||
f"repo forall a rendu {result.returncode} : les depots"
|
||||
" rapatries sont ignores, les fichiers locaux sont"
|
||||
" formates quand meme."
|
||||
)
|
||||
for flux in (result.stderr, result.stdout):
|
||||
if flux and flux.strip():
|
||||
print(f" {flux.strip()}")
|
||||
else:
|
||||
lines_project = result.stdout.strip().split("\n\n")
|
||||
|
||||
if os.path.isfile(".odoo-version"):
|
||||
with open(".odoo-version") as txt:
|
||||
|
|
@ -163,3 +178,9 @@ if __name__ == "__main__":
|
|||
if status != 0:
|
||||
print(output)
|
||||
sys.exit(status)
|
||||
elif files is None:
|
||||
# get_modified_files a échoué sur le dépôt lui-même : rendre 0
|
||||
# laisserait croire que tout est formaté.
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("Aucun fichier modifie a formater.")
|
||||
|
|
|
|||
Loading…
Reference in a new issue