glop.dev 0.11.0 → 0.13.0
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/index.js +39 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -434,13 +434,31 @@ var doctorCommand = new Command3("doctor").description("Check that glop is set u
|
|
|
434
434
|
} else {
|
|
435
435
|
fail("Global hooks installed", "run `glop login`");
|
|
436
436
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
437
|
+
if (repoRoot) {
|
|
438
|
+
const repoBinding = loadRepoConfig();
|
|
439
|
+
if (repoBinding) {
|
|
440
|
+
let workspaceLabel = repoBinding.workspace_id;
|
|
441
|
+
try {
|
|
442
|
+
const wsRes = await fetch(`${config.server_url}/api/v1/cli/workspaces`, {
|
|
443
|
+
headers: {
|
|
444
|
+
Authorization: `Bearer ${config.api_key}`,
|
|
445
|
+
"X-Machine-Id": config.machine_id
|
|
446
|
+
},
|
|
447
|
+
signal: AbortSignal.timeout(5e3)
|
|
448
|
+
});
|
|
449
|
+
if (wsRes.ok) {
|
|
450
|
+
const data = await wsRes.json();
|
|
451
|
+
const ws = data.workspaces.find((w) => w.id === repoBinding.workspace_id);
|
|
452
|
+
if (ws) {
|
|
453
|
+
workspaceLabel = ws.name;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
} catch {
|
|
457
|
+
}
|
|
458
|
+
check("pass", "Repo bound to workspace", workspaceLabel);
|
|
459
|
+
} else {
|
|
460
|
+
check("warn", "Repo bound to workspace", "run `glop link` to bind this repo");
|
|
461
|
+
}
|
|
444
462
|
}
|
|
445
463
|
try {
|
|
446
464
|
const which = execSync3("which glop", {
|
|
@@ -475,6 +493,14 @@ import { spawn } from "child_process";
|
|
|
475
493
|
import { fileURLToPath } from "url";
|
|
476
494
|
import path5 from "path";
|
|
477
495
|
var PR_URL_RE = /(https:\/\/github\.com\/[^\s]+\/pull\/\d+)/;
|
|
496
|
+
function extractBashOutput(response) {
|
|
497
|
+
if (!response || typeof response !== "object") return "";
|
|
498
|
+
const r = response;
|
|
499
|
+
const parts = [];
|
|
500
|
+
if (typeof r.stdout === "string") parts.push(r.stdout);
|
|
501
|
+
if (typeof r.stderr === "string") parts.push(r.stderr);
|
|
502
|
+
return parts.join("\n");
|
|
503
|
+
}
|
|
478
504
|
function extractSlugFromTranscript(transcriptPath) {
|
|
479
505
|
try {
|
|
480
506
|
const fd = openSync(transcriptPath, "r");
|
|
@@ -512,9 +538,10 @@ var hookCommand = new Command4("__hook").description("internal").action(async ()
|
|
|
512
538
|
payload.workspace_id = repoConfig.workspace_id;
|
|
513
539
|
payload.git_user_name = getGitUserName();
|
|
514
540
|
payload.git_user_email = getGitUserEmail();
|
|
515
|
-
|
|
541
|
+
const toolOutput = payload.hook_event_name === "PostToolUse" && payload.tool_name === "Bash" ? extractBashOutput(payload.tool_response) : "";
|
|
542
|
+
if (toolOutput && /\bgit\s+commit\b/.test(
|
|
516
543
|
typeof payload.tool_input?.command === "string" ? payload.tool_input.command : ""
|
|
517
|
-
) && /\[\w[^\]]*\s+[a-f0-9]{7,}\]/.test(
|
|
544
|
+
) && /\[\w[^\]]*\s+[a-f0-9]{7,}\]/.test(toolOutput)) {
|
|
518
545
|
const diffStats = getCommitDiffStats();
|
|
519
546
|
if (diffStats) {
|
|
520
547
|
payload.commit_diff_stats = diffStats;
|
|
@@ -526,10 +553,10 @@ var hookCommand = new Command4("__hook").description("internal").action(async ()
|
|
|
526
553
|
if (slug) payload.slug = slug;
|
|
527
554
|
}
|
|
528
555
|
let prUrl = null;
|
|
529
|
-
if (
|
|
556
|
+
if (toolOutput && /\bgh\s+pr\s+create\b/.test(
|
|
530
557
|
typeof payload.tool_input?.command === "string" ? payload.tool_input.command : ""
|
|
531
558
|
)) {
|
|
532
|
-
const prMatch =
|
|
559
|
+
const prMatch = toolOutput.match(PR_URL_RE);
|
|
533
560
|
if (prMatch) prUrl = prMatch[1];
|
|
534
561
|
}
|
|
535
562
|
try {
|
|
@@ -801,7 +828,7 @@ async function checkForUpdate(currentVersion) {
|
|
|
801
828
|
// package.json
|
|
802
829
|
var package_default = {
|
|
803
830
|
name: "glop.dev",
|
|
804
|
-
version: "0.
|
|
831
|
+
version: "0.13.0",
|
|
805
832
|
type: "module",
|
|
806
833
|
bin: {
|
|
807
834
|
glop: "./dist/index.js"
|