Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Scope branch refresh fetch to checked-out upstream refspec
Julius Marminge6708fe996ac1
diff --git a/apps/server/src/git.test.ts b/apps/server/src/git.test.tsindex 075207c6e..323b385ed 100644--- a/apps/server/src/git.test.ts+++ b/apps/server/src/git.test.ts@@ -324,6 +324,55 @@ describe("git integration", () => {expect(await git(source.path, "branch --show-current")).toBe(featureBranch);});+ it("refresh fetch is scoped to the checked out branch upstream refspec", async () => {+ await using remote = await makeTmpDir();+ await using source = await makeTmpDir();+ await git(remote.path, "init --bare");++ await initRepoWithCommit(source.path);+ const defaultBranch = (await listGitBranches({ cwd: source.path })).branches.find(+ (branch) => branch.current,+ )!.name;+ await git(source.path, `remote add origin ${JSON.stringify(remote.path)}`);+ await git(source.path, `push -u origin ${defaultBranch}`);++ const featureBranch = "feature/scoped-fetch";+ await git(source.path, `checkout -b ${featureBranch}`);+ await writeFile(path.join(source.path, "feature.txt"), "feature base\n");+ await git(source.path, "add feature.txt");+ await git(source.path, "commit -m 'feature base'");+ await git(source.path, `push -u origin ${featureBranch}`);+ await git(source.path, `checkout ${defaultBranch}`);++ class FetchRecordingGitCoreService extends GitCoreService {+ fetchArgs: readonly string[] | null = null;++ override async git(+ cwd: string,+ args: readonly string[],+ allowNonZeroExit = false,+ ): Promise<void> {+ if (args[0] === "fetch") {+ this.fetchArgs = args;+ return;+ }+ await super.git(cwd, args, allowNonZeroExit);+ }+ }++ const core = new FetchRecordingGitCoreService();+ await core.checkoutBranch({ cwd: source.path, branch: featureBranch });++ expect(await git(source.path, "branch --show-current")).toBe(featureBranch);+ expect(core.fetchArgs).toEqual([+ "fetch",+ "--quiet",+ "--no-tags",+ "origin",+ `+refs/heads/${featureBranch}:refs/remotes/origin/${featureBranch}`,+ ]);+ });+it("throws when branch does not exist", async () => {await using tmp = await makeTmpDir();await initRepoWithCommit(tmp.path);diff --git a/apps/server/src/git.ts b/apps/server/src/git.tsindex 1e3109526..ea035d988 100644--- a/apps/server/src/git.ts+++ b/apps/server/src/git.ts@@ -570,11 +570,16 @@ export class GitCoreService {return;}const remoteName = upstreamRef.slice(0, separatorIndex);+ const upstreamBranch = upstreamRef.slice(separatorIndex + 1);if (remoteName.length === 0) {return;}+ if (upstreamBranch.length === 0) {+ return;+ }- await this.git(cwd, ["fetch", "--quiet", "--no-tags", remoteName], true);+ const refspec = `+refs/heads/${upstreamBranch}:refs/remotes/${upstreamRef}`;+ await this.git(cwd, ["fetch", "--quiet", "--no-tags", remoteName, refspec], true);}async checkoutBranch(input: GitCheckoutInput): Promise<void> {