@rtrentjones/greenlight 0.2.13 → 0.2.14
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/dist/bin.js +29 -21
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -413,7 +413,7 @@ function tokensForTool(tool) {
|
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
// src/version.ts
|
|
416
|
-
var MODULE_REF = "v0.2.
|
|
416
|
+
var MODULE_REF = "v0.2.14";
|
|
417
417
|
var MODULE_SOURCE_BASE = "git::https://github.com/RTrentJones/greenlight.git//infra/modules";
|
|
418
418
|
function moduleSource(module, ref = MODULE_REF) {
|
|
419
419
|
return `${MODULE_SOURCE_BASE}/${module}?ref=${ref}`;
|
|
@@ -2414,16 +2414,24 @@ function git(repoDir, args) {
|
|
|
2414
2414
|
function gitOut(repoDir, args) {
|
|
2415
2415
|
return execFileSync5("git", args, { cwd: repoDir, encoding: "utf8" }).trim();
|
|
2416
2416
|
}
|
|
2417
|
+
function resolveRef(repoDir, branch) {
|
|
2418
|
+
for (const ref of [branch, `origin/${branch}`]) {
|
|
2419
|
+
try {
|
|
2420
|
+
git(repoDir, ["rev-parse", "--verify", "--quiet", ref]);
|
|
2421
|
+
return ref;
|
|
2422
|
+
} catch {
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
return null;
|
|
2426
|
+
}
|
|
2417
2427
|
function canPromote(repoDir, from = "develop", to = "main") {
|
|
2418
|
-
const
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
run2(["rev-parse", "--verify", "--quiet", to]);
|
|
2422
|
-
} catch {
|
|
2428
|
+
const fromRef = resolveRef(repoDir, from);
|
|
2429
|
+
const toRef = resolveRef(repoDir, to);
|
|
2430
|
+
if (!fromRef || !toRef) {
|
|
2423
2431
|
return { canPromote: false, reason: `branch "${from}" or "${to}" not found in ${repoDir}` };
|
|
2424
2432
|
}
|
|
2425
2433
|
try {
|
|
2426
|
-
|
|
2434
|
+
git(repoDir, ["merge-base", "--is-ancestor", toRef, fromRef]);
|
|
2427
2435
|
return { canPromote: true, reason: `"${to}" can fast-forward to "${from}"` };
|
|
2428
2436
|
} catch {
|
|
2429
2437
|
return {
|
|
@@ -2437,25 +2445,25 @@ function promote(repoDir, opts = {}) {
|
|
|
2437
2445
|
const to = opts.to ?? "main";
|
|
2438
2446
|
const check = canPromote(repoDir, from, to);
|
|
2439
2447
|
if (!check.canPromote) return { promoted: false, from, to, reason: check.reason };
|
|
2440
|
-
const
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
if (original && original !== "HEAD" && original !== to) {
|
|
2448
|
+
const fromRef = resolveRef(repoDir, from);
|
|
2449
|
+
const fromCommit = gitOut(repoDir, ["rev-parse", fromRef]);
|
|
2450
|
+
const current = gitOut(repoDir, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
2451
|
+
if (opts.push) {
|
|
2452
|
+
git(repoDir, ["push", "origin", `${fromCommit}:refs/heads/${to}`]);
|
|
2453
|
+
if (current !== to) {
|
|
2447
2454
|
try {
|
|
2448
|
-
git(repoDir, ["
|
|
2455
|
+
git(repoDir, ["update-ref", `refs/heads/${to}`, fromCommit]);
|
|
2449
2456
|
} catch {
|
|
2450
2457
|
}
|
|
2451
2458
|
}
|
|
2459
|
+
return { promoted: true, from, to, reason: `"${to}" fast-forwarded to "${from}" and pushed` };
|
|
2452
2460
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
to
|
|
2457
|
-
|
|
2458
|
-
};
|
|
2461
|
+
if (current === to) {
|
|
2462
|
+
git(repoDir, ["merge", "--ff-only", fromRef]);
|
|
2463
|
+
} else {
|
|
2464
|
+
git(repoDir, ["update-ref", `refs/heads/${to}`, fromCommit]);
|
|
2465
|
+
}
|
|
2466
|
+
return { promoted: true, from, to, reason: `"${to}" fast-forwarded to "${from}"` };
|
|
2459
2467
|
}
|
|
2460
2468
|
|
|
2461
2469
|
// src/commands/promote.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rtrentjones/greenlight",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "Greenlight CLI — setup and lifecycle for the harness.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rtrentjones/greenlight-adapters": "0.2.4",
|
|
35
|
-
"@rtrentjones/greenlight-
|
|
35
|
+
"@rtrentjones/greenlight-loop": "0.2.4",
|
|
36
36
|
"@rtrentjones/greenlight-verify": "0.2.4",
|
|
37
|
-
"@rtrentjones/greenlight-
|
|
37
|
+
"@rtrentjones/greenlight-shared": "0.2.4"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "node scripts/copy-assets.mjs && tsup",
|