codiedev 0.7.4 → 0.7.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/dist/commands/reverseTicket.js +11 -32
- package/package.json +1 -1
|
@@ -36,7 +36,6 @@ function parseArgs(args) {
|
|
|
36
36
|
let base;
|
|
37
37
|
let forcedKey;
|
|
38
38
|
let noTruncate = false;
|
|
39
|
-
let dirty = false;
|
|
40
39
|
for (let i = 0; i < args.length; i++) {
|
|
41
40
|
const a = args[i];
|
|
42
41
|
if ((a === "--with" || a === "-w") && i + 1 < args.length) {
|
|
@@ -54,20 +53,17 @@ function parseArgs(args) {
|
|
|
54
53
|
else if (a === "--full") {
|
|
55
54
|
noTruncate = true;
|
|
56
55
|
}
|
|
57
|
-
else if (a === "--dirty") {
|
|
58
|
-
dirty = true;
|
|
59
|
-
}
|
|
60
56
|
else if (!a.startsWith("--") && !prUrl) {
|
|
61
57
|
prUrl = a;
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
|
-
return { prUrl, base, forcedKey, noTruncate
|
|
60
|
+
return { prUrl, base, forcedKey, noTruncate };
|
|
65
61
|
}
|
|
66
62
|
async function runReverseTicket(args) {
|
|
67
|
-
const { prUrl, base, forcedKey, noTruncate
|
|
63
|
+
const { prUrl, base, forcedKey, noTruncate } = parseArgs(args);
|
|
68
64
|
// No PR URL → branch mode (mid-session, no PR exists yet).
|
|
69
65
|
if (!prUrl) {
|
|
70
|
-
return runBranchMode({ explicitBase: base, forcedKey
|
|
66
|
+
return runBranchMode({ explicitBase: base, forcedKey });
|
|
71
67
|
}
|
|
72
68
|
const parsed = parsePrUrl(prUrl);
|
|
73
69
|
if (!parsed) {
|
|
@@ -241,38 +237,22 @@ async function runBranchMode(opts) {
|
|
|
241
237
|
}
|
|
242
238
|
};
|
|
243
239
|
const shQuote = (s) => `'${s.replace(/'/g, "'\\''")}'`;
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
// uncommitted modifications and (via ls-files --others) untracked leftovers
|
|
248
|
-
// from prior branches. That produced audit-grade leaks where a one-commit
|
|
249
|
-
// copy-button branch generated a draft describing an unrelated auth rebrand
|
|
250
|
-
// that was sitting dirty in the working tree.
|
|
251
|
-
//
|
|
252
|
-
// --dirty re-enables the old behavior for the "ticket my current WIP"
|
|
253
|
-
// intent — explicit opt-in, since the user is asserting the dirty state is
|
|
254
|
-
// theirs and on-topic.
|
|
255
|
-
const includeDirty = opts.dirty === true;
|
|
256
|
-
const trackedRaw = git(`diff --name-only ${baseSha}${includeDirty ? "" : " HEAD"}`);
|
|
240
|
+
// Capture all work relative to the base ref: committed + uncommitted-tracked
|
|
241
|
+
// + new untracked. Matches "ticket my current changes" intent.
|
|
242
|
+
const trackedRaw = git(`diff --name-only ${baseSha}`);
|
|
257
243
|
const trackedFiles = trackedRaw ? trackedRaw.split("\n").filter(Boolean) : [];
|
|
258
|
-
const untrackedRaw =
|
|
259
|
-
? safeGit(() => git("ls-files --others --exclude-standard"))
|
|
260
|
-
: undefined;
|
|
244
|
+
const untrackedRaw = safeGit(() => git("ls-files --others --exclude-standard"));
|
|
261
245
|
const untrackedFiles = untrackedRaw
|
|
262
246
|
? untrackedRaw.split("\n").filter(Boolean)
|
|
263
247
|
: [];
|
|
264
248
|
const filesChanged = Array.from(new Set([...trackedFiles, ...untrackedFiles]));
|
|
265
249
|
if (filesChanged.length === 0) {
|
|
266
|
-
|
|
267
|
-
console.error(`No changes detected between ${baseRef} and ${scope} on ${branch}.`);
|
|
268
|
-
if (!includeDirty) {
|
|
269
|
-
console.error("Pass --dirty to also include uncommitted + untracked changes.");
|
|
270
|
-
}
|
|
250
|
+
console.error(`No changes detected between ${baseRef} and your working tree on ${branch}.`);
|
|
271
251
|
process.exit(1);
|
|
272
252
|
}
|
|
273
253
|
let stat = "";
|
|
274
254
|
try {
|
|
275
|
-
const trackedStat = git(`diff --stat=200 ${baseSha}
|
|
255
|
+
const trackedStat = git(`diff --stat=200 ${baseSha}`);
|
|
276
256
|
const untrackedStatLines = untrackedFiles.map((f) => {
|
|
277
257
|
const wc = shellTolerant(`wc -l < ${shQuote(f)}`);
|
|
278
258
|
const n = parseInt(wc.split(/\s+/)[0] || "0", 10) || 0;
|
|
@@ -289,10 +269,9 @@ async function runBranchMode(opts) {
|
|
|
289
269
|
let diff = "";
|
|
290
270
|
try {
|
|
291
271
|
const sourceTracked = trackedFiles.filter((f) => !isNoise(f));
|
|
292
|
-
const headRef = includeDirty ? "" : " HEAD";
|
|
293
272
|
const trackedDiff = sourceTracked.length > 0
|
|
294
|
-
? git(`diff ${baseSha}
|
|
295
|
-
: git(`diff ${baseSha}
|
|
273
|
+
? git(`diff ${baseSha} -- ${sourceTracked.map(shQuote).join(" ")}`)
|
|
274
|
+
: git(`diff ${baseSha}`);
|
|
296
275
|
const sourceUntracked = untrackedFiles.filter((f) => !isNoise(f));
|
|
297
276
|
const untrackedDiffs = sourceUntracked.map((f) => shellTolerant(`git diff --no-index --no-color -- /dev/null ${shQuote(f)}`));
|
|
298
277
|
diff = [trackedDiff, ...untrackedDiffs]
|
package/package.json
CHANGED