Skip to content

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.

fix: avoid no-upstream push skip when base cannot be resolved

Julius Marminge96efd1cef044
diff --git a/apps/server/src/git/Layers/GitCore.test.ts b/apps/server/src/git/Layers/GitCore.test.ts
index 53fc7bf3b..7e6a7c6c0 100644
--- a/apps/server/src/git/Layers/GitCore.test.ts
+++ b/apps/server/src/git/Layers/GitCore.test.ts
@@ -1177,6 +1177,31 @@ it.layer(TestLayer)("git integration", (it) => {
}),
);
+ it.effect("pushes with upstream setup when no comparable base branch exists", () =>
+ Effect.gen(function* () {
+ const tmp = yield* makeTmpDir();
+ const remote = yield* makeTmpDir();
+ yield* git(tmp, ["init", "--initial-branch=trunk"]);
+ yield* git(tmp, ["config", "user.email", "[email protected]"]);
+ yield* git(tmp, ["config", "user.name", "Test"]);
+ yield* writeTextFile(path.join(tmp, "README.md"), "hello\n");
+ yield* git(tmp, ["add", "README.md"]);
+ yield* git(tmp, ["commit", "-m", "initial"]);
+ yield* git(remote, ["init", "--bare"]);
+ yield* git(tmp, ["remote", "add", "origin", remote]);
+ yield* git(tmp, ["checkout", "-b", "feature/no-base"]);
+
+ const core = yield* GitCore;
+ const pushed = yield* core.pushCurrentBranch(tmp, null);
+ expect(pushed.status).toBe("pushed");
+ expect(pushed.setUpstream).toBe(true);
+ expect(pushed.upstreamBranch).toBe("origin/feature/no-base");
+ expect(yield* git(tmp, ["rev-parse", "--abbrev-ref", "@{upstream}"])).toBe(
+ "origin/feature/no-base",
+ );
+ }),
+ );
+
it.effect("includes command context when worktree removal fails", () =>
Effect.gen(function* () {
const tmp = yield* makeTmpDir();
diff --git a/apps/server/src/git/Layers/GitCore.ts b/apps/server/src/git/Layers/GitCore.ts
index 543a721ef..570b214fb 100644
--- a/apps/server/src/git/Layers/GitCore.ts
+++ b/apps/server/src/git/Layers/GitCore.ts
@@ -630,12 +630,25 @@ const makeGitCore = Effect.gen(function* () {
);
}
- if (details.aheadCount === 0 && details.behindCount === 0) {
- return {
- status: "skipped_up_to_date" as const,
- branch,
- ...(details.upstreamRef ? { upstreamBranch: details.upstreamRef } : {}),
- };
+ const hasNoLocalDelta = details.aheadCount === 0 && details.behindCount === 0;
+ if (hasNoLocalDelta) {
+ if (details.hasUpstream) {
+ return {
+ status: "skipped_up_to_date" as const,
+ branch,
+ ...(details.upstreamRef ? { upstreamBranch: details.upstreamRef } : {}),
+ };
+ }
+
+ const comparableBaseBranch = yield* resolveBaseBranchForNoUpstream(cwd, branch).pipe(
+ Effect.catch(() => Effect.succeed(null)),
+ );
+ if (comparableBaseBranch) {
+ return {
+ status: "skipped_up_to_date" as const,
+ branch,
+ };
+ }
}
if (!details.hasUpstream) {