The best way to control Claude Code, Codex and more from any computer or phone
fix(forgejo): fast-forward-only repositories can merge pull requests (#32738)
Julius Marminge committed
Nov 12, 2026 at 19:31 UTC
5e18314b88369981fb6cde7ebc51c0c76ff31d2d
11 files changed
+147
-21
apps/mobile/src/features/pull-requests/pullRequestActions.ts
+4
@@ -33,6 +33,10 @@ export const MERGE_METHODS = {
33
description: "Keep the commits and add a merge commit.",
34
},
35
rebase: { title: "Rebase and merge", description: "Add the commits without a merge commit." },
36
+ "fast-forward": {
37
+ title: "Fast-forward merge",
38
+ description: "Add the commits as they are. Needs the branch to contain the base.",
39
+ },
40
} as const satisfies Record<PullRequestMergeMethod, { title: string; description: string }>;
41
42
export function pullRequestActionLabel(
apps/mobile/src/persistence/mobile-preferences.ts
+3
-6
@@ -11,7 +11,7 @@ import {
11
PullRequestListFilters,
12
PullRequestListState,
13
type ProviderInstanceId,
14
- type PullRequestMergeMethod,
14
+ PullRequestMergeMethod,
15
type SidebarProjectGroupingMode,
16
} from "@t3tools/contracts";
17
import { ToolCallVisibility } from "@t3tools/contracts/settings";
@@ -174,6 +174,7 @@ export class MobilePreferencesStore extends Context.Service<
174
>()("@t3tools/mobile/persistence/mobile-preferences/MobilePreferencesStore") {}
175
176
const isToolCallVisibility = Schema.is(ToolCallVisibility);
177
+const isPullRequestMergeMethod = Schema.is(PullRequestMergeMethod);
178
179
function sanitizePreferences(parsed: Preferences): Preferences {
180
const preferences: {
@@ -232,11 +233,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
233
preferences.pullRequestHideTestFiles = parsed.pullRequestHideTestFiles;
234
}
235
235
- if (
236
- parsed.pullRequestMergeMethod === "squash" ||
237
- parsed.pullRequestMergeMethod === "merge" ||
238
- parsed.pullRequestMergeMethod === "rebase"
239
- ) {
236
+ if (isPullRequestMergeMethod(parsed.pullRequestMergeMethod)) {
237
preferences.pullRequestMergeMethod = parsed.pullRequestMergeMethod;
238
}
239
apps/web/src/components/pullRequest/pullRequestDetail.logic.ts
+1
@@ -54,6 +54,7 @@ export const PULL_REQUEST_MERGE_METHOD_LABELS: Record<PullRequestMergeMethod, st
54
merge: "Merge",
55
squash: "Squash and merge",
56
rebase: "Rebase and merge",
57
+ "fast-forward": "Fast-forward merge",
58
};
59
60
export function allowsSinglePullRequestMerge(input: {
apps/web/src/uiStateStore.test.ts
+6
@@ -136,6 +136,12 @@ describe("parsePersistedState", () => {
136
});
137
});
138
139
+ it("keeps a persisted fast-forward merge method", () => {
140
+ expect(
141
+ parsePersistedState({ pullRequestMergeMethod: "fast-forward" }).pullRequestMergeMethod,
142
+ ).toBe("fast-forward");
143
+ });
144
+
145
it.each([undefined, 1])("ignores changed-file expansion version %s", (version) => {
146
const parsed = parsePersistedState({
147
...(version === undefined ? {} : { threadChangedFilesExpansionVersion: version }),
apps/web/src/uiStateStore.ts
+4
-5
@@ -1,5 +1,6 @@
1
import { Debouncer } from "@tanstack/react-pacer";
2
-import type { PullRequestMergeMethod } from "@t3tools/contracts";
2
+import { PullRequestMergeMethod } from "@t3tools/contracts";
3
+import * as Schema from "effect/Schema";
4
import { create } from "zustand";
5
import { normalizeProjectPathForComparison } from "@t3tools/client-runtime/state/projects";
6
@@ -99,6 +100,8 @@ function sanitizeOptionalKey(value: unknown): string | null {
100
return typeof value === "string" && value.length > 0 ? value : null;
101
}
102
103
+const isPullRequestMergeMethod = Schema.is(PullRequestMergeMethod);
104
+
105
function sanitizeTimestampRecord(value: unknown): Record<string, string> {
106
if (!value || typeof value !== "object") {
107
return {};
@@ -114,10 +117,6 @@ function sanitizeTimestampRecord(value: unknown): Record<string, string> {
117
);
118
}
119
117
-function isPullRequestMergeMethod(value: unknown): value is PullRequestMergeMethod {
118
- return value === "merge" || value === "squash" || value === "rebase";
119
-}
120
-
120
export function parsePersistedState(parsed: PersistedUiState): UiState {
121
const projectExpandedById =
122
parsed.projectExpandedById === undefined
packages/contracts/src/pullRequest.test.ts
+1
-1
@@ -104,7 +104,7 @@ describe("PullRequestCapabilities", () => {
104
capabilities: {
105
...base,
106
actions: options.actions,
107
- mergeMethods: ["squash", "fast-forward", "merge"],
107
+ mergeMethods: ["squash", "semi-linear", "merge"],
108
updateMethods: options.updateMethods,
109
review: { ...base.review, verdicts: options.verdicts },
110
},
packages/contracts/src/pullRequest.ts
+9
-1
@@ -54,7 +54,13 @@ export type PullRequestChecksState = typeof PullRequestChecksState.Type;
54
export const PullRequestMergeability = Schema.Literals(["mergeable", "conflicting", "unknown"]);
55
export type PullRequestMergeability = typeof PullRequestMergeability.Type;
56
57
-export const PullRequestMergeMethod = Schema.Literals(["merge", "squash", "rebase"]);
57
+/** `fast-forward` refuses unless the head contains the base, where `rebase` rewrites the branch onto it. */
58
+export const PullRequestMergeMethod = Schema.Literals([
59
+ "merge",
60
+ "squash",
61
+ "rebase",
62
+ "fast-forward",
63
+]);
64
export type PullRequestMergeMethod = typeof PullRequestMergeMethod.Type;
65
66
export const PullRequestAction = Schema.Literals([
@@ -335,6 +341,8 @@ export const PullRequestMergeCapabilities = Schema.Struct({
341
merge: Schema.Boolean,
342
squash: Schema.Boolean,
343
rebase: Schema.Boolean,
344
+ /** Optional so servers that predate it still decode; absent means not allowed. */
345
+ "fast-forward": Schema.optional(Schema.Boolean),
346
});
347
export type PullRequestMergeCapabilities = typeof PullRequestMergeCapabilities.Type;
348
packages/source-control-forgejo/src/server/ForgejoPullRequestProvider.test.ts
+103
@@ -121,3 +121,106 @@ it.effect("filters listed pull requests by the requested state", () =>
121
assert.deepStrictEqual(yield* numbers("open"), []);
122
}),
123
);
124
+
125
+const fastForwardOnly = {
126
+ cwd: "/forgejo",
127
+ repository: "maria/project",
128
+ host: "forge.example:3000",
129
+ number: 3,
130
+};
131
+const fastForwardOnlySettings = {
132
+ allow_merge_commits: false,
133
+ allow_squash_merge: false,
134
+ allow_rebase: false,
135
+ allow_rebase_explicit: false,
136
+ allow_fast_forward_only_merge: true,
137
+ default_merge_style: "fast-forward-only",
138
+};
139
+const fastForwardOnlyProvider = (
140
+ writes: Array<{ path: string; body: unknown }>,
141
+ mergeSettings: object = fastForwardOnlySettings,
142
+) =>
143
+ ForgejoPullRequestProvider.make.pipe(
144
+ Effect.provide(
145
+ Layer.mock(ForgejoCli.ForgejoCli)({
146
+ api: (input) => {
147
+ const [path] = input.path.split("?");
148
+ const reply = (value: unknown) =>
149
+ Effect.succeed(TestSourceControlHost.processOutput(JSON.stringify(value)));
150
+ if (input.method === "POST") {
151
+ writes.push({ path: input.path, body: input.body });
152
+ return reply("");
153
+ }
154
+ switch (path) {
155
+ case "user":
156
+ return reply({ login: "maria" });
157
+ case "repos/maria/project":
158
+ return reply({
159
+ full_name: "maria/project",
160
+ permissions: { push: true, admin: true },
161
+ ...mergeSettings,
162
+ });
163
+ case "repos/maria/project/pulls/3":
164
+ return reply({
165
+ number: 3,
166
+ title: "Fast-forward me",
167
+ body: "",
168
+ html_url: "https://forge.example:3000/maria/project/pulls/3",
169
+ user: { login: "maria" },
170
+ state: "open",
171
+ merged: false,
172
+ mergeable: true,
173
+ head: { ref: "feature", sha: "head-sha", repo: null },
174
+ base: { ref: "main", sha: "base-sha", repo: null },
175
+ merge_base: "base-sha",
176
+ created_at: "2026-10-12T00:00:00Z",
177
+ updated_at: "2026-10-12T00:00:00Z",
178
+ closed_at: null,
179
+ merged_at: null,
180
+ labels: [],
181
+ });
182
+ case "repos/maria/project/branches/main":
183
+ return reply({});
184
+ default:
185
+ return reply([]);
186
+ }
187
+ },
188
+ }),
189
+ ),
190
+ );
191
+
192
+it.effect("offers a fast-forward merge on a repository that only allows fast-forward", () =>
193
+ Effect.gen(function* () {
194
+ const provider = yield* fastForwardOnlyProvider([]);
195
+ const detail = yield* provider.getChangeRequest(fastForwardOnly);
196
+ const allowed = provider.capabilities.mergeMethods.filter(
197
+ (method) => detail.mergeCapabilities[method],
198
+ );
199
+ assert.deepStrictEqual(allowed, ["fast-forward"]);
200
+ }),
201
+);
202
+
203
+it.effect("does not offer fast-forward when Forgejo omits the setting", () =>
204
+ Effect.gen(function* () {
205
+ const provider = yield* fastForwardOnlyProvider([], {});
206
+ const detail = yield* provider.getChangeRequest(fastForwardOnly);
207
+ const allowed = provider.capabilities.mergeMethods.filter(
208
+ (method) => detail.mergeCapabilities[method],
209
+ );
210
+ assert.deepStrictEqual(allowed, ["merge", "squash", "rebase"]);
211
+ }),
212
+);
213
+
214
+it.effect("merges with Forgejo's fast-forward-only style", () =>
215
+ Effect.gen(function* () {
216
+ const writes: Array<{ path: string; body: unknown }> = [];
217
+ const provider = yield* fastForwardOnlyProvider(writes);
218
+ yield* provider.runAction({ ...fastForwardOnly, action: "merge", mergeMethod: "fast-forward" });
219
+ assert.deepStrictEqual(writes, [
220
+ {
221
+ path: "repos/maria/project/pulls/3/merge",
222
+ body: { Do: "fast-forward-only", delete_branch_after_merge: false },
223
+ },
224
+ ]);
225
+ }),
226
+);
packages/source-control-forgejo/src/server/ForgejoPullRequestProvider.ts
+10
-2
@@ -44,7 +44,7 @@ const CAPABILITIES: PullRequestCapabilities = {
44
viewedFiles: "environment",
45
comment: true,
46
actions: [...definition.changeRequestActions],
47
- mergeMethods: ["merge", "squash", "rebase"],
47
+ mergeMethods: ["merge", "squash", "rebase", "fast-forward"],
48
updateMethods: ["merge", "rebase"],
49
search: false,
50
reactions: true,
@@ -385,6 +385,8 @@ export const make = Effect.gen(function* () {
385
merge: repo.allow_merge_commits ?? true,
386
squash: repo.allow_squash_merge ?? true,
387
rebase: repo.allow_rebase ?? true,
388
+ // Added in Forgejo 7; older servers cannot fast-forward-only merge.
389
+ "fast-forward": repo.allow_fast_forward_only_merge ?? false,
390
},
391
} satisfies ProviderChangeRequestDetail;
392
}),
@@ -542,7 +544,13 @@ export const make = Effect.gen(function* () {
544
...input,
545
path: `${pullPath(input)}/merge`,
546
method: "POST",
545
- body: { Do: input.mergeMethod ?? "merge", delete_branch_after_merge: deleteBranch },
547
+ body: {
548
+ Do:
549
+ input.mergeMethod === "fast-forward"
550
+ ? "fast-forward-only"
551
+ : (input.mergeMethod ?? "merge"),
552
+ delete_branch_after_merge: deleteBranch,
553
+ },
554
}).pipe(
555
Effect.catchTags({
556
// Forgejo merges before deleting the branch, so a refused deletion still merged.
packages/source-control-forgejo/src/server/forgejoPullRequestJson.ts
+1
@@ -32,6 +32,7 @@ export const ForgejoRepository = Schema.Struct({
32
allow_merge_commits: Schema.optional(Schema.Boolean),
33
allow_squash_merge: Schema.optional(Schema.Boolean),
34
allow_rebase: Schema.optional(Schema.Boolean),
35
+ allow_fast_forward_only_merge: Schema.optional(Schema.Boolean),
36
allow_rebase_update: Schema.optional(Schema.Boolean),
37
default_delete_branch_after_merge: Schema.optional(Schema.Boolean),
38
});
packages/source-control-github/src/server/GitHubPullRequestApi.ts
+5
-6
@@ -933,11 +933,10 @@ const decodeMergeBase = Schema.decodeUnknownOption(
933
),
934
);
935
936
-const GRAPHQL_MERGE_METHODS = {
937
- merge: "MERGE",
938
- squash: "SQUASH",
939
- rebase: "REBASE",
940
-} as const satisfies Record<PullRequestMergeMethod, string>;
936
+// GitHub has no fast-forward-only merge; the service refuses methods a host does not advertise.
937
+const GRAPHQL_MERGE_METHODS: Partial<
938
+ Record<PullRequestMergeMethod, "MERGE" | "SQUASH" | "REBASE">
939
+> = { merge: "MERGE", squash: "SQUASH", rebase: "REBASE" };
940
941
const PullRequestGraphQLGroup = GraphQLGroup.merge(
942
PullRequestBatchesGraphQLGroup,
@@ -2752,7 +2751,7 @@ export const make = Effect.gen(function* () {
2751
!IMMEDIATELY_MERGEABLE.has(state.mergeStateStatus?.toUpperCase() ?? ""));
2752
const merge = {
2753
pullRequestId: state.id,
2755
- mergeMethod: GRAPHQL_MERGE_METHODS[input.mergeMethod ?? "merge"],
2754
+ mergeMethod: GRAPHQL_MERGE_METHODS[input.mergeMethod ?? "merge"] ?? "MERGE",
2755
...(expectedHead === undefined ? {} : { expectedHeadOid: expectedHead }),
2756
...(body === undefined ? {} : { commitBody: body }),
2757
};