feat(git): support custom commit flags for app-run commits

This commit is contained in:
Niklas Wojtkowiak committed 2026-03-13 12:21:13 -04:00
1 parent 89ffcf42eb
commit 5a57ada95b
10 files changed
+75 -5

No files matched your search

+1 -1
View File
@@ -98,7 +98,7 @@ const makeIsolatedGitCore = (gitService: GitServiceShape) =>
status: (input) => core.status(input),
statusDetails: (cwd) => core.statusDetails(cwd),
prepareCommitContext: (cwd, filePaths?) => core.prepareCommitContext(cwd, filePaths),
commit: (cwd, subject, body) => core.commit(cwd, subject, body),
commit: (cwd, subject, body, extraArgs?) => core.commit(cwd, subject, body, extraArgs),
pushCurrentBranch: (cwd, fallbackBranch) => core.pushCurrentBranch(cwd, fallbackBranch),
pullCurrentBranch: (cwd) => core.pullCurrentBranch(cwd),
readRangeContext: (cwd, baseBranch) => core.readRangeContext(cwd, baseBranch),
+2 -2
View File
@@ -804,9 +804,9 @@ const makeGitCore = Effect.gen(function* () {
};
});
const commit: GitCoreShape["commit"] = (cwd, subject, body) =>
const commit: GitCoreShape["commit"] = (cwd, subject, body, extraArgs = []) =>
Effect.gen(function* () {
const args = ["commit", "-m", subject];
const args = ["commit", ...extraArgs, "-m", subject];
const trimmedBody = body.trim();
if (trimmedBody.length > 0) {
args.push("-m", trimmedBody);
+15 -1
View File
@@ -207,6 +207,13 @@ interface CommitAndBranchSuggestion {
commitMessage: string;
}
function tokenizeCommitFlags(rawFlags?: string): string[] {
return (rawFlags ?? "")
.trim()
.split(/\s+/g)
.filter((value) => value.length > 0);
}
function formatCommitMessage(subject: string, body: string): string {
const trimmedBody = body.trim();
if (trimmedBody.length === 0) {
@@ -680,6 +687,7 @@ export const makeGitManager = Effect.gen(function* () {
cwd: string,
branch: string | null,
commitMessage?: string,
commitFlags?: string,
preResolvedSuggestion?: CommitAndBranchSuggestion,
filePaths?: readonly string[],
) =>
@@ -696,7 +704,12 @@ export const makeGitManager = Effect.gen(function* () {
return { status: "skipped_no_changes" as const };
}
const { commitSha } = yield* gitCore.commit(cwd, suggestion.subject, suggestion.body);
const { commitSha } = yield* gitCore.commit(
cwd,
suggestion.subject,
suggestion.body,
tokenizeCommitFlags(commitFlags),
);
return {
status: "created" as const,
commitSha,
@@ -1042,6 +1055,7 @@ export const makeGitManager = Effect.gen(function* () {
input.cwd,
currentBranch,
commitMessageForStep,
input.commitFlags,
preResolvedCommitSuggestion,
input.filePaths,
);
+1
View File
@@ -111,6 +111,7 @@ export interface GitCoreShape {
cwd: string,
subject: string,
body: string,
extraArgs?: readonly string[],
) => Effect.Effect<{ commitSha: string }, GitCommandError>;
/**
+1 -1
View File
@@ -7,7 +7,7 @@
* - Please do NOT modify this file.
*/
const PACKAGE_VERSION = '2.12.9'
const PACKAGE_VERSION = '2.12.10'
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
+3
View File
@@ -21,6 +21,9 @@ const AppSettingsSchema = Schema.Struct({
codexHomePath: Schema.String.check(Schema.isMaxLength(4096)).pipe(
Schema.withConstructorDefault(() => Option.some("")),
),
gitCommitFlags: Schema.String.check(Schema.isMaxLength(4096)).pipe(
Schema.withConstructorDefault(() => Option.some("")),
),
defaultThreadEnvMode: Schema.Literals(["local", "worktree"]).pipe(
Schema.withConstructorDefault(() => Option.some("local")),
),
@@ -32,6 +32,7 @@ import { Popover, PopoverPopup, PopoverTrigger } from "~/components/ui/popover";
import { ScrollArea } from "~/components/ui/scroll-area";
import { Textarea } from "~/components/ui/textarea";
import { toastManager } from "~/components/ui/toast";
import { useAppSettings } from "~/appSettings";
import { openInPreferredEditor } from "~/editorPreferences";
import {
gitBranchesQueryOptions,
@@ -158,6 +159,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
() => (activeThreadId ? { threadId: activeThreadId } : undefined),
[activeThreadId],
);
const { settings } = useAppSettings();
const queryClient = useQueryClient();
const [isCommitDialogOpen, setIsCommitDialogOpen] = useState(false);
const [dialogCommitMessage, setDialogCommitMessage] = useState("");
@@ -199,6 +201,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
useIsMutating({ mutationKey: gitMutationKeys.runStackedAction(gitCwd) }) > 0;
const isPullRunning = useIsMutating({ mutationKey: gitMutationKeys.pull(gitCwd) }) > 0;
const isGitActionRunning = isRunStackedActionRunning || isPullRunning;
const configuredCommitFlags = settings.gitCommitFlags.trim();
const isDefaultBranch = useMemo(() => {
const branchName = gitStatusForActions?.branch;
if (!branchName) return false;
@@ -349,6 +352,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
const promise = runImmediateGitActionMutation.mutateAsync({
action,
...(commitMessage ? { commitMessage } : {}),
...(configuredCommitFlags ? { commitFlags: configuredCommitFlags } : {}),
...(featureBranch ? { featureBranch } : {}),
...(filePaths ? { filePaths } : {}),
});
@@ -442,6 +446,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
},
[
configuredCommitFlags,
isDefaultBranch,
runImmediateGitActionMutation,
setPendingDefaultBranchAction,
+3
View File
@@ -118,11 +118,13 @@ export function gitRunStackedActionMutationOptions(input: {
mutationFn: async ({
action,
commitMessage,
commitFlags,
featureBranch,
filePaths,
}: {
action: GitStackedAction;
commitMessage?: string;
commitFlags?: string;
featureBranch?: boolean;
filePaths?: string[];
}) => {
@@ -132,6 +134,7 @@ export function gitRunStackedActionMutationOptions(input: {
cwd: input.cwd,
action,
...(commitMessage ? { commitMessage } : {}),
...(commitFlags ? { commitFlags } : {}),
...(featureBranch ? { featureBranch } : {}),
...(filePaths ? { filePaths } : {}),
});
+43
View File
@@ -109,6 +109,7 @@ function SettingsRouteView() {
const codexBinaryPath = settings.codexBinaryPath;
const codexHomePath = settings.codexHomePath;
const gitCommitFlags = settings.gitCommitFlags;
const keybindingsConfigPath = serverConfigQuery.data?.keybindingsConfigPath ?? null;
const availableEditors = serverConfigQuery.data?.availableEditors;
@@ -545,6 +546,48 @@ function SettingsRouteView() {
) : null}
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Git</h2>
<p className="mt-1 text-xs text-muted-foreground">
Configure extra flags for app-run <code>git commit</code> commands.
</p>
</div>
<div className="space-y-4">
<label htmlFor="git-commit-flags" className="block space-y-1">
<span className="text-xs font-medium text-foreground">
Extra git commit flags
</span>
<Input
id="git-commit-flags"
value={gitCommitFlags}
onChange={(event) => updateSettings({ gitCommitFlags: event.target.value })}
placeholder="--no-gpg-sign"
spellCheck={false}
/>
<span className="text-xs text-muted-foreground">
Applied to app-run git commit commands only. Example: <code>--no-gpg-sign</code>
. Quoted arguments are not supported yet.
</span>
</label>
<div className="flex justify-end">
<Button
size="xs"
variant="outline"
onClick={() =>
updateSettings({
gitCommitFlags: defaults.gitCommitFlags,
})
}
>
Restore default
</Button>
</div>
</div>
</section>
<section className="rounded-2xl border border-border bg-card p-5">
<div className="mb-4">
<h2 className="text-sm font-medium text-foreground">Responses</h2>
+1
View File
@@ -60,6 +60,7 @@ export const GitRunStackedActionInput = Schema.Struct({
cwd: TrimmedNonEmptyStringSchema,
action: GitStackedAction,
commitMessage: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(10_000))),
commitFlags: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4_096))),
featureBranch: Schema.optional(Schema.Boolean),
filePaths: Schema.optional(
Schema.Array(TrimmedNonEmptyStringSchema).check(Schema.isMinLength(1)),