feat(vcs): JJ #2461
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
juliusmarminge changed the title
juliusmarminge reviewed
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/vcs/JjVcsDriver.ts line 52Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,19 @@1+import { Effect, FileSystem, Layer } from "effect";2+3+import { VcsOutputDecodeError, VcsProcessExitError } from "@t3tools/contracts";4+import { VcsDriver, type VcsDriverShape } from "./VcsDriver.ts";5+import { nowFreshness } from "./VcsFreshness.ts";6+import { VcsProcess, type VcsProcessShape } from "./VcsProcess.ts";7+8+const WORKSPACE_FILES_MAX_OUTPUT_BYTES = 16 * 1024 * 1024;9+const CHECK_IGNORE_MAX_STDIN_BYTES = 256 * 1024;10+11+function splitNullSeparatedPaths(input: string, truncated: boolean): string[] {12+ const parts = input.split("\0");13+ if (parts.length === 0) return [];14+15+ if (truncated && parts[parts.length - 1]?.length) {16+ parts.pop();17+ }18+19+ return parts.filter((value) => value.length > 0);
juliusmarminge reviewed
- @@ -0,0 +207,21 @@207+ readonly truncateOutputAtMaxBytes?: boolean;208+ },209+) => processCommand(process, "jj", operation, cwd, ["--no-pager", ...args], options);210+211+const gitCommand = (212+ process: VcsProcessShape,213+ operation: string,214+ cwd: string,215+ args: ReadonlyArray<string>,216+ options?: Parameters<typeof processCommand>[5],217+) => processCommand(process, "git", operation, cwd, args, options);218+219+function fileSystemError(operation: string, cwd: string, detail: string, cause: unknown) {220+ return new VcsOutputDecodeError({221+ operation,222+ command: "git check-ignore",223+ cwd,224+ detail,225+ cause,226+ });227+}@@ -0,0 +413,21 @@413+414+ yield* Effect.scoped(415+ Effect.gen(function* () {416+ const gitDir = yield* makeScopedTempGitDir(fileSystem, operation, cwd);417+ const initResult = yield* gitCommand(418+ process,419+ operation,420+ cwd,421+ ["--git-dir", gitDir, "init", "--bare"],422+ {423+ allowNonZeroExit: true,424+ },425+ );426+ if (initResult.exitCode !== 0) {427+ return yield* new VcsProcessExitError({428+ operation,429+ command: "git init --bare",430+ cwd,431+ exitCode: initResult.exitCode,432+ detail: initResult.stderr.trim() || "git init --bare failed",433+ });
- apps/server/src/vcs/JjVcsDriver.ts line 96Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +76,21 @@76+ });77+}78+79+function parseNullRecord(record: string): string[] {80+ return record.split("\0").map((value) => value.trim());81+}82+83+function decodeJjCurrentChange(raw: string, cwd: string): JjCurrentChange | null {84+ const trimmed = raw.trim();85+ if (trimmed.length === 0) {86+ return null;87+ }88+89+ const [changeId, commitId, description] = parseNullRecord(trimmed);90+ if (!changeId) {91+ throw new VcsOutputDecodeError({92+ operation: "JjVcsDriver.currentChange",93+ command: "jj log",94+ cwd,95+ detail: "jj current change output did not include a change id",96+ });
- @@ -251,3 +252,4 @@251252 if (current === null) {252253 return mergeGitStatusParts(253254 {255+ kind: "unknown",
- apps/web/src/vcsPresentation.ts line 48OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +28,21 @@28+ refNounPlural: "refs",29+ currentRefFallback: "checkout",30+};31+32+export function resolveVcsTerms(kind: VcsDriverKind | null | undefined): VcsTerms {33+ if (kind === "jj") {34+ return {35+ systemName: "JJ",36+ repositoryNoun: "workspace",37+ refNoun: "bookmark",38+ refNounPlural: "bookmarks",39+ currentRefFallback: "working copy",40+ };41+ }42+43+ if (kind === "sapling") {44+ return {45+ ...gitLikeTerms,46+ systemName: "Sapling",47+ };48+ }
- @@ -0,0 +339,21 @@339+ );340+341+ if (result.exitCode !== 0) {342+ return {343+ remotes: [],344+ freshness: yield* nowFreshness(),345+ };346+ }347+348+ return {349+ remotes: parseJjRemoteList(result.stdout).map((remote) => ({350+ name: remote.name,351+ url: remote.url,352+ pushUrl: Option.none(),353+ isPrimary: remote.name === "origin",354+ })),355+ freshness: yield* nowFreshness(),356+ };357+ });358+359+ const currentChange: JjVcsDriverShape["currentChange"] = (cwd) =>
- @@ -0,0 +29,21 @@29+ data: null,30+ error: null,31+ isPending: true,32+});33+34+/* --- Atoms ---------------------------------------------------------- */35+36+const knownSourceControlDiscoveryKeys = new Set<string>();37+38+export const sourceControlDiscoveryStateAtom = Atom.family((key: string) => {39+ knownSourceControlDiscoveryKeys.add(key);40+ return Atom.make(INITIAL_SOURCE_CONTROL_DISCOVERY_STATE).pipe(41+ Atom.keepAlive,42+ Atom.withLabel(`source-control-discovery:${key}`),43+ );44+});45+46+export const EMPTY_SOURCE_CONTROL_DISCOVERY_ATOM = Atom.make(47+ EMPTY_SOURCE_CONTROL_DISCOVERY_STATE,48+).pipe(Atom.keepAlive, Atom.withLabel("source-control-discovery:null"));49+
- apps/server/src/vcs/VcsStatusBroadcaster.ts line 229Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -226,4 +221,3 @@226221 const refreshStatus: VcsStatusBroadcasterShape["refreshStatus"] = Effect.fn(227222 "VcsStatusBroadcaster.refreshStatus",228223 )(function* (rawCwd) {229- const cwd = normalizeCwd(rawCwd);
juliusmarminge closed this
Sign in to join this conversation.



Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
52cb29e7-cd51-4ba1-9007-bf91a124f5beYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.