Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ This is due to limit the number of tokens sent in each request. However, if you
oco --fgm
```

#### Skip Commit Confirmation

This flag allows users to automatically commit the changes without having to manually confirm the commit message. This is useful for users who want to streamline the commit process and avoid additional steps. To use this flag, you can run the following command:

```
oco --yes
```

## Configuration

### Local per repo configuration
Expand Down
10 changes: 8 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ cli(
name: 'opencommit',
commands: [configCommand, hookCommand, commitlintConfigCommand],
flags: {
fgm: Boolean
fgm: Boolean,
yes: {
type: Boolean,
alias: 'y',
description: 'Skip commit confirmation prompt',
default: false
}
},
ignoreArgv: (type) => type === 'unknown-flag' || type === 'argument',
help: { description: packageJSON.description }
Expand All @@ -29,7 +35,7 @@ cli(
if (await isHookCalled()) {
prepareCommitMessageHook();
} else {
commit(extraArgs, false, flags.fgm);
commit(extraArgs, false, flags.fgm, flags.yes);
}
},
extraArgs
Expand Down
11 changes: 7 additions & 4 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const checkMessageTemplate = (extraArgs: string[]): string | false => {
const generateCommitMessageFromGitDiff = async (
diff: string,
extraArgs: string[],
fullGitMojiSpec: boolean
fullGitMojiSpec: boolean,
skipCommitConfirmation: boolean
): Promise<void> => {
await assertGitRepo();
const commitSpinner = spinner();
Expand Down Expand Up @@ -76,7 +77,7 @@ ${commitMessage}
${chalk.grey('——————————————————')}`
);

const isCommitConfirmedByUser = await confirm({
const isCommitConfirmedByUser = skipCommitConfirmation || await confirm({
message: 'Confirm the commit message?'
});

Expand Down Expand Up @@ -178,7 +179,8 @@ ${chalk.grey('——————————————————')}`
export async function commit(
extraArgs: string[] = [],
isStageAllFlag: Boolean = false,
fullGitMojiSpec: boolean = false
fullGitMojiSpec: boolean = false,
skipCommitConfirmation: boolean = false
) {
if (isStageAllFlag) {
const changedFiles = await getChangedFiles();
Expand Down Expand Up @@ -250,7 +252,8 @@ export async function commit(
generateCommitMessageFromGitDiff(
await getDiff({ files: stagedFiles }),
extraArgs,
fullGitMojiSpec
fullGitMojiSpec,
skipCommitConfirmation
)
);

Expand Down