feat(git-bug): hide changes to git-bug refs/identities
1 files changed,  +22, -4
M src/lib/server/jj.ts
+22, -4
 1@@ -56,6 +56,18 @@ export async function isJjAvailable(): Promise<boolean> {
 2 
 3 // --- Revision helpers ---
 4 
 5+// git-bug stores issues/identities and Lamport clocks in dedicated refs and
 6+// operation-pack commits (e.g. create-clock-12, edit-clock-34, ops, version-4).
 7+// Those commits are tooling internals, not code under review, so hide them from
 8+// the change stack. Ref tips carry a `bugs/*` or `identities/*` bookmark, while
 9+// intermediate commits have none — but every one of them touches a clock file.
10+const BUG_REF_PATTERN = /^(?:bugs|identities)\//;
11+const CLOCK_FILE_PREFIXES = ['create-clock-', 'edit-clock-'];
12+
13+const clockCheck = CLOCK_FILE_PREFIXES.map(
14+	(p) => `diff.files().any(|f| f.path().display().starts_with(${JSON.stringify(p)}))`
15+).join(' || ');
16+
17 const T = {
18 	changeId: 'change_id.short()',
19 	commitId: 'commit_id.short()',
20@@ -64,12 +76,14 @@ const T = {
21 	bookmarks: 'bookmarks.join(",")',
22 	workingCopy: 'if(current_working_copy, "1", "0")',
23 	empty: 'if(empty, "1", "0")',
24-	parents: 'parents.map(|p| p.change_id().short()).join(",")'
25+	parents: 'parents.map(|p| p.change_id().short()).join(",")',
26+	bugClock: `(${clockCheck})`
27 };
28 
29 const CHANGE_TEMPLATE =
30 	`${T.changeId} ++ "\\t" ++ ${T.commitId} ++ "\\t" ++ ${T.description} ++ "\\t" ++ ` +
31-	`${T.bookmarks} ++ "\\t" ++ ${T.workingCopy} ++ "\\t" ++ ${T.empty} ++ "\\t" ++ ${T.parents} ++ "\\n"`;
32+	`${T.bookmarks} ++ "\\t" ++ ${T.workingCopy} ++ "\\t" ++ ${T.empty} ++ "\\t" ++ ${T.parents} ++ "\\t" ++ ` +
33+	`${T.bugClock} ++ "\\n"`;
34 
35 interface BaseInfo {
36 	revset: string;
37@@ -127,14 +141,18 @@ function parseChanges(raw: string): ChangeInfo[] {
38 	const out: ChangeInfo[] = [];
39 	for (const line of raw.split('\n')) {
40 		if (!line.trim()) continue;
41-		const [changeId, commitId, description, bookmarks, wc, empty, parents] = line.split('\t');
42+		const [changeId, commitId, description, bookmarks, wc, empty, parents, bugClock] =
43+			line.split('\t');
44 		if (!changeId || !commitId) continue;
45 		if (empty === '1') continue; // skip empty working-copy commits
46+		const bookmarkList = (bookmarks || '').split(',').filter(Boolean);
47+		// Skip git-bug issue/identity commits and Lamport-clock updates.
48+		if (bugClock === 'true' || bookmarkList.some((b) => BUG_REF_PATTERN.test(b))) continue;
49 		out.push({
50 			changeId,
51 			commitId,
52 			description: description || '',
53-			bookmarks: (bookmarks || '').split(',').filter(Boolean),
54+			bookmarks: bookmarkList,
55 			isWorkingCopy: wc === '1',
56 			parents: (parents || '').split(',').filter(Boolean)
57 		});