@devries-cameron20 / t3code Mirror · read-only / commits / 068332c603
Fork 0

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 21, 04:45 UTC

fix(gitlab): pull_request_create opens a draft MR as a draft (#39817)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Arav Jain committed Nov 20, 2026 at 12:15 UTC 068332c603ce5ca40ad5a96a09cffa34ebd05dff
3 files changed +28 -2
packages/source-control-gitlab/src/server/GitLabCli.test.ts
+19 -1
@@ -261,7 +261,7 @@ layer("GitLabCli.layer", (it) => {
261 }),
262 );
263
264 - it.effect("creates same-project MRs without a repository lookup", () =>
264 + it.effect("creates same-project MRs without a repository lookup, drafts by title prefix", () =>
265 Effect.gen(function* () {
266 const fileSystem = yield* FileSystem.FileSystem;
267 const bodyFile = yield* fileSystem.makeTempFileScoped({ prefix: "t3-gitlab-mr-body-" });
@@ -292,6 +292,24 @@ layer("GitLabCli.layer", (it) => {
292 ],
293 }),
294 );
295 +
296 + const draftTitle = (title: string) =>
297 + Effect.gen(function* () {
298 + mockedRun.mockClear();
299 + mockedRun.mockReturnValueOnce(Effect.succeed(processOutput("{}")));
300 + yield* glab.createMergeRequest({
301 + cwd: "/repo",
302 + baseBranch: "main",
303 + headSelector: "feature/fix",
304 + title,
305 + bodyFile,
306 + draft: true,
307 + });
308 + return mockedRun.mock.calls[0]?.[0].args.find((arg) => arg.startsWith("title="));
309 + });
310 + expect(yield* draftTitle("Fix remote flow")).toBe("title=Draft: Fix remote flow");
311 + expect(yield* draftTitle("draft: Fix remote flow")).toBe("title=draft: Fix remote flow");
312 + expect(yield* draftTitle("[Draft] Fix remote flow")).toBe("title=[Draft] Fix remote flow");
313 }).pipe(Effect.scoped),
314 );
315
packages/source-control-gitlab/src/server/GitLabCli.ts
+7 -1
@@ -342,6 +342,7 @@ export class GitLabCli extends Context.Service<
342 readonly target?: SourceControlProvider.SourceControlRefSelector;
343 readonly title: string;
344 readonly bodyFile: string;
345 + readonly draft?: boolean;
346 }) => Effect.Effect<void, GitLabCliError>;
347
348 readonly getDefaultBranch: (input: {
@@ -356,6 +357,11 @@ export class GitLabCli extends Context.Service<
357 }
358 >()("@t3tools/source-control-gitlab/server/GitLabCli") {}
359
360 +// The create-MR endpoint has no draft attribute; GitLab reads the draft marker from the title.
361 +// Same markers and case rule as glab's `EnsureTitlePrefix`.
362 +const draftTitle = (title: string) =>
363 + /^\s*(?:\[draft\]|\(draft\)|draft:)/i.test(title) ? title : `Draft: ${title}`;
364 +
365 const RawGitLabRepositoryCloneUrlsSchema = Schema.Struct({
366 path_with_namespace: TrimmedNonEmptyString,
367 web_url: TrimmedNonEmptyString,
@@ -777,7 +783,7 @@ export const make = Effect.gen(function* () {
783 ? []
784 : ["--raw-field", `target_project_id=${targetProjectId}`]),
785 "--raw-field",
780 - `title=${input.title}`,
786 + `title=${input.draft === true ? draftTitle(input.title) : input.title}`,
787 "--field",
788 "description=@-",
789 ],
packages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts
+2
@@ -283,6 +283,7 @@ export const make = Effect.gen(function* () {
283 ),
284 );
285 }),
286 + createsDraftChangeRequests: true,
287 createChangeRequest: Effect.fn("GitLabSourceControlProvider.createChangeRequest")(
288 function (input) {
289 const source = SourceControlProvider.sourceControlRefFromInput(input);
@@ -295,6 +296,7 @@ export const make = Effect.gen(function* () {
296 ...(input.target ? { target: input.target } : {}),
297 title: input.title,
298 bodyFile: input.bodyFile,
299 + ...(input.draft === true ? { draft: true } : {}),
300 })
301 .pipe(
302 Effect.mapError(