Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions apps/server/src/project/RepositoryIdentityResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,30 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
);

it.effect("resolves identity for a partial clone whose fetch line carries a filter", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const cwd = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-repository-identity-partial-clone-",
});

yield* git(cwd, ["init"]);
yield* git(cwd, ["remote", "add", "origin", "https://github.com/T3Tools/t3code.git"]);
// `git clone --filter=blob:none` writes these, making `git remote -v`
// print `origin\t<url> (fetch) [blob:none]`.
yield* git(cwd, ["config", "remote.origin.promisor", "true"]);
yield* git(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
expect((yield* git(cwd, ["remote", "-v"])).stdout).toContain("(fetch) [blob:none]");

const resolver = yield* RepositoryIdentityResolver.RepositoryIdentityResolver;
const identity = yield* resolver.resolve(cwd);

expect(identity?.canonicalKey).toBe("github.com/t3tools/t3code");
expect(identity?.locator.remoteName).toBe("origin");
expect(identity?.locator.remoteUrl).toBe("https://github.com/T3Tools/t3code.git");
}).pipe(Effect.provide(RepositoryIdentityResolver.layer)),
);

it.effect("returns the git top-level root path when resolving from a nested workspace", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/project/RepositoryIdentityResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function parseRemoteFetchUrls(stdout: string): Map<string, string> {
for (const line of stdout.split("\n")) {
const trimmed = line.trim();
if (trimmed.length === 0) continue;
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)$/.exec(trimmed);
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]*\])?$/.exec(trimmed);
if (!match) continue;
const [, remoteName = "", remoteUrl = "", direction = ""] = match;
if (direction !== "fetch" || remoteName.length === 0 || remoteUrl.length === 0) {
Expand Down
35 changes: 35 additions & 0 deletions apps/server/src/vcs/GitVcsDriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as Fiber from "effect/Fiber";
import * as TestClock from "effect/testing/TestClock";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
import * as Path from "effect/Path";
import * as PlatformError from "effect/PlatformError";
import { ChildProcessSpawner } from "effect/unstable/process";
Expand Down Expand Up @@ -515,6 +516,40 @@ it.effect("checkpoint recovery preserves interruption and removes the private in
}).pipe(Effect.scoped, Effect.provide(GitContractLayer)),
);

it.effect("listRemotes keeps a partial-clone remote whose fetch line carries a filter", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const driver = yield* GitVcsDriver.makeVcsDriverShape();
const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-list-remotes-" });
const git = (args: ReadonlyArray<string>) =>
driver.execute({ operation: "list-remotes-test", cwd, args });
yield* git(["init"]);
yield* git(["remote", "add", "origin", "https://github.com/pingdotgg/t3code.git"]);
yield* git(["config", "remote.origin.promisor", "true"]);
yield* git(["config", "remote.origin.partialclonefilter", "blob:none"]);
yield* git(["remote", "add", "fork", "git@github.com:octocat/t3code.git"]);
assert.include((yield* git(["remote", "-v"])).stdout, "(fetch) [blob:none]");

const { remotes } = yield* driver.listRemotes(cwd);

assert.deepStrictEqual(
remotes.map(({ name, url, pushUrl }) => ({ name, url, pushUrl })),
[
{
name: "fork",
url: "git@github.com:octocat/t3code.git",
pushUrl: Option.some("git@github.com:octocat/t3code.git"),
},
{
name: "origin",
url: "https://github.com/pingdotgg/t3code.git",
pushUrl: Option.some("https://github.com/pingdotgg/t3code.git"),
},
],
);
}).pipe(Effect.scoped, Effect.provide(GitContractLayer)),
);

it.effect("checkpoint capture does not rerun clean filters for unchanged indexed files", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/vcs/GitVcsDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ function parseGitRemoteVerboseOutput(
continue;
}

const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)$/.exec(trimmed);
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]*\])?$/.exec(trimmed);
if (!match) {
continue;
}
Expand Down
21 changes: 21 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2801,6 +2801,27 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
assert.equal(yield* git(cwd, ["remote"]), "octocat\norigin");
}),
);

it.effect("ensureRemote reuses a partial-clone remote whose fetch line carries a filter", () =>
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
yield* initRepoWithCommit(cwd);
const driver = yield* GitVcsDriver.GitVcsDriver;

yield* git(cwd, ["remote", "add", "origin", "https://github.com/pingdotgg/t3code.git"]);
yield* git(cwd, ["config", "remote.origin.promisor", "true"]);
yield* git(cwd, ["config", "remote.origin.partialclonefilter", "blob:none"]);
assert.include(yield* git(cwd, ["remote", "-v"]), "(fetch) [blob:none]");

const reused = yield* driver.ensureRemote({
cwd,
preferredName: "pingdotgg",
url: "git@github.com:pingdotgg/t3code.git",
});
assert.equal(reused, "origin");
assert.equal(yield* git(cwd, ["remote"]), "origin");
}),
);
});

describe("commit context", () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function parseRemoteFetchUrls(stdout: string): Map<string, string> {
for (const line of stdout.split("\n")) {
const trimmed = line.trim();
if (trimmed.length === 0) continue;
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)$/.exec(trimmed);
const match = /^(\S+)\s+(\S+)\s+\((fetch|push)\)(?:\s+\[[^\]]*\])?$/.exec(trimmed);
if (!match) continue;
const [, remoteName = "", remoteUrl = "", direction = ""] = match;
if (direction !== "fetch" || remoteName.length === 0 || remoteUrl.length === 0) {
Expand Down
22 changes: 22 additions & 0 deletions docs/fork-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -955,3 +955,25 @@ for per-match decisions and the absorption PR record.
"keywords": ["scheduler", "scheduledTasks", "scheduler.state-set", "schedulerOwnsThread"]
}
```

## Partial-clone remotes keep repository identity

```json
{
"id": "partial-clone-remotes",
"purpose": "Parse `git remote -v` lines that end with a partial-clone filter such as `[blob:none]`, so partial clones keep repository identity and remote lookup.",
"issues": ["https://github.com/toolboxmd/chromeria/issues/135"],
"prs": ["https://github.com/toolboxmd/chromeria/compare/main...fix/partial-clone-identity"],
"newFiles": [],
"upstreamFiles": [
"apps/server/src/project/RepositoryIdentityResolver.test.ts",
"apps/server/src/project/RepositoryIdentityResolver.ts",
"apps/server/src/vcs/GitVcsDriver.test.ts",
"apps/server/src/vcs/GitVcsDriver.ts",
"apps/server/src/vcs/GitVcsDriverCore.test.ts",
"apps/server/src/vcs/GitVcsDriverCore.ts"
],
"sharedFiles": [],
"keywords": ["partial clone", "blob:none", "partialclonefilter", "git remote -v"]
}
```
8 changes: 8 additions & 0 deletions scripts/fork-upstream-edits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,11 @@ packages/contracts/src/environmentHttp.ts

# Check-gated scheduled tasks (#123)
apps/server/src/orchestration/projector.ts

# Partial-clone remotes keep repository identity (#135)
apps/server/src/project/RepositoryIdentityResolver.test.ts
apps/server/src/project/RepositoryIdentityResolver.ts
apps/server/src/vcs/GitVcsDriver.test.ts
apps/server/src/vcs/GitVcsDriver.ts
apps/server/src/vcs/GitVcsDriverCore.test.ts
apps/server/src/vcs/GitVcsDriverCore.ts
Loading