plugin-updater 1.0.42 → 1.0.44
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/git.js +40 -2
- package/package.json +1 -1
package/dist/git.js
CHANGED
|
@@ -44,8 +44,46 @@ export function updatePlugin(pluginName, gitUrl, branch, commitHash, updateInter
|
|
|
44
44
|
const intervalMs = updateInterval * 3_600_000;
|
|
45
45
|
const elapsed = Date.now() - lastCheck;
|
|
46
46
|
if (elapsed < intervalMs) {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
// The interval throttles the expensive fetch/build, NOT change detection.
|
|
48
|
+
// A pinned commit is intentional; otherwise do a cheap ls-remote so a new
|
|
49
|
+
// push is picked up on the very next launch instead of waiting out the hour.
|
|
50
|
+
let remoteMoved = false;
|
|
51
|
+
if (!commitHash) {
|
|
52
|
+
try {
|
|
53
|
+
const ref = branch || "HEAD";
|
|
54
|
+
const remoteHash = execSync(`git ls-remote origin ${ref}`, { cwd: targetDir }).toString().trim().split(/\s+/)[0] || "";
|
|
55
|
+
const localHash = execSync("git rev-parse HEAD", { cwd: targetDir }).toString().trim();
|
|
56
|
+
remoteMoved = !!remoteHash && !!localHash && remoteHash !== localHash;
|
|
57
|
+
}
|
|
58
|
+
catch { /* offline / transient — fall back to skipping until the interval */ }
|
|
59
|
+
}
|
|
60
|
+
if (!remoteMoved) {
|
|
61
|
+
writeLog(`Fast-path: ${pluginName} skipping update check (checked ${Math.floor(elapsed / 60_000)} min ago, interval ${updateInterval}h)`);
|
|
62
|
+
// even when skipping the network check, keep embedded submodules pinned to
|
|
63
|
+
// this checkout — a loader running against a stale core/core-auth is the
|
|
64
|
+
// top cause of "looks broken but it's just stale". Rebuild if they moved.
|
|
65
|
+
if (fs.existsSync(path.join(targetDir, ".gitmodules"))) {
|
|
66
|
+
let before = "";
|
|
67
|
+
try {
|
|
68
|
+
before = execSync("git submodule status --recursive", { cwd: targetDir }).toString();
|
|
69
|
+
}
|
|
70
|
+
catch { /* ignore */ }
|
|
71
|
+
executeGit("git submodule sync --recursive", targetDir);
|
|
72
|
+
executeGit("git submodule update --init --recursive", targetDir);
|
|
73
|
+
let after = "";
|
|
74
|
+
try {
|
|
75
|
+
after = execSync("git submodule status --recursive", { cwd: targetDir }).toString();
|
|
76
|
+
}
|
|
77
|
+
catch { /* ignore */ }
|
|
78
|
+
if (before !== after) {
|
|
79
|
+
writeLog(`Fast-path: ${pluginName} submodules were out of sync — resynced, forcing rebuild`);
|
|
80
|
+
return { success: true, changed: true };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { success: true, changed: false };
|
|
84
|
+
}
|
|
85
|
+
writeLog(`Fast-path: ${pluginName} remote moved — updating despite interval`);
|
|
86
|
+
// fall through to the full fetch/checkout/build path below
|
|
49
87
|
}
|
|
50
88
|
fs.writeFileSync(lastCheckFile, Date.now().toString());
|
|
51
89
|
executeGit("git fetch origin", targetDir);
|