Repository navigation
Expand file tree
/
Copy pathbugbot_autofix_commit.ts
More file actions
39 lines (36 loc) · 1.91 KB
/
Copy pathbugbot_autofix_commit.ts
File metadata and controls
39 lines (36 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { BugbotGitMutationPort } from '../../../../../application/ports/bugbot_git_ports';
import { buildBugbotCommitMessage, buildUserRequestCommitMessage } from './commit_message_policy';
import {
runCommitAndPushWorkflow,
type CommitAndPushWorkflowResult,
} from './commit_and_push_workflow';
import type { BugbotCommitContext } from './bugbot_review_operation_context';
export type BugbotAutofixCommitResult = CommitAndPushWorkflowResult;
export async function runBugbotAutofixCommitAndPush(
context: BugbotCommitContext,
options: { branchOverride?: string; branchAlreadyCheckedOut?: boolean; targetFindingIds?: string[]; workspacePaths?: string[] } | undefined,
gitCommitPort: BugbotGitMutationPort,
): Promise<BugbotAutofixCommitResult> {
const branch = options?.branchOverride ?? context.branch;
return runCommitAndPushWorkflow(context, {
branch,
branchOverride: Boolean(options?.branchOverride) && !options?.branchAlreadyCheckedOut,
workspacePaths: options?.workspacePaths,
commitMessage: buildBugbotCommitMessage(context.issueNumber, options?.targetFindingIds ?? []),
noChangesMessage: 'No changes to commit after autofix.',
}, gitCommitPort);
}
export async function runUserRequestCommitAndPush(
context: BugbotCommitContext,
options: { branchOverride?: string; branchAlreadyCheckedOut?: boolean; workspacePaths?: string[] } | undefined,
gitCommitPort: BugbotGitMutationPort,
): Promise<BugbotAutofixCommitResult> {
const branch = options?.branchOverride ?? context.branch;
return runCommitAndPushWorkflow(context, {
branch,
branchOverride: Boolean(options?.branchOverride) && !options?.branchAlreadyCheckedOut,
workspacePaths: options?.workspacePaths,
commitMessage: buildUserRequestCommitMessage(context.issueNumber),
noChangesMessage: 'No changes to commit after user request.',
}, gitCommitPort);
}