@firstpick/pi-extension-git-footer-status 0.1.4 → 0.1.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/index.ts +45 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -23,6 +23,13 @@ type GitSnapshot = {
|
|
|
23
23
|
signingMismatch: boolean;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
type SigningDiagnostics = {
|
|
27
|
+
commitSignRequired: boolean;
|
|
28
|
+
signState: string;
|
|
29
|
+
gpgFormat: string;
|
|
30
|
+
signingKey: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
26
33
|
const LIVE_TOKEN_SPEED_ROLLING_WINDOW_MS = 2000;
|
|
27
34
|
|
|
28
35
|
// Toggle footer items on/off here.
|
|
@@ -284,6 +291,22 @@ async function readGitSnapshot(pi: ExtensionAPI, cwd: string): Promise<GitSnapsh
|
|
|
284
291
|
};
|
|
285
292
|
}
|
|
286
293
|
|
|
294
|
+
async function getSigningDiagnostics(pi: ExtensionAPI, cwd: string): Promise<SigningDiagnostics> {
|
|
295
|
+
const [commitSignRequiredRaw, headSignState, gpgFormatRaw, signingKeyRaw] = await Promise.all([
|
|
296
|
+
runGit(pi, cwd, ["config", "--bool", "--get", "commit.gpgsign"]),
|
|
297
|
+
runGit(pi, cwd, ["log", "-1", "--format=%G?"]),
|
|
298
|
+
runGit(pi, cwd, ["config", "--get", "gpg.format"]),
|
|
299
|
+
runGit(pi, cwd, ["config", "--get", "user.signingkey"]),
|
|
300
|
+
]);
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
commitSignRequired: commitSignRequiredRaw?.toLowerCase() === "true",
|
|
304
|
+
signState: headSignState?.trim().toUpperCase() || "N",
|
|
305
|
+
gpgFormat: gpgFormatRaw?.trim() || "(default:gpg)",
|
|
306
|
+
signingKey: signingKeyRaw?.trim() || "(not set)",
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
287
310
|
function buildStatusText(ctx: ExtensionContext, snapshot: GitSnapshot): string {
|
|
288
311
|
const t = ctx.ui.theme;
|
|
289
312
|
const f = FOOTER_FLAGS;
|
|
@@ -314,7 +337,7 @@ function buildStatusText(ctx: ExtensionContext, snapshot: GitSnapshot): string {
|
|
|
314
337
|
if (f.worktrees && snapshot.worktreeCount > 1) extraSection.push(t.fg("muted", `📦${snapshot.worktreeCount}`));
|
|
315
338
|
if (f.tag && snapshot.headTag) extraSection.push(t.fg("accent", `🏷${snapshot.headTag}`));
|
|
316
339
|
if (f.lastCommitAge && snapshot.lastCommitAge) extraSection.push(t.fg("dim", `⏱${snapshot.lastCommitAge}`));
|
|
317
|
-
if (f.signingMismatch && snapshot.signingMismatch) extraSection.push(t.fg("warning", "
|
|
340
|
+
if (f.signingMismatch && snapshot.signingMismatch) extraSection.push(t.fg("warning", "⚠️!"));
|
|
318
341
|
|
|
319
342
|
const isWorkingTreeClean =
|
|
320
343
|
snapshot.ahead === 0 &&
|
|
@@ -658,4 +681,25 @@ export default function gitFooterStatus(pi: ExtensionAPI) {
|
|
|
658
681
|
ctx.ui.notify("Git footer refreshed", "info");
|
|
659
682
|
},
|
|
660
683
|
});
|
|
684
|
+
|
|
685
|
+
pi.registerShortcut("ctrl+shift+g", {
|
|
686
|
+
description: "Show git signing mismatch diagnostics",
|
|
687
|
+
handler: async (ctx) => {
|
|
688
|
+
const diagnostics = await getSigningDiagnostics(pi, ctx.cwd);
|
|
689
|
+
if (!diagnostics.commitSignRequired) {
|
|
690
|
+
ctx.ui.notify("Signing mismatch: commit.gpgsign is OFF", "info");
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (!["N", "E"].includes(diagnostics.signState)) {
|
|
695
|
+
ctx.ui.notify("Signing mismatch: not currently triggered", "info");
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
ctx.ui.notify(
|
|
700
|
+
`Signing mismatch details: commit.gpgsign=ON, last-sign-state=${diagnostics.signState}, gpg.format=${diagnostics.gpgFormat}, user.signingkey=${diagnostics.signingKey}`,
|
|
701
|
+
"warning",
|
|
702
|
+
);
|
|
703
|
+
},
|
|
704
|
+
});
|
|
661
705
|
}
|
package/package.json
CHANGED