The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 10:45 UTC
fix(forgejo): publishing a repository with no commits no longer fails the fj login check (#26770)
Igor Makowski committed
Oct 30, 2026 at 22:20 UTC
26af67426b6ab4da8203fc1a7384c6b5385c3335
3 files changed
+19
-4
packages/source-control-forgejo/src/server/ForgejoCli.ts
+6
-1
@@ -433,7 +433,12 @@ export const make = Effect.gen(function* () {
433
const now = yield* Clock.currentTimeMillis;
434
const cached = authenticated.get(login.url);
435
if (token && cached?.token === token && now - cached.time < 30_000) return token;
436
- yield* execute({ command: "fj", cwd, args: ["--host", login.url, "whoami"] });
436
+ // fj reads the cwd repository even with --host and fails on an unborn branch.
437
+ yield* execute({
438
+ command: "fj",
439
+ cwd: yield* HostProcess.HomeDirectory,
440
+ args: ["--host", login.url, "whoami"],
441
+ });
442
// fj owns OAuth renewal. Re-read the file after it has refreshed an expired token.
443
const refreshed = (yield* readKeys(cwd)).hosts[login.name]?.token;
444
if (!refreshed)
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+10
-2
@@ -12,6 +12,7 @@ import * as HttpClientRequest from "effect/http/HttpClientRequest";
12
import * as HttpClientResponse from "effect/http/HttpClientResponse";
13
import { VcsProcessSpawnError } from "@t3tools/contracts";
14
import { firstNonEmptyLine } from "@t3tools/source-control-core/server/discovery";
15
+import * as HostProcess from "@t3tools/shared/HostProcess";
16
import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost";
17
18
import * as ForgejoCli from "./ForgejoCli.ts";
@@ -1295,6 +1296,7 @@ it.effect("routes mounted Forgejo repositories without repeating the mount in AP
1296
it.effect("prefers fj for HTTP and ported SSH aliases on root servers", () => {
1297
const commands: string[] = [];
1298
const requests: string[] = [];
1299
+ let repositoryCwd = "";
1300
return Effect.gen(function* () {
1301
const cli = yield* ForgejoCli.make;
1302
for (const remoteUrl of [
@@ -1392,7 +1394,8 @@ it.effect("prefers fj for HTTP and ported SSH aliases on root servers", () => {
1394
process: {
1395
run: (input) => {
1396
commands.push(input.command);
1395
- if (input.command === "git")
1397
+ if (input.command === "git") {
1398
+ repositoryCwd = input.cwd;
1399
return Effect.succeed(
1400
input.cwd === "/no-remotes"
1401
? processOutput("", { exitCode: ChildProcessSpawner.ExitCode(2) })
@@ -1402,10 +1405,11 @@ it.effect("prefers fj for HTTP and ported SSH aliases on root servers", () => {
1405
: "origin\thttp://forgejo.local:3000/maria/project.git (fetch)\nother\thttp://forgejo.local:3000/maria/other.git (fetch)\nunrelated\thttp://other.local:3000/maria/project.git (fetch)",
1406
),
1407
);
1408
+ }
1409
assert.strictEqual(input.command, "fj");
1410
assert.deepStrictEqual(input.args, [
1411
"--host",
1408
- input.cwd === "/no-remotes"
1412
+ repositoryCwd === "/no-remotes"
1413
? "https://forgejo.local:3000"
1414
: "http://forgejo.local:3000",
1415
"whoami",
@@ -1519,11 +1523,13 @@ it.effect("loads later fj review pages when the server caps pages below the requ
1523
}
1524
assert.strictEqual(input.command, "fj");
1525
assert.deepStrictEqual(input.args, ["--host", "https://forgejo.test", "whoami"]);
1526
+ assert.strictEqual(input.cwd, "/home/maria");
1527
return Effect.succeed(processOutput(""));
1528
},
1529
},
1530
}),
1531
),
1532
+ Effect.provideService(HostProcess.HomeDirectory, "/home/maria"),
1533
);
1534
});
1535
@@ -1680,6 +1686,7 @@ it.effect(
1686
processOutput("http://forgejo.local:3000/maria/project.git\n"),
1687
);
1688
if (input.command === "fj") {
1689
+ assert.strictEqual(input.cwd, "/home/maria");
1690
if (scenario === "missing")
1691
return Effect.fail(
1692
new VcsProcessSpawnError({
@@ -1727,6 +1734,7 @@ it.effect(
1734
}),
1735
),
1736
),
1737
+ Effect.provideService(HostProcess.HomeDirectory, "/home/maria"),
1738
);
1739
}
1740
}),
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.ts
+3
-1
@@ -4,6 +4,7 @@ import * as FileSystem from "effect/FileSystem";
4
import * as Schema from "effect/Schema";
5
import * as Result from "effect/Result";
6
import { SourceControlProviderError } from "@t3tools/contracts";
7
+import * as HostProcess from "@t3tools/shared/HostProcess";
8
import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
9
import * as ForgejoCli from "./ForgejoCli.ts";
10
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
@@ -94,7 +95,8 @@ export const makeDiscovery = Effect.gen(function* () {
95
logins.find((entry) => entry.default === "true") ||
96
logins[0];
97
const fj = yield* probeSourceControlProvider({
97
- cwd,
98
+ // fj reads the cwd repository even with --host and fails on an unborn branch.
99
+ cwd: yield* HostProcess.HomeDirectory,
100
process,
101
spec: {
102
...discovery,