@feigi/fleet-ctl 3.40.0 → 3.40.1
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/package.json +1 -1
- package/scripts/main-checkout.mjs +13 -2
package/package.json
CHANGED
|
@@ -180,8 +180,19 @@ function nestedHash(abs, env) {
|
|
|
180
180
|
const now = entriesAt(abs, env, new Set());
|
|
181
181
|
if (!now.ok) throw new Error(now.why);
|
|
182
182
|
let head = git("git rev-parse HEAD", ["rev-parse", "-q", "--verify", "HEAD^{commit}"], abs, env);
|
|
183
|
-
if (!head.ok)
|
|
184
|
-
|
|
183
|
+
if (!head.ok) {
|
|
184
|
+
// No readable commit. Only a branch whose ref does not exist yet (show-ref
|
|
185
|
+
// exit 1) is unborn and hashes as the name HEAD holds; a ref that exists,
|
|
186
|
+
// or a show-ref that failed any other way, is a failed read.
|
|
187
|
+
const symbolic = git("git symbolic-ref HEAD", ["symbolic-ref", "-q", "HEAD"], abs, env);
|
|
188
|
+
// HEAD is detached or otherwise invalid.
|
|
189
|
+
if (!symbolic.ok) throw new Error(symbolic.why);
|
|
190
|
+
const ref = symbolic.stdout.trim();
|
|
191
|
+
const probe = git("git show-ref --verify", ["show-ref", "-q", "--verify", "--", ref], abs, env);
|
|
192
|
+
if (probe.ok) throw new Error(`HEAD points to ${ref} but the commit cannot be resolved`);
|
|
193
|
+
if (probe.status !== 1) throw new Error(probe.why);
|
|
194
|
+
head = symbolic;
|
|
195
|
+
}
|
|
185
196
|
return `repo:${sha(`${head.stdout}${formatEntries(now.entries)}`)}`;
|
|
186
197
|
}
|
|
187
198
|
|