forgedock 1.0.4 → 1.0.5
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/bin/forgedock.mjs +28 -1
- package/package.json +1 -1
package/bin/forgedock.mjs
CHANGED
|
@@ -1336,8 +1336,35 @@ async function checkForRemoteUpdate(force = false) {
|
|
|
1336
1336
|
timeout: 5000,
|
|
1337
1337
|
}).trim();
|
|
1338
1338
|
|
|
1339
|
+
// An update is only "available" when local HEAD is strictly BEHIND
|
|
1340
|
+
// origin/main. Plain SHA inequality is direction-agnostic: a checkout
|
|
1341
|
+
// that is ahead of or diverged from origin/main (e.g. a contributor with
|
|
1342
|
+
// local commits) would otherwise show a spurious "Update available"
|
|
1343
|
+
// notice. `git merge-base --is-ancestor HEAD origin/main` exits 0 when
|
|
1344
|
+
// HEAD is an ancestor of origin/main (behind or equal); combined with the
|
|
1345
|
+
// inequality below this means strictly behind. Any non-zero exit ("not an
|
|
1346
|
+
// ancestor") or error throws under execFileSync — treat all such cases as
|
|
1347
|
+
// "not behind" so we never show a false-positive notice.
|
|
1348
|
+
let headIsAncestorOfRemote = false;
|
|
1349
|
+
try {
|
|
1350
|
+
execFileSync(
|
|
1351
|
+
"git",
|
|
1352
|
+
["merge-base", "--is-ancestor", "HEAD", "origin/main"],
|
|
1353
|
+
{
|
|
1354
|
+
cwd: FORGE_HOME,
|
|
1355
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1356
|
+
timeout: 5000,
|
|
1357
|
+
},
|
|
1358
|
+
);
|
|
1359
|
+
headIsAncestorOfRemote = true;
|
|
1360
|
+
} catch {
|
|
1361
|
+
// HEAD is ahead of, diverged from, or unrelated to origin/main — or git
|
|
1362
|
+
// failed. In every case, do not report an update as available.
|
|
1363
|
+
headIsAncestorOfRemote = false;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1339
1366
|
result = {
|
|
1340
|
-
updateAvailable: localHead !== remoteHead,
|
|
1367
|
+
updateAvailable: localHead !== remoteHead && headIsAncestorOfRemote,
|
|
1341
1368
|
latestVersion: null,
|
|
1342
1369
|
remoteHead,
|
|
1343
1370
|
};
|