@roomi-fields/grillhouse 0.29.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +739 -0
- package/bin/grillhouse.mjs +79 -18
- package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
- package/cadre/templates/projet/CLAUDE.md +5 -1
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/projet/package.json +2 -2
- package/charte.md +24 -0
- package/dist/temporal/acte.d.ts +24 -0
- package/dist/temporal/acte.js +139 -0
- package/dist/temporal/acte.js.map +1 -0
- package/dist/temporal/attributs.d.ts +6 -0
- package/dist/temporal/attributs.js +15 -0
- package/dist/temporal/attributs.js.map +1 -0
- package/dist/temporal/circuit/activites.d.ts +13 -0
- package/dist/temporal/circuit/activites.js +33 -0
- package/dist/temporal/circuit/activites.js.map +1 -0
- package/dist/temporal/circuit/client.d.ts +72 -0
- package/dist/temporal/circuit/client.js +247 -0
- package/dist/temporal/circuit/client.js.map +1 -0
- package/dist/temporal/circuit/commande.d.ts +2 -0
- package/dist/temporal/circuit/commande.js +238 -0
- package/dist/temporal/circuit/commande.js.map +1 -0
- package/dist/temporal/circuit/contrat.d.ts +305 -0
- package/dist/temporal/circuit/contrat.js +24 -0
- package/dist/temporal/circuit/contrat.js.map +1 -0
- package/dist/temporal/circuit/deroule.d.ts +3 -0
- package/dist/temporal/circuit/deroule.js +540 -0
- package/dist/temporal/circuit/deroule.js.map +1 -0
- package/dist/temporal/client.d.ts +47 -0
- package/dist/temporal/client.js +69 -0
- package/dist/temporal/client.js.map +1 -0
- package/dist/temporal/commande.d.ts +2 -0
- package/dist/temporal/commande.js +95 -0
- package/dist/temporal/commande.js.map +1 -0
- package/dist/temporal/deroules.d.ts +5 -0
- package/dist/temporal/deroules.js +10 -0
- package/dist/temporal/deroules.js.map +1 -0
- package/dist/temporal/etat.d.ts +33 -0
- package/dist/temporal/etat.js +59 -0
- package/dist/temporal/etat.js.map +1 -0
- package/dist/temporal/file/activites.d.ts +10 -0
- package/dist/temporal/file/activites.js +25 -0
- package/dist/temporal/file/activites.js.map +1 -0
- package/dist/temporal/file/client.d.ts +4 -0
- package/dist/temporal/file/client.js +6 -0
- package/dist/temporal/file/client.js.map +1 -0
- package/dist/temporal/file/contrat.d.ts +158 -0
- package/dist/temporal/file/contrat.js +14 -0
- package/dist/temporal/file/contrat.js.map +1 -0
- package/dist/temporal/file/deroule.d.ts +15 -0
- package/dist/temporal/file/deroule.js +235 -0
- package/dist/temporal/file/deroule.js.map +1 -0
- package/dist/temporal/installation.d.ts +124 -0
- package/dist/temporal/installation.js +408 -0
- package/dist/temporal/installation.js.map +1 -0
- package/dist/temporal/places/activites.d.ts +8 -0
- package/dist/temporal/places/activites.js +13 -0
- package/dist/temporal/places/activites.js.map +1 -0
- package/dist/temporal/places/client.d.ts +28 -0
- package/dist/temporal/places/client.js +64 -0
- package/dist/temporal/places/client.js.map +1 -0
- package/dist/temporal/places/contrat.d.ts +106 -0
- package/dist/temporal/places/contrat.js +21 -0
- package/dist/temporal/places/contrat.js.map +1 -0
- package/dist/temporal/places/deroule.d.ts +3 -0
- package/dist/temporal/places/deroule.js +198 -0
- package/dist/temporal/places/deroule.js.map +1 -0
- package/dist/temporal/sonde/activites.d.ts +6 -0
- package/dist/temporal/sonde/activites.js +52 -0
- package/dist/temporal/sonde/activites.js.map +1 -0
- package/dist/temporal/sonde/contrat.d.ts +35 -0
- package/dist/temporal/sonde/contrat.js +10 -0
- package/dist/temporal/sonde/contrat.js.map +1 -0
- package/dist/temporal/sonde/deroule.d.ts +3 -0
- package/dist/temporal/sonde/deroule.js +39 -0
- package/dist/temporal/sonde/deroule.js.map +1 -0
- package/dist/temporal/tickets/activites.d.ts +7 -0
- package/dist/temporal/tickets/activites.js +81 -0
- package/dist/temporal/tickets/activites.js.map +1 -0
- package/dist/temporal/tickets/client.d.ts +10 -0
- package/dist/temporal/tickets/client.js +31 -0
- package/dist/temporal/tickets/client.js.map +1 -0
- package/dist/temporal/tickets/contrat.d.ts +56 -0
- package/dist/temporal/tickets/contrat.js +13 -0
- package/dist/temporal/tickets/contrat.js.map +1 -0
- package/dist/temporal/tickets/deroule.d.ts +3 -0
- package/dist/temporal/tickets/deroule.js +94 -0
- package/dist/temporal/tickets/deroule.js.map +1 -0
- package/dist/temporal/travailleur.d.ts +2 -0
- package/dist/temporal/travailleur.js +69 -0
- package/dist/temporal/travailleur.js.map +1 -0
- package/docs/ARCHITECTURE.md +609 -80
- package/docs/CADRE.md +17 -0
- package/docs/INTERFACE.md +134 -42
- package/hooks/crochet.mjs +19 -2
- package/hooks/hooks.json +11 -0
- package/package.json +16 -4
- package/scripts/activites.mjs +2182 -0
- package/scripts/aiguillage.d.mts +37 -0
- package/scripts/aiguillage.mjs +7 -3
- package/scripts/avancement.mjs +128 -16
- package/scripts/bilan.mjs +37 -19
- package/scripts/cadre.mjs +11 -2
- package/scripts/circuit.mjs +881 -4059
- package/scripts/circuits-cles.d.mts +4 -0
- package/scripts/circuits-cles.mjs +21 -0
- package/scripts/circuits-du-serveur.mjs +105 -0
- package/scripts/codes-de-sortie.mjs +9 -0
- package/scripts/commandes-composees.mjs +45 -41
- package/scripts/commandes-du-path.d.mts +7 -0
- package/scripts/commandes-du-path.mjs +25 -0
- package/scripts/composition-des-langages.mjs +16 -12
- package/scripts/conformite.mjs +6 -13
- package/scripts/copies-finies.mjs +52 -47
- package/scripts/depart-du-ticket.d.mts +53 -0
- package/scripts/depart-du-ticket.mjs +124 -0
- package/scripts/dependances-internes.mjs +115 -0
- package/scripts/dernier-vert.mjs +7 -15
- package/scripts/donnees-cles.mjs +228 -0
- package/scripts/droits.mjs +11 -1
- package/scripts/effets.mjs +352 -0
- package/scripts/enveloppe/enveloppe.mjs +119 -8
- package/scripts/enveloppe/lancer.sh +14 -18
- package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
- package/scripts/enveloppe/travail-de-la-copie.mjs +5 -1
- package/scripts/etapes.mjs +5 -2
- package/scripts/faits-du-circuit.mjs +493 -0
- package/scripts/file-des-tickets.d.mts +21 -0
- package/scripts/file-des-tickets.mjs +58 -0
- package/scripts/flux-des-paquets.mjs +187 -0
- package/scripts/gardes-du-cadre.mjs +12 -2
- package/scripts/integration/file.mjs +475 -420
- package/scripts/integration/integrer.mjs +17 -19
- package/scripts/integration/rejeu.mjs +19 -4
- package/scripts/jointure.d.ts +145 -27
- package/scripts/langages/cargo/commandes.mjs +289 -109
- package/scripts/langages/cargo/composants.mjs +130 -34
- package/scripts/langages/cargo/exemples.mjs +12 -21
- package/scripts/langages/cargo/index.mjs +18 -8
- package/scripts/langages/cargo/sccache.mjs +8 -14
- package/scripts/langages/python/commandes.mjs +216 -100
- package/scripts/langages/python/composants.mjs +53 -21
- package/scripts/langages/python/exemples.mjs +6 -16
- package/scripts/langages/python/index.mjs +24 -8
- package/scripts/langages/python/lot.mjs +1 -36
- package/scripts/langages/typescript/construire.mjs +6 -163
- package/scripts/langages/typescript/exemples.mjs +3 -11
- package/scripts/langages/typescript/frontieres.mjs +1 -1
- package/scripts/langages/typescript/index.mjs +43 -61
- package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
- package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
- package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
- package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
- package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
- package/scripts/langages/typescript/tests-de-nuit.mjs +12 -9
- package/scripts/langages/typescript/tests.mjs +17 -8
- package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
- package/scripts/langages/typescript/verdict.mjs +1 -1
- package/scripts/langages/typescript/verifier.mjs +31 -11
- package/scripts/langages/typescript/vitest-config/base.mjs +22 -1
- package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
- package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
- package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
- package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
- package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +49 -63
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +3 -0
- package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
- package/scripts/mesure/pression.mjs +3 -3
- package/scripts/mesure-de-la-machine.d.mts +21 -0
- package/scripts/mesure-de-la-machine.mjs +76 -0
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
- package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
- package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
- package/scripts/migrations.mjs +5 -0
- package/scripts/nuit.sh +10 -3
- package/scripts/outils-cles.d.mts +24 -0
- package/scripts/outils-cles.mjs +0 -1
- package/scripts/paquet-npm.mjs +147 -0
- package/scripts/paquet.mjs +73 -4
- package/scripts/paquets.mjs +34 -6
- package/scripts/passe-de-la-machine.mjs +66 -0
- package/scripts/places-de-la-machine.mjs +360 -0
- package/scripts/places-du-serveur.mjs +170 -0
- package/scripts/prefixe-des-tickets.mjs +68 -0
- package/scripts/preparation.mjs +10 -3
- package/scripts/registre.mjs +3 -2
- package/scripts/regles-des-places.d.mts +36 -0
- package/scripts/regles-des-places.mjs +70 -0
- package/scripts/reponses-du-circuit.d.mts +6 -0
- package/scripts/reponses-du-circuit.mjs +28 -0
- package/scripts/resultats.mjs +7 -9
- package/scripts/retirer-les-copies-finies.mjs +25 -0
- package/scripts/sans-reponse.d.mts +4 -0
- package/scripts/sans-reponse.mjs +13 -0
- package/scripts/seances.mjs +918 -0
- package/scripts/services-du-noyau.mjs +26 -8
- package/scripts/session-start.sh +2 -2
- package/scripts/sortie.mjs +3 -3
- package/scripts/sous-commandes.mjs +38 -9
- package/scripts/style-a-l-ecriture.mjs +229 -0
- package/scripts/superviseur.mjs +122 -111
- package/scripts/tableau.mjs +148 -110
- package/scripts/taches-du-graphe.mjs +328 -0
- package/scripts/ticket-du-circuit.mjs +206 -0
- package/scripts/transitions.d.mts +148 -0
- package/scripts/transitions.mjs +901 -0
- package/scripts/verrou-de-fichier.mjs +2 -2
- package/scripts/verrou-de-machine.mjs +28 -13
- package/skills/explorateur/SKILL.md +2 -1
- package/skills/pitmaster/SKILL.md +17 -18
- package/skills/pitmaster/references/consigne-agent.md +5 -1
- package/skills/release/SKILL.md +3 -3
- package/skills/relecteur/SKILL.md +4 -2
- package/skills/testwriter/SKILL.md +36 -24
- package/scripts/demon.mjs +0 -251
- package/scripts/integration/file-attente.mjs +0 -61
- package/scripts/langages/cargo/touches.mjs +0 -93
- package/scripts/langages/typescript/script-des-tests.mjs +0 -6
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// in
|
|
4
|
-
//
|
|
5
|
-
// by the supervisor by hand.
|
|
1
|
+
// The gestures of the queue, which brings the branches `agent/<ticket>` the integration committed
|
|
2
|
+
// onto main, one at a time: the workflow of the queue of a project (`file:<racine>`,
|
|
3
|
+
// src/temporal/file/deroule.ts) plays them, each in an act of its own (scripts/faits-du-circuit.mjs),
|
|
4
|
+
// for the entries the circuits of the tickets send it at their step 5.2, in their order of arrival.
|
|
6
5
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// No argument, or `--ci <ticket>` (below; exit 2 and the usage otherwise). It takes the branches waiting one by one until none is
|
|
10
|
-
// left, then exits 0, whatever became of each branch. A queue launched while another runs exits 0 at
|
|
11
|
-
// once, refusing nothing: the running queue takes the branch that arrived (it reads the entries
|
|
12
|
-
// again before it lets go of its lock, `.git/file-integration.lock`).
|
|
13
|
-
//
|
|
14
|
-
// For each branch, against the main of the moment:
|
|
6
|
+
// For each branch, against the main of the moment (`avancerMain`):
|
|
15
7
|
// - main is an ancestor of the branch (main has not moved since its base): main moves forward onto
|
|
16
8
|
// the branch (`merge --ff-only`), nothing replayed;
|
|
17
9
|
// - main has moved: the branch is replaced on main in the queue's own copy
|
|
@@ -36,17 +28,20 @@
|
|
|
36
28
|
// - a branch that does not replace (the files in conflict) or whose `npm run verifier` is red once
|
|
37
29
|
// replaced leaves the queue: its ticket loses `en-file`, reopens with a comment that
|
|
38
30
|
// names the files or ends with the output of the tests, and the branch stays where it is, for
|
|
39
|
-
// the
|
|
31
|
+
// the resumption of its circuit;
|
|
40
32
|
// - a branch whose replay cannot be done (the copy does not get ready, main does not take the
|
|
41
33
|
// branch, the main tree holds a file of the lot), or whose `npm run verifier` is « à repasser »
|
|
42
34
|
// once replaced (75: the wait for the lock of the machine reached its bound,
|
|
43
35
|
// scripts/verrou-de-machine.mjs; neither green nor red), stays in the queue, the reason written to its
|
|
44
|
-
// ticket, which is neither reopened nor closed, and the queue goes on; the
|
|
45
|
-
// again. Any other code than 0 and
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// ticket, which closes all the same.
|
|
36
|
+
// ticket, which is neither reopened nor closed, and the queue goes on; the circuit of the ticket
|
|
37
|
+
// stops at « a-repasser », and its resumption sends the branch again. Any other code than 0 and
|
|
38
|
+
// 75 is red.
|
|
39
|
+
// At its entry on main, the branch's ticket closes « intégré : <commit> », loses `en-file`, and the
|
|
40
|
+
// branch is deleted; a branch git does not delete (its copy still in place) is written to the
|
|
41
|
+
// ticket, which closes all the same. The working directory of its circuit
|
|
42
|
+
// (`.claude/worktrees/<ticket>.travail`, scripts/circuit.mjs), which lives as long as the ticket
|
|
43
|
+
// and holds the progress the board reads, the CI's included, is removed when the queue is done
|
|
44
|
+
// with the ticket closed: its CI concluded, or its push not made (`retirerLeTravail`). Then main is pushed to origin, on the branch
|
|
50
45
|
// `grillhouse.poussee.commit` of main's package.json (`main` without the key); a refused push is
|
|
51
46
|
// written to the ticket and does not stop the queue.
|
|
52
47
|
// Once pushed, the queue reads the CI of the commit pushed, as a merge queue waits for its checks.
|
|
@@ -55,56 +50,52 @@
|
|
|
55
50
|
// branch it pushes to (`fluxDeLaBranche`, the files `.github/workflows/*.yml` and `*.yaml`, their
|
|
56
51
|
// `on` and its filters as GitHub reads them); with none, the ticket is told in one line that
|
|
57
52
|
// there is no CI for that branch, and nothing is waited for. A workflow the queue cannot judge (a
|
|
58
|
-
// file it cannot read, a filter on the paths) counts as one that runs. With one,
|
|
59
|
-
// run (`gh run list --commit <sha> --json
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
// commit
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
// CI read as above (`relireCI`); green, the ticket closes « intégré : <commit> », the run named at
|
|
76
|
-
// it; red or not read, it stays open, the reading at the ticket. A flaky test has no path of its
|
|
77
|
-
// own: the red comment gives the charter's rule, a test known red goes into quarantine in the test
|
|
78
|
-
// itself, with the ticket that fixes it. It takes no lock: it does not move main.
|
|
53
|
+
// file it cannot read, a filter on the paths) counts as one that runs. With one, each reading
|
|
54
|
+
// (`lireUneFoisLaCI`) looks for its run (`gh run list --commit <sha> --json
|
|
55
|
+
// databaseId,status,conclusion`), then reads it (`gh run view <id> --json status,conclusion,jobs`),
|
|
56
|
+
// as `gh run watch` does; the workflow of the CI of the commit spaces the readings and bounds the
|
|
57
|
+
// search and the wait (`ciDuCommit`). Green on the conclusion `success`, red on any other. Under
|
|
58
|
+
// the circuit's progress directory (scripts/avancement.mjs), each reading writes there the steps
|
|
59
|
+
// of the run done over planned, which the board shows. A red CI reopens the ticket (`bd reopen`),
|
|
60
|
+
// its comment giving the address of the run (`gh run view <id> --json url`) and the end of `gh run
|
|
61
|
+
// view <id> --log-failed` (`conclureLaCI`). Without `gh`, without a run found, with `gh` refusing
|
|
62
|
+
// or past the wait, the ticket is told that the CI was not read, and why, and stays closed. The
|
|
63
|
+
// run is read at its current attempt (`gh run view <id>` without `--attempt`), as a merge queue
|
|
64
|
+
// judges the last attempt of a commit's checks: after a red CI, `--reprendre` reads again the CI
|
|
65
|
+
// of the ticket's commit on main (`situerLeLot`), once the supervisor had the failed jobs run
|
|
66
|
+
// again (`gh run rerun <id> --failed`); green, the ticket closes « intégré : <commit> », the run
|
|
67
|
+
// named at it; red or not read, it stays open, the reading at the ticket. A flaky test has no path
|
|
68
|
+
// of its own: the red comment gives the charter's rule, a test known red goes into quarantine in
|
|
69
|
+
// the test itself, with the ticket that fixes it.
|
|
79
70
|
// Every comment and change of the queue at a ticket is written under the author `file`, which bd
|
|
80
71
|
// reads in BEADS_ACTOR, as the circuit writes its own lines under `circuit`.
|
|
81
72
|
import { spawnSync } from 'node:child_process';
|
|
82
73
|
import { existsSync, rmSync } from 'node:fs';
|
|
83
74
|
import { createRequire } from 'node:module';
|
|
84
75
|
import path from 'node:path';
|
|
85
|
-
import { pathToFileURL } from 'node:url';
|
|
86
76
|
import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
|
|
77
|
+
import { avecLesDonnees, donneesDe } from '../donnees-cles.mjs';
|
|
87
78
|
import { avecLesOutils, outilsDe } from '../outils-cles.mjs';
|
|
88
79
|
import { lireCommit } from '../poussee-cles.mjs';
|
|
89
80
|
import { commitsDelivering, gitLog } from '../un-commit-par-ticket.mjs';
|
|
90
|
-
import { attendreUnPeu, lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
|
|
91
|
-
import { dossierCommun, lireEntrees, retirerEntree } from './file-attente.mjs';
|
|
92
81
|
import { ouvrirCopie } from './rejeu.mjs';
|
|
93
|
-
import { A_REPASSER } from '../
|
|
94
|
-
import {
|
|
82
|
+
import { A_REPASSER } from '../codes-de-sortie.mjs';
|
|
83
|
+
import { ecrireTache } from '../mesure/avancement.mjs';
|
|
84
|
+
import { ACTEUR, emettre } from '../effets.mjs';
|
|
85
|
+
import { enUneLigne } from '../ticket-du-circuit.mjs';
|
|
95
86
|
|
|
96
87
|
const ESSAIS_PAR_BRANCHE = 5;
|
|
97
|
-
// The
|
|
98
|
-
const ACTEUR = 'BEADS_ACTOR';
|
|
88
|
+
// The queue's author.
|
|
99
89
|
export const AUTEUR_DE_LA_FILE = 'file';
|
|
90
|
+
|
|
91
|
+
// The comment <texte> at <ticket> with the tools <o>, by the queue: the effect `commentaire`
|
|
92
|
+
// (../effets.mjs), written at once by the queue on its file, gathered by an act of the queue under
|
|
93
|
+
// Temporal, which the workflow writes in an activity of its own, under its key.
|
|
94
|
+
const commenterAu = (o, ticket, texte) =>
|
|
95
|
+
emettre(o, { genre: 'commentaire', ticket, texte, auteur: AUTEUR_DE_LA_FILE });
|
|
100
96
|
// The reason of the closure of a ticket the queue brought onto main, before its commit, which the
|
|
101
97
|
// circuit reads to name that commit (scripts/circuit.mjs, the tri of the discoveries).
|
|
102
98
|
export const INTEGRE = 'intégré : ';
|
|
103
|
-
// How long the queue looks for the run of the CI, then waits for it.
|
|
104
|
-
const RECHERCHE_CI_MS = 2 * 60 * 1000;
|
|
105
|
-
const ATTENTE_CI_MS = 30 * 60 * 1000;
|
|
106
|
-
// The gap between two readings of the run, as `gh run watch` reads it again.
|
|
107
|
-
const PAS_CI_MS = 10 * 1000;
|
|
108
99
|
// The steps done over planned of the view <vue> of a run (`gh run view --json jobs`), written to
|
|
109
100
|
// the progress directory <avancement> as the record `etapes-de-la-ci`; nothing without one.
|
|
110
101
|
function ecrireLesEtapes(avancement, vue) {
|
|
@@ -122,11 +113,6 @@ function ecrireLesEtapes(avancement, vue) {
|
|
|
122
113
|
}
|
|
123
114
|
}
|
|
124
115
|
|
|
125
|
-
const delai = (variable, defaut) => {
|
|
126
|
-
const v = Number(process.env[variable]);
|
|
127
|
-
return Number.isFinite(v) && process.env[variable] !== '' && v >= 0 ? v : defaut;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
116
|
// The directory of the workflows GitHub reads, and the extensions it reads in it.
|
|
131
117
|
const DOSSIER_DES_FLUX = '.github/workflows';
|
|
132
118
|
const EXTENSIONS_DES_FLUX = /\.ya?ml$/;
|
|
@@ -213,9 +199,8 @@ export function fluxDeLaBranche(fichiers, branche) {
|
|
|
213
199
|
.map(({ chemin }) => chemin);
|
|
214
200
|
}
|
|
215
201
|
|
|
216
|
-
// The verdicts of a reading of the CI (`
|
|
202
|
+
// The verdicts of a reading of the CI (`lireUneFoisLaCI`, then the workflow `ciDuCommit`).
|
|
217
203
|
const VERTE = 'verte';
|
|
218
|
-
const ROUGE = 'rouge';
|
|
219
204
|
const SANS_CI = 'sans-ci';
|
|
220
205
|
const NON_LUE = 'non-lue';
|
|
221
206
|
|
|
@@ -244,407 +229,477 @@ const ghDans =
|
|
|
244
229
|
...options,
|
|
245
230
|
});
|
|
246
231
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return { verdict: SANS_CI, passage: null };
|
|
263
|
-
}
|
|
264
|
-
const { gh } = o;
|
|
265
|
-
const nonLue = raison => {
|
|
266
|
-
commenter(`## CI non lue\n\nLa CI de ${court} n'a pas été lue : ${raison}`);
|
|
267
|
-
o.dire(`⚠ CI de ${court} non lue : ${raison}`);
|
|
268
|
-
return { verdict: NON_LUE, passage: null };
|
|
232
|
+
/**
|
|
233
|
+
* The tools of the queue on the main tree <racine>, its lines said by <dire>: `{ racine,
|
|
234
|
+
* principale, bd, gh, dire, avancement }`, bd run under the queue's author (BEADS_ACTOR), the
|
|
235
|
+
* branch of the main tree (null when it is on none).
|
|
236
|
+
*/
|
|
237
|
+
export function outilsDeLaFile(racine, dire, avancement = null) {
|
|
238
|
+
const bd = (...a) => {
|
|
239
|
+
const r = spawnSync('bd', a, {
|
|
240
|
+
cwd: racine,
|
|
241
|
+
encoding: 'utf8',
|
|
242
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
243
|
+
env: { ...process.env, [ACTEUR]: AUTEUR_DE_LA_FILE },
|
|
244
|
+
});
|
|
245
|
+
if (r.status !== 0) process.stderr.write(`bd ${a[0]} ${a[1] ?? ''} : ${r.stderr}`);
|
|
246
|
+
return r;
|
|
269
247
|
};
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
248
|
+
const principale =
|
|
249
|
+
spawnSync('git', ['-C', racine, 'symbolic-ref', '--short', '-q', 'HEAD'], {
|
|
250
|
+
encoding: 'utf8',
|
|
251
|
+
}).stdout.trim() || null;
|
|
252
|
+
return { racine, principale, bd, gh: ghDans(racine), dire, avancement };
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* One reading of the CI of the commit <sha> pushed to <branche>, with the tools <o> (`outilsDeLaFile`),
|
|
257
|
+
* the run <passage> found by a reading before (null while it is looked for): `{ etat: 'sans-ci' }`
|
|
258
|
+
* (no workflow runs on a push to the branch), `{ etat: 'cherche' }` (no run yet), `{ etat:
|
|
259
|
+
* 'en-cours', passage }`, `{ etat: 'finie', passage, conclusion }`, or `{ etat: 'non-lue', raison
|
|
260
|
+
* }` (gh absent, refusing, or its output unreadable). The run is read at its current attempt
|
|
261
|
+
* (`gh run view <id>` without `--attempt`). A run found is read at once. It writes nothing to the
|
|
262
|
+
* ticket: `conclureLaCI` does.
|
|
263
|
+
*/
|
|
264
|
+
export function lireUneFoisLaCI(o, { sha, branche, passage = null }) {
|
|
265
|
+
const { gh } = o;
|
|
266
|
+
let id = passage;
|
|
267
|
+
if (id === null) {
|
|
268
|
+
if (fluxDuCommit(o.racine, sha, branche).length === 0) return { etat: SANS_CI };
|
|
274
269
|
const r = gh(['run', 'list', '--commit', sha, '--json', 'databaseId,status,conclusion']);
|
|
275
|
-
if (r.error)
|
|
276
|
-
|
|
270
|
+
if (r.error) {
|
|
271
|
+
return { etat: NON_LUE, raison: `gh ne se lance pas (${r.error.code ?? r.error.message}).` };
|
|
272
|
+
}
|
|
273
|
+
if (r.status !== 0) {
|
|
274
|
+
return { etat: NON_LUE, raison: `gh run list refuse :\n${`${r.stderr}${r.stdout}`.trim()}` };
|
|
275
|
+
}
|
|
277
276
|
let passages = [];
|
|
278
277
|
try {
|
|
279
278
|
passages = JSON.parse(r.stdout || '[]');
|
|
280
279
|
} catch {
|
|
281
|
-
return
|
|
280
|
+
return {
|
|
281
|
+
etat: NON_LUE,
|
|
282
|
+
raison: `gh run list rend une sortie illisible :\n${r.stdout.trim()}`,
|
|
283
|
+
};
|
|
282
284
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
attendreUnPeu(Math.min(10_000, reste));
|
|
285
|
+
const trouve = passages.find(x => x?.databaseId);
|
|
286
|
+
if (!trouve) return { etat: 'cherche' };
|
|
287
|
+
id = String(trouve.databaseId);
|
|
287
288
|
}
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
const v = gh(['run', 'view', id, '--json', 'status,conclusion,jobs'], {
|
|
290
|
+
timeout: 60_000,
|
|
291
|
+
killSignal: 'SIGKILL',
|
|
292
|
+
});
|
|
293
|
+
if (v.error) {
|
|
294
|
+
return { etat: NON_LUE, raison: `gh ne se lance pas (${v.error.code ?? v.error.message}).` };
|
|
290
295
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
killSignal: 'SIGKILL',
|
|
300
|
-
});
|
|
301
|
-
if (v.error) return nonLue(`gh ne se lance pas (${v.error.code ?? v.error.message}).`);
|
|
302
|
-
if (v.status !== 0) return nonLue(`gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}`);
|
|
303
|
-
try {
|
|
304
|
-
vue = JSON.parse(v.stdout || '{}');
|
|
305
|
-
} catch {
|
|
306
|
-
return nonLue(`gh run view rend une sortie illisible :\n${v.stdout.trim()}`);
|
|
307
|
-
}
|
|
308
|
-
ecrireLesEtapes(o.avancement, vue);
|
|
309
|
-
if (vue?.status === 'completed') break;
|
|
310
|
-
const reste = limite - Date.now();
|
|
311
|
-
if (reste <= 0) {
|
|
312
|
-
return nonLue(`le passage ${id} n'a pas fini en ${Math.round(attente / 60_000)} min.`);
|
|
313
|
-
}
|
|
314
|
-
attendreUnPeu(Math.min(pas, reste));
|
|
296
|
+
if (v.status !== 0) {
|
|
297
|
+
return { etat: NON_LUE, raison: `gh run view refuse :\n${`${v.stderr}${v.stdout}`.trim()}` };
|
|
298
|
+
}
|
|
299
|
+
let vue;
|
|
300
|
+
try {
|
|
301
|
+
vue = JSON.parse(v.stdout || '{}');
|
|
302
|
+
} catch {
|
|
303
|
+
return { etat: NON_LUE, raison: `gh run view rend une sortie illisible :\n${v.stdout.trim()}` };
|
|
315
304
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return {
|
|
305
|
+
ecrireLesEtapes(o.avancement, vue);
|
|
306
|
+
if (vue?.status === 'completed') {
|
|
307
|
+
return { etat: 'finie', passage: id, conclusion: vue.conclusion ?? null };
|
|
319
308
|
}
|
|
320
|
-
|
|
321
|
-
const journal = `${gh(['run', 'view', id, '--log-failed']).stdout ?? ''}`
|
|
322
|
-
.trim()
|
|
323
|
-
.split('\n')
|
|
324
|
-
.slice(-60)
|
|
325
|
-
.join('\n');
|
|
326
|
-
commenter(
|
|
327
|
-
`## CI rouge\n\nLa CI de ${court} sur ${o.principale} est rouge : ${url}\n\nLa fin de gh run view ${id} --log-failed :\n\n${journal}\n\nLe ticket est rouvert : sa correction entre sous son numéro. Un rejeu vert de la même CI (\`gh run rerun ${id} --failed\`), puis \`--reprendre\` du circuit, le ferme ; un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`
|
|
328
|
-
);
|
|
329
|
-
o.dire(`✗ CI de ${court} rouge (passage ${id}) : ${ticket} rouvert`);
|
|
330
|
-
return { verdict: ROUGE, passage: id };
|
|
309
|
+
return { etat: 'en-cours', passage: id };
|
|
331
310
|
}
|
|
332
311
|
|
|
333
312
|
/**
|
|
334
|
-
* The
|
|
335
|
-
*
|
|
336
|
-
* queue judges the last attempt of a commit's checks, a run whose failed jobs were run again green
|
|
337
|
-
* is green. The commit is the last of main that delivers the ticket (its title line names it,
|
|
338
|
-
* `commitsDelivering` of ../un-commit-par-ticket.mjs, the prefix read from bd); green, or no CI
|
|
339
|
-
* for the branch pushed to, the ticket closes as an entry closes it (« intégré : <commit> »), its
|
|
340
|
-
* run named at the ticket; red or not read, it stays open, the reading at the ticket. No commit of
|
|
341
|
-
* main delivering it, or its branch `agent/<ticket>` still ahead of main (a lot not yet on main),
|
|
342
|
-
* the ticket is told that the CI is not read again. Exit 0.
|
|
313
|
+
* The working directory of the circuit of <ticket> in the main tree of <o> removed, once the queue
|
|
314
|
+
* is done with the ticket closed: as the workspace of a pipeline, it lives as long as the ticket.
|
|
343
315
|
*/
|
|
344
|
-
export function
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
316
|
+
export function retirerLeTravail(o, ticket) {
|
|
317
|
+
rmSync(path.join(o.racine, '.claude', 'worktrees', `${ticket}.travail`), {
|
|
318
|
+
recursive: true,
|
|
319
|
+
force: true,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The CI of the commit <sha> of the ticket <ticket> concluded with the tools <o>, its verdict
|
|
325
|
+
* <verdict> (VERTE, `rouge`, SANS_CI or NON_LUE), its run <passage> and the reason <raison> of a CI
|
|
326
|
+
* not read, after the queue's entry, or read again (<relue>, on `--reprendre`): what is said to the
|
|
327
|
+
* ticket and what becomes of it. No CI, the ticket is told so in one line; not read, it is told
|
|
328
|
+
* why; red, its comment gives the address of the run and the end of its failed log, and the
|
|
329
|
+
* queue's entry reopens it (read again, it stays open). Green or no CI read again, the ticket
|
|
330
|
+
* closes « intégré : <commit> », its run named. `{ etat, raison }`: `ferme` or `rouvert`, as the
|
|
331
|
+
* circuit reads the issue of the queue (src/temporal/file/deroule.ts); `ferme`, the working
|
|
332
|
+
* directory of its circuit is removed (`retirerLeTravail`).
|
|
333
|
+
*/
|
|
334
|
+
export function conclureLaCI(
|
|
335
|
+
o,
|
|
336
|
+
{ ticket, sha, branche, verdict, passage = null, raison = null, relue = false }
|
|
337
|
+
) {
|
|
338
|
+
const court = sha.slice(0, 7);
|
|
339
|
+
const commenter = texte => commenterAu(o, ticket, texte);
|
|
340
|
+
if (verdict === SANS_CI) {
|
|
341
|
+
const texte = `Aucune CI pour origin/${branche} : aucun flux de ${DOSSIER_DES_FLUX} de ${court} ne se lance sur la branche ${branche}, la file n'en attend pas.`;
|
|
342
|
+
commenter(texte);
|
|
343
|
+
o.dire(`✓ ${texte}`);
|
|
344
|
+
} else if (verdict === NON_LUE) {
|
|
345
|
+
commenter(`## CI non lue\n\nLa CI de ${court} n'a pas été lue : ${raison}`);
|
|
346
|
+
o.dire(`⚠ CI de ${court} non lue : ${raison}`);
|
|
347
|
+
} else if (verdict === VERTE) {
|
|
348
|
+
o.dire(`✓ CI de ${court} verte (passage ${passage})`);
|
|
349
|
+
} else {
|
|
350
|
+
const { gh } = o;
|
|
351
|
+
const url =
|
|
352
|
+
gh(['run', 'view', passage, '--json', 'url', '--jq', '.url']).stdout?.trim() || passage;
|
|
353
|
+
const journal = `${gh(['run', 'view', passage, '--log-failed']).stdout ?? ''}`
|
|
354
|
+
.trim()
|
|
355
|
+
.split('\n')
|
|
356
|
+
.slice(-60)
|
|
357
|
+
.join('\n');
|
|
358
|
+
commenter(
|
|
359
|
+
`## CI rouge\n\nLa CI de ${court} sur ${o.principale} est rouge : ${url}\n\nLa fin de gh run view ${passage} --log-failed :\n\n${journal}\n\nLe ticket est rouvert : sa correction entre sous son numéro. Un rejeu vert de la même CI (\`gh run rerun ${passage} --failed\`), puis \`--reprendre\` du circuit, le ferme ; un test connu instable se met en quarantaine dans le test, avec le ticket qui le corrige.`
|
|
367
360
|
);
|
|
361
|
+
o.dire(`✗ CI de ${court} rouge (passage ${passage}) : ${ticket} rouvert`);
|
|
362
|
+
if (!relue) o.bd('reopen', ticket);
|
|
363
|
+
return { etat: 'rouvert', raison: `La CI de ${court} est rouge : ${url}` };
|
|
368
364
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
365
|
+
if (!relue) {
|
|
366
|
+
retirerLeTravail(o, ticket);
|
|
367
|
+
return {
|
|
368
|
+
etat: 'ferme',
|
|
369
|
+
raison:
|
|
370
|
+
verdict === NON_LUE ? `${INTEGRE}${court} ; CI non lue : ${raison}` : `${INTEGRE}${court}`,
|
|
371
|
+
};
|
|
374
372
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
o.
|
|
380
|
-
|
|
381
|
-
'add',
|
|
382
|
-
ticket,
|
|
383
|
-
`## CI relue\n\nLa CI de ${court} sur ${principale} est verte au dernier essai du passage ${ci.passage} : le ticket se ferme.`
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
o.dire(`✓ ${ticket} fermé : ${court} est sur ${principale}`);
|
|
373
|
+
if (verdict === NON_LUE) return { etat: 'rouvert', raison: `CI non relue : ${raison}` };
|
|
374
|
+
o.bd('close', ticket, '--reason', `${INTEGRE}${court}`);
|
|
375
|
+
if (passage) {
|
|
376
|
+
commenter(
|
|
377
|
+
`## CI relue\n\nLa CI de ${court} sur ${o.principale} est verte au dernier essai du passage ${passage} : le ticket se ferme.`
|
|
378
|
+
);
|
|
387
379
|
}
|
|
388
|
-
|
|
380
|
+
o.dire(`✓ ${ticket} fermé : ${court} est sur ${o.principale}`);
|
|
381
|
+
retirerLeTravail(o, ticket);
|
|
382
|
+
return { etat: 'ferme', raison: `${INTEGRE}${court}` };
|
|
389
383
|
}
|
|
390
384
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
385
|
+
/**
|
|
386
|
+
* Where the lot of the ticket <ticket> stands, with the tools <o>: `{ statut, raison, aEntrer,
|
|
387
|
+
* commit, branche, surOrigin, raisonOrigin, faute }`, its status in Beads and its reason of
|
|
388
|
+
* closure, whether its branch `agent/<ticket>` holds a lot ahead of main (which enters by the
|
|
389
|
+
* queue), the commit of main that delivers it (`lotSurMain`, null without one), the branch it was
|
|
390
|
+
* pushed to (`grillhouse.poussee.commit`), whether that commit is on that branch of origin
|
|
391
|
+
* (`surOrigin`: « oui », « non » for a closure that failed before its push, or « inconnu » when
|
|
392
|
+
* origin does not answer, `raisonOrigin` its reason), and the fault of that key (null when it
|
|
393
|
+
* reads).
|
|
394
|
+
*/
|
|
395
|
+
export function situerLeLot(o, ticket) {
|
|
396
|
+
const show = o.bd('show', ticket, '--json');
|
|
397
|
+
const t = show.status === 0 ? (JSON.parse(show.stdout)[0] ?? {}) : {};
|
|
398
|
+
const git = (...a) => spawnSync('git', ['-C', o.racine, ...a], { encoding: 'utf8' });
|
|
399
|
+
const paquet = git('show', `refs/heads/${o.principale}:package.json`);
|
|
400
|
+
const { commit: branche, faute } = lireCommit(
|
|
401
|
+
paquet.status === 0 ? JSON.parse(paquet.stdout) : null
|
|
407
402
|
);
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
403
|
+
const enAvance = git(
|
|
404
|
+
'rev-list',
|
|
405
|
+
'--count',
|
|
406
|
+
`refs/heads/${o.principale}..refs/heads/agent/${ticket}`
|
|
407
|
+
);
|
|
408
|
+
const commit = lotSurMain(o, ticket);
|
|
409
|
+
const origine =
|
|
410
|
+
commit && !faute ? surOrigin(o, commit, branche) : { surOrigin: 'non', raison: null };
|
|
411
|
+
return {
|
|
412
|
+
statut: t.status ?? null,
|
|
413
|
+
raison: t.close_reason ?? null,
|
|
414
|
+
aEntrer: enAvance.status === 0 && Number(enAvance.stdout.trim()) > 0,
|
|
415
|
+
commit,
|
|
416
|
+
branche: faute ? null : branche,
|
|
417
|
+
surOrigin: origine.surOrigin,
|
|
418
|
+
raisonOrigin: origine.raison,
|
|
419
|
+
faute: faute ?? null,
|
|
419
420
|
};
|
|
420
|
-
|
|
421
|
-
const principale = git('symbolic-ref', '--short', '-q', 'HEAD').stdout.trim();
|
|
422
|
-
if (!principale) {
|
|
423
|
-
process.stderr.write("⛔ L'arbre principal n'est pas sur une branche.\n");
|
|
424
|
-
return 1;
|
|
425
|
-
}
|
|
426
|
-
// The tools of the reading of the CI, the queue's and its reading again.
|
|
427
|
-
const lecture = { racine, principale, bd, gh: ghDans(racine), dire, avancement };
|
|
428
|
-
if (relecture) return relireCI({ ...lecture, ticket: relecture });
|
|
429
|
-
const refPrincipale = `refs/heads/${principale}`;
|
|
430
|
-
const copie = path.join(racine, '.claude', 'worktrees', 'file');
|
|
431
|
-
const verrou = path.join(dossierCommun(racine), 'file-integration.lock');
|
|
421
|
+
}
|
|
432
422
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
423
|
+
// Whether the commit <commit> is on the branch <branche> of origin, with the tools <o>: « oui »,
|
|
424
|
+
// « non », or « inconnu » when origin does not answer (`git ls-remote`, without a prompt, as the
|
|
425
|
+
// push) or its tip is not known here (`merge-base --is-ancestor` neither 0 nor 1), its reason
|
|
426
|
+
// named: a place that does not read is never « not pushed ».
|
|
427
|
+
function surOrigin(o, commit, branche) {
|
|
428
|
+
const ls = spawnSync(
|
|
429
|
+
'git',
|
|
430
|
+
['-C', o.racine, 'ls-remote', '--heads', 'origin', `refs/heads/${branche}`],
|
|
431
|
+
{
|
|
432
|
+
encoding: 'utf8',
|
|
433
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
434
|
+
}
|
|
435
|
+
);
|
|
436
|
+
if (ls.status !== 0) {
|
|
437
|
+
const raison =
|
|
438
|
+
`${ls.stderr ?? ''}`.trim().split('\n')[0] || ls.error?.message || `code ${ls.status}`;
|
|
439
|
+
return { surOrigin: 'inconnu', raison: `git ls-remote origin ${branche} : ${raison}` };
|
|
440
|
+
}
|
|
441
|
+
const pointe = ls.stdout.split(/\s/)[0] ?? '';
|
|
442
|
+
if (!pointe) return { surOrigin: 'non', raison: null };
|
|
443
|
+
// `--is-ancestor` answers 0 (an ancestor) or 1 (not one); any other code (the tip of origin
|
|
444
|
+
// unknown here, 128) does not say: « inconnu », its reason named.
|
|
445
|
+
const git = (...a) => spawnSync('git', ['-C', o.racine, ...a], { encoding: 'utf8' });
|
|
446
|
+
const ancetre = git('merge-base', '--is-ancestor', commit, pointe);
|
|
447
|
+
if (ancetre.status === 0) return { surOrigin: 'oui', raison: null };
|
|
448
|
+
if (ancetre.status === 1) return { surOrigin: 'non', raison: null };
|
|
449
|
+
const raison =
|
|
450
|
+
`${ancetre.stderr ?? ''}`.trim().split('\n')[0] ||
|
|
451
|
+
ancetre.error?.message ||
|
|
452
|
+
`code ${ancetre.status}`;
|
|
453
|
+
return {
|
|
454
|
+
surOrigin: 'inconnu',
|
|
455
|
+
raison: `git merge-base --is-ancestor ${commit.slice(0, 7)} origin/${branche} : ${raison}`,
|
|
458
456
|
};
|
|
457
|
+
}
|
|
459
458
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
459
|
+
// The commit of main that delivers the ticket <ticket> (its title line names it,
|
|
460
|
+
// `commitsDelivering` of ../un-commit-par-ticket.mjs, the prefix read from bd), the last one, in
|
|
461
|
+
// full; null without one.
|
|
462
|
+
function lotSurMain(o, ticket) {
|
|
463
|
+
const git = (...a) => spawnSync('git', ['-C', o.racine, ...a], { encoding: 'utf8' });
|
|
464
|
+
const prefixe = o.bd('config', 'get', 'issue_prefix').stdout?.trim() ?? '';
|
|
465
|
+
return (
|
|
466
|
+
commitsDelivering(ticket, prefixe, gitLog(o.racine))
|
|
467
|
+
.map(c => git('rev-parse', '--verify', '-q', `${c}^{commit}`).stdout.trim())
|
|
468
|
+
.find(
|
|
469
|
+
c => c && git('merge-base', '--is-ancestor', c, `refs/heads/${o.principale}`).status === 0
|
|
470
|
+
) ?? null
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// The branch of <entree> replaced on the main <tete> in the queue's own copy, replayed, with the
|
|
475
|
+
// tools <o>: { nouveau } (the commit to move main onto), or { sortie: [titre, détail] } (it leaves
|
|
476
|
+
// the queue), or { garde } (it stays, the reason).
|
|
477
|
+
function rejouer(o, tip, tete, ticketRejoue = null) {
|
|
478
|
+
const { racine, dire } = o;
|
|
479
|
+
const copie = path.join(racine, '.claude', 'worktrees', 'file');
|
|
480
|
+
if (existsSync(copie)) spawnSync('git', ['-C', copie, 'rebase', '--abort'], { encoding: 'utf8' });
|
|
481
|
+
// The keys of the project, before any work: its generated files and its tools.
|
|
482
|
+
let engendres;
|
|
483
|
+
let env;
|
|
484
|
+
try {
|
|
485
|
+
engendres = engendresDe(racine);
|
|
486
|
+
env = avecLesDonnees(donneesDe(racine), avecLesOutils(outilsDe(racine), process.env));
|
|
487
|
+
} catch (e) {
|
|
488
|
+
return { garde: `une clé grillhouse du package.json est refusée :\n${e.message}` };
|
|
489
|
+
}
|
|
490
|
+
const ouverte = ouvrirCopie({ racine, copie, ref: tete, dire });
|
|
491
|
+
if (ouverte.refus) return { garde: ouverte.refus };
|
|
492
|
+
const { dansCopie, monter, installer, tester } = ouverte;
|
|
493
|
+
if (dansCopie('checkout', '-q', '--detach', tip).status !== 0)
|
|
494
|
+
return { garde: `la copie ne prend pas ${tip.slice(0, 7)}` };
|
|
495
|
+
// A conflict on generated files the project declares only is no conflict: main's version is
|
|
496
|
+
// taken, and their command writes them again once the branch is replaced (below).
|
|
497
|
+
let rebase = dansCopie('rebase', tete);
|
|
498
|
+
let tours = Number(dansCopie('rev-list', '--count', `${tete}..${tip}`).stdout.trim()) || 1;
|
|
499
|
+
while (rebase.status !== 0) {
|
|
500
|
+
const conflits = dansCopie('diff', '--name-only', '--diff-filter=U')
|
|
501
|
+
.stdout.split('\n')
|
|
502
|
+
.filter(Boolean);
|
|
503
|
+
const engendresSeuls =
|
|
504
|
+
tours-- > 0 &&
|
|
505
|
+
conflits.length > 0 &&
|
|
506
|
+
conflits.every(f => engendres.some(e => couvertPar(e.entiers, f))) &&
|
|
507
|
+
dansCopie('checkout', '--ours', '--', ...conflits).status === 0 &&
|
|
508
|
+
dansCopie('add', '--', ...conflits).status === 0;
|
|
509
|
+
if (!engendresSeuls) {
|
|
510
|
+
dansCopie('rebase', '--abort');
|
|
511
|
+
return {
|
|
512
|
+
sortie: [
|
|
513
|
+
'elle ne se replace pas sur main.',
|
|
514
|
+
conflits.length
|
|
515
|
+
? `Fichiers en conflit :\n${conflits.map(f => ` ${f}`).join('\n')}`
|
|
516
|
+
: `Sortie de git :\n${rebase.stdout}${rebase.stderr}`,
|
|
517
|
+
],
|
|
518
|
+
};
|
|
473
519
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
520
|
+
rebase = dansCopie('-c', 'core.editor=true', 'rebase', '--continue');
|
|
521
|
+
}
|
|
522
|
+
const installation = installer();
|
|
523
|
+
if (installation) {
|
|
524
|
+
return { sortie: [installation, "Le verrou de la branche replacée ne s'installe pas."] };
|
|
525
|
+
}
|
|
526
|
+
const touches = touchesPar(
|
|
527
|
+
engendres,
|
|
528
|
+
dansCopie('diff', '--name-only', '--no-renames', '-z', tete, 'HEAD')
|
|
529
|
+
.stdout.split('\0')
|
|
530
|
+
.filter(Boolean)
|
|
531
|
+
);
|
|
532
|
+
if (touches.length) {
|
|
533
|
+
const refus = regenerer({
|
|
534
|
+
refs: touches.map(e => ({ ...e, cadre: false })),
|
|
535
|
+
dansCopie,
|
|
536
|
+
lancer: commande =>
|
|
537
|
+
spawnSync('bash', monter('sh', '-c', commande), {
|
|
538
|
+
cwd: copie,
|
|
539
|
+
encoding: 'utf8',
|
|
540
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
541
|
+
env,
|
|
542
|
+
}),
|
|
543
|
+
});
|
|
544
|
+
if (refus) return { sortie: ['ses fichiers engendrés ne se régénèrent pas sur main.', refus] };
|
|
545
|
+
if (dansCopie('diff', '--cached', '--quiet').status !== 0) {
|
|
546
|
+
const corrige = dansCopie('commit', '-q', '--amend', '--no-edit', '--no-verify');
|
|
547
|
+
if (corrige.status !== 0) {
|
|
495
548
|
return {
|
|
496
|
-
|
|
497
|
-
'elle ne se replace pas sur main.',
|
|
498
|
-
conflits.length
|
|
499
|
-
? `Fichiers en conflit :\n${conflits.map(f => ` ${f}`).join('\n')}`
|
|
500
|
-
: `Sortie de git :\n${rebase.stdout}${rebase.stderr}`,
|
|
501
|
-
],
|
|
549
|
+
garde: `ses fichiers régénérés n'entrent pas dans son commit :\n${corrige.stderr}`,
|
|
502
550
|
};
|
|
503
551
|
}
|
|
504
|
-
rebase = dansCopie('-c', 'core.editor=true', 'rebase', '--continue');
|
|
505
552
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
553
|
+
dire(`✓ fichiers engendrés régénérés sur main : ${touches.map(e => e.nom).join(', ')}`);
|
|
554
|
+
}
|
|
555
|
+
dire('— npm run verifier (construction, gardes, tests)');
|
|
556
|
+
const t = tester({ sorte: 'File', ticket: ticketRejoue });
|
|
557
|
+
if (t.status === A_REPASSER) {
|
|
558
|
+
return {
|
|
559
|
+
garde: `son \`npm run verifier\` est à repasser (code ${A_REPASSER}) une fois replacée : l'attente de la machine a atteint sa borne. Ni vert ni rouge ; la prochaine file la rejoue.`,
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
if (t.status !== 0) {
|
|
563
|
+
const fin = `${t.stdout}${t.stderr}`.trim().split('\n').slice(-40).join('\n');
|
|
564
|
+
return { sortie: ['ses tests sont rouges une fois la branche replacée.', fin] };
|
|
565
|
+
}
|
|
566
|
+
return { nouveau: dansCopie('rev-parse', 'HEAD').stdout.trim() };
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Main moved onto the branch of <entree> (`{ ticket, branche }`) with the tools <o>, against the
|
|
571
|
+
* main of the moment, without a word to the ticket: `{ entre: { commit } }`, main at <commit>;
|
|
572
|
+
* `{ sortie: [titre, détail] }` (it leaves the queue: gone, not replaced, red once replaced);
|
|
573
|
+
* `{ garde }` (it stays in the queue, the reason); `{ ecartee: true }` (nothing ahead of main). A
|
|
574
|
+
* lot already on main (the branch points at the commit of main that delivers its ticket, or each
|
|
575
|
+
* of its commits has its equivalent on main, or the branch is gone), as an attempt played again
|
|
576
|
+
* after its worker died finds it, is entered: main does not move again.
|
|
577
|
+
*/
|
|
578
|
+
export function avancerMain(o, entree) {
|
|
579
|
+
const git = (...args) => spawnSync('git', ['-C', o.racine, ...args], { encoding: 'utf8' });
|
|
580
|
+
const refPrincipale = `refs/heads/${o.principale}`;
|
|
581
|
+
const tip = git('rev-parse', '--verify', '-q', `refs/heads/${entree.branche}`).stdout.trim();
|
|
582
|
+
const livre = lotSurMain(o, entree.ticket);
|
|
583
|
+
// A lot on main whose branch is gone (a closure that failed after its deletion) is entered.
|
|
584
|
+
if (!tip)
|
|
585
|
+
return livre ? { entre: { commit: livre } } : { sortie: ["la branche n'existe plus.", ''] };
|
|
586
|
+
const enAvance = Number(git('rev-list', '--count', `${refPrincipale}..${tip}`).stdout.trim());
|
|
587
|
+
// The lot is on main when the branch points at the commit of main that delivers the ticket
|
|
588
|
+
// (main moved onto it by fast-forward), or when each commit of the branch has its equivalent on
|
|
589
|
+
// main (the same patch, git cherry), the replay a rebase wrote: a lot of before of a ticket
|
|
590
|
+
// reopened is neither, its branch at main's or ahead of it by new commits.
|
|
591
|
+
if (livre) {
|
|
592
|
+
const cerise = git('cherry', refPrincipale, tip).stdout.split('\n').filter(Boolean);
|
|
593
|
+
const rejeu = enAvance > 0 && cerise.length > 0 && cerise.every(l => l.startsWith('- '));
|
|
594
|
+
if (tip === livre || rejeu) return { entre: { commit: livre } };
|
|
595
|
+
}
|
|
596
|
+
if (enAvance === 0) return { ecartee: true };
|
|
597
|
+
for (let essai = 0; essai < ESSAIS_PAR_BRANCHE; essai++) {
|
|
598
|
+
const tete = git('rev-parse', refPrincipale).stdout.trim();
|
|
599
|
+
let nouveau = tip;
|
|
600
|
+
if (git('merge-base', '--is-ancestor', tete, tip).status !== 0) {
|
|
601
|
+
const r = rejouer(o, tip, tete, entree.ticket);
|
|
602
|
+
if (!r.nouveau) return r;
|
|
603
|
+
nouveau = r.nouveau;
|
|
509
604
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
.stdout.
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
refs: touches.map(e => ({ ...e, cadre: false })),
|
|
519
|
-
dansCopie,
|
|
520
|
-
lancer: commande =>
|
|
521
|
-
spawnSync('bash', monter('sh', '-c', commande), {
|
|
522
|
-
cwd: copie,
|
|
523
|
-
encoding: 'utf8',
|
|
524
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
525
|
-
env,
|
|
526
|
-
}),
|
|
527
|
-
});
|
|
528
|
-
if (refus)
|
|
529
|
-
return { sortie: ['ses fichiers engendrés ne se régénèrent pas sur main.', refus] };
|
|
530
|
-
if (dansCopie('diff', '--cached', '--quiet').status !== 0) {
|
|
531
|
-
const corrige = dansCopie('commit', '-q', '--amend', '--no-edit', '--no-verify');
|
|
532
|
-
if (corrige.status !== 0) {
|
|
533
|
-
return {
|
|
534
|
-
garde: `ses fichiers régénérés n'entrent pas dans son commit :\n${corrige.stderr}`,
|
|
535
|
-
};
|
|
536
|
-
}
|
|
605
|
+
if (nouveau !== tete) {
|
|
606
|
+
const avance = git('merge', '-q', '--ff-only', nouveau);
|
|
607
|
+
if (avance.status !== 0) {
|
|
608
|
+
if (git('rev-parse', refPrincipale).stdout.trim() !== tete) continue;
|
|
609
|
+
return {
|
|
610
|
+
garde:
|
|
611
|
+
`${o.principale} n'avance pas sur ${nouveau.slice(0, 7)} :\n${avance.stdout}${avance.stderr}`.trim(),
|
|
612
|
+
};
|
|
537
613
|
}
|
|
538
|
-
dire(`✓ fichiers engendrés régénérés sur main : ${touches.map(e => e.nom).join(', ')}`);
|
|
539
|
-
}
|
|
540
|
-
dire('— npm run verifier (construction, gardes, tests)');
|
|
541
|
-
const t = tester();
|
|
542
|
-
if (t.status === A_REPASSER) {
|
|
543
|
-
return {
|
|
544
|
-
garde: `son \`npm run verifier\` est à repasser (code ${A_REPASSER}) une fois replacée : l'attente de la machine a atteint sa borne. Ni vert ni rouge ; la prochaine file la rejoue.`,
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
if (t.status !== 0) {
|
|
548
|
-
const fin = `${t.stdout}${t.stderr}`.trim().split('\n').slice(-40).join('\n');
|
|
549
|
-
return { sortie: ['ses tests sont rouges une fois la branche replacée.', fin] };
|
|
550
614
|
}
|
|
551
|
-
return {
|
|
552
|
-
}
|
|
615
|
+
return { entre: { commit: nouveau } };
|
|
616
|
+
}
|
|
617
|
+
return { garde: `${o.principale} bouge sans cesse : cinq essais n'ont pas suffi.` };
|
|
618
|
+
}
|
|
553
619
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
620
|
+
/**
|
|
621
|
+
* The ticket of <entree> (`{ ticket, branche, commit }`) entered on main at <commit>, with the
|
|
622
|
+
* tools <o>: it closes « intégré : <commit> » and loses `en-file` (a ticket already closed is left
|
|
623
|
+
* as it is), <apresLaFermeture> runs (the queue on its file removes its entry there), the branch is
|
|
624
|
+
* deleted, then main is pushed to origin on the branch `grillhouse.poussee.commit` of main's
|
|
625
|
+
* package.json; a push not made ends the queue's work on the ticket, and removes the working
|
|
626
|
+
* directory of its circuit (`retirerLeTravail`), which the conclusion of its CI removes otherwise. Each of its gestures replays without
|
|
627
|
+
* harm (a ticket closed is left closed, a branch gone stays gone, a commit pushed is pushed again
|
|
628
|
+
* as it is), and never reopens the ticket; its comments are effects (`commenterAu`), which the
|
|
629
|
+
* workflow of the queue writes once each. `{ poussee, raison }`: the branch pushed to, or null and
|
|
630
|
+
* why, in one line (`enUneLigne`), its comment at the ticket whole.
|
|
631
|
+
*/
|
|
632
|
+
export function fermerLEntree(o, entree, apresLaFermeture = () => {}) {
|
|
633
|
+
const { racine } = o;
|
|
634
|
+
const git = (...args) => spawnSync('git', ['-C', racine, ...args], { encoding: 'utf8' });
|
|
635
|
+
const court = entree.commit.slice(0, 7);
|
|
636
|
+
const commenter = texte => commenterAu(o, entree.ticket, texte);
|
|
637
|
+
const show = o.bd('show', entree.ticket, '--json');
|
|
638
|
+
const statut = show.status === 0 ? (JSON.parse(show.stdout)[0]?.status ?? null) : null;
|
|
639
|
+
if (statut !== 'closed') {
|
|
640
|
+
o.bd('update', entree.ticket, '--remove-label', 'en-file');
|
|
641
|
+
o.bd('close', entree.ticket, '--reason', `${INTEGRE}${court}`);
|
|
642
|
+
}
|
|
643
|
+
apresLaFermeture();
|
|
644
|
+
o.dire(`✓ ${entree.branche} entre sur ${o.principale} : ${court}`);
|
|
645
|
+
if (git('rev-parse', '--verify', '-q', `refs/heads/${entree.branche}`).status === 0) {
|
|
565
646
|
const efface = git('branch', '-D', entree.branche);
|
|
566
647
|
if (efface.status !== 0) {
|
|
567
648
|
commenter(
|
|
568
|
-
entree.ticket
|
|
569
|
-
`La branche ${entree.branche} reste en place après son entrée sur ${principale} (${efface.stderr.trim()}) : sa copie est encore en place. Le ticket est fermé.`
|
|
570
|
-
);
|
|
571
|
-
dire(`⚠ ${entree.branche} n'est pas effacée`);
|
|
572
|
-
}
|
|
573
|
-
const paquet = git('show', `${refPrincipale}:package.json`);
|
|
574
|
-
const { commit, faute } = lireCommit(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
|
|
575
|
-
if (faute) {
|
|
576
|
-
commenter(
|
|
577
|
-
entree.ticket,
|
|
578
|
-
`Poussée non faite : grillhouse.poussee.commit vaut ${faute}, pas un nom de branche.`
|
|
579
|
-
);
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
const pousse = spawnSync(
|
|
583
|
-
'git',
|
|
584
|
-
['-C', racine, 'push', 'origin', `${nouveau}:refs/heads/${commit}`],
|
|
585
|
-
{ encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } }
|
|
586
|
-
);
|
|
587
|
-
if (pousse.status !== 0) {
|
|
588
|
-
commenter(
|
|
589
|
-
entree.ticket,
|
|
590
|
-
`La poussée de ${court} vers origin/${commit} (grillhouse.poussee.commit) est refusée :\n${pousse.stderr.trim()}`
|
|
649
|
+
`La branche ${entree.branche} reste en place après son entrée sur ${o.principale} (${efface.stderr.trim()}) : sa copie est encore en place. Le ticket est fermé.`
|
|
591
650
|
);
|
|
592
|
-
dire(`⚠
|
|
593
|
-
} else {
|
|
594
|
-
dire(`✓ poussée : ${court} est sur origin/${commit}`);
|
|
595
|
-
const ci = lireCI(lecture, entree.ticket, nouveau, commit);
|
|
596
|
-
if (ci.verdict === ROUGE) bd('reopen', entree.ticket);
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
// One branch of the queue, against the main of the moment.
|
|
601
|
-
const traiter = entree => {
|
|
602
|
-
const tip = git('rev-parse', '--verify', '-q', `refs/heads/${entree.branche}`).stdout.trim();
|
|
603
|
-
if (!tip) return sortir(entree, "la branche n'existe plus.", '');
|
|
604
|
-
if (Number(git('rev-list', '--count', `${refPrincipale}..${tip}`).stdout.trim()) === 0)
|
|
605
|
-
return ecarter(entree);
|
|
606
|
-
for (let essai = 0; essai < ESSAIS_PAR_BRANCHE; essai++) {
|
|
607
|
-
const tete = git('rev-parse', refPrincipale).stdout.trim();
|
|
608
|
-
let nouveau = tip;
|
|
609
|
-
if (git('merge-base', '--is-ancestor', tete, tip).status !== 0) {
|
|
610
|
-
const r = rejouer(tip, tete);
|
|
611
|
-
if (r.sortie) return sortir(entree, ...r.sortie);
|
|
612
|
-
if (r.garde) return garder(entree, r.garde);
|
|
613
|
-
nouveau = r.nouveau;
|
|
614
|
-
}
|
|
615
|
-
if (nouveau !== tete) {
|
|
616
|
-
const avance = git('merge', '-q', '--ff-only', nouveau);
|
|
617
|
-
if (avance.status !== 0) {
|
|
618
|
-
if (git('rev-parse', refPrincipale).stdout.trim() !== tete) continue;
|
|
619
|
-
return garder(
|
|
620
|
-
entree,
|
|
621
|
-
`${principale} n'avance pas sur ${nouveau.slice(0, 7)} :\n${avance.stdout}${avance.stderr}`.trim()
|
|
622
|
-
);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
return entrer(entree, nouveau);
|
|
626
|
-
}
|
|
627
|
-
return garder(entree, `${principale} bouge sans cesse : cinq essais n'ont pas suffi.`);
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
const vues = new Set();
|
|
631
|
-
for (;;) {
|
|
632
|
-
if (!prendreVerrou(verrou, { attendre: false })) return 0;
|
|
633
|
-
try {
|
|
634
|
-
for (;;) {
|
|
635
|
-
const entree = lireEntrees(racine).find(e => !vues.has(e.fichier));
|
|
636
|
-
if (!entree) break;
|
|
637
|
-
vues.add(entree.fichier);
|
|
638
|
-
traiter(entree);
|
|
639
|
-
}
|
|
640
|
-
} finally {
|
|
641
|
-
lacherVerrou(verrou);
|
|
651
|
+
o.dire(`⚠ ${entree.branche} n'est pas effacée`);
|
|
642
652
|
}
|
|
643
|
-
// An entry written while the lock was let go has no queue running to take it.
|
|
644
|
-
if (!lireEntrees(racine).some(e => !vues.has(e.fichier))) return 0;
|
|
645
653
|
}
|
|
654
|
+
const paquet = git('show', `refs/heads/${o.principale}:package.json`);
|
|
655
|
+
const { commit, faute } = lireCommit(paquet.status === 0 ? JSON.parse(paquet.stdout) : null);
|
|
656
|
+
if (faute) {
|
|
657
|
+
const raison = `Poussée non faite : grillhouse.poussee.commit vaut ${faute}, pas un nom de branche.`;
|
|
658
|
+
commenter(raison);
|
|
659
|
+
retirerLeTravail(o, entree.ticket);
|
|
660
|
+
return { poussee: null, raison: enUneLigne(raison) };
|
|
661
|
+
}
|
|
662
|
+
const pousse = spawnSync(
|
|
663
|
+
'git',
|
|
664
|
+
['-C', racine, 'push', 'origin', `${entree.commit}:refs/heads/${commit}`],
|
|
665
|
+
{ encoding: 'utf8', env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } }
|
|
666
|
+
);
|
|
667
|
+
if (pousse.status !== 0) {
|
|
668
|
+
const raison = `La poussée de ${court} vers origin/${commit} (grillhouse.poussee.commit) est refusée :\n${pousse.stderr.trim()}`;
|
|
669
|
+
commenter(raison);
|
|
670
|
+
o.dire(`⚠ poussée de ${court} refusée`);
|
|
671
|
+
retirerLeTravail(o, entree.ticket);
|
|
672
|
+
return { poussee: null, raison: enUneLigne(raison) };
|
|
673
|
+
}
|
|
674
|
+
o.dire(`✓ poussée : ${court} est sur origin/${commit}`);
|
|
675
|
+
return { poussee: commit, raison: null };
|
|
646
676
|
}
|
|
647
677
|
|
|
648
|
-
|
|
649
|
-
|
|
678
|
+
/**
|
|
679
|
+
* What the outcome <r> of `avancerMain` for <entree> says to its ticket, with the tools <o>: a
|
|
680
|
+
* branch out of the queue reopens it, its files or its red named; a branch set aside loses
|
|
681
|
+
* `en-file`, the ticket left open; a branch kept, the reason. `{ etat, raison }`: `rouvert` or
|
|
682
|
+
* `en-file`, as the circuit reads the queue.
|
|
683
|
+
*/
|
|
684
|
+
export function direLIssue(o, entree, r) {
|
|
685
|
+
const commenter = texte => commenterAu(o, entree.ticket, texte);
|
|
686
|
+
if (r.sortie) {
|
|
687
|
+
const [titre, detail] = r.sortie;
|
|
688
|
+
const texte = `## Sortie de la file\n\nLa branche ${entree.branche} ne peut pas entrer sur ${o.principale} : ${titre}\n${detail}\n\nLa branche reste en place ; la relance du ticket remet son lot en travail local sur ${o.principale}.`;
|
|
689
|
+
o.bd('update', entree.ticket, '--status', 'open', '--remove-label', 'en-file');
|
|
690
|
+
commenter(texte);
|
|
691
|
+
o.dire(`✗ ${entree.branche} sort de la file : ${titre}`);
|
|
692
|
+
return { etat: 'rouvert', raison: texte };
|
|
693
|
+
}
|
|
694
|
+
if (r.ecartee) {
|
|
695
|
+
const texte = `## Sortie de la file\n\nLa branche ${entree.branche} n'a rien en avance sur ${o.principale} : elle n'entre pas, et le ticket reste ouvert.`;
|
|
696
|
+
o.bd('update', entree.ticket, '--remove-label', 'en-file');
|
|
697
|
+
commenter(texte);
|
|
698
|
+
o.dire(`⚠ ${entree.branche} n'a rien en avance sur ${o.principale} : elle sort de la file`);
|
|
699
|
+
return { etat: 'rouvert', raison: texte };
|
|
700
|
+
}
|
|
701
|
+
const texte = `## La file garde la branche\n\nLa branche ${entree.branche} reste en file : ${r.garde}`;
|
|
702
|
+
commenter(texte);
|
|
703
|
+
o.dire(`⚠ ${entree.branche} reste en file : ${r.garde}`);
|
|
704
|
+
return { etat: 'en-file', raison: texte };
|
|
650
705
|
}
|