Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨feat: Support auto commit setting #5

Merged
merged 1 commit into from
May 1, 2020
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
5 changes: 5 additions & 0 deletions packages/vscode-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@
}
}
},
"commitji.autoCommit": {
"type": "boolean",
"default": false,
"description": "Automatically commit instead of manually commiting"
},
"commitji.jira.allowWorkflowTransitionPrompt": {
"type": "boolean",
"default": false,
Expand Down
6 changes: 6 additions & 0 deletions packages/vscode-ext/src/commitjiCommit/types/Settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Settings as CommitjiSettings } from '@commitji/core';

export type Settings = CommitjiSettings & {
// Auto commit is currently available on VSCode extension
autoCommit: boolean;
};
1 change: 1 addition & 0 deletions packages/vscode-ext/src/commitjiCommit/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Settings';
4 changes: 3 additions & 1 deletion packages/vscode-ext/src/commitjiCommit/utils/getSettings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { workspace } from 'vscode';

import { App, Settings } from '@commitji/core';
import { App } from '@commitji/core';

import { Settings } from '../types';

const clean = (settings: Settings): Settings => ({
...settings,
Expand Down
3 changes: 2 additions & 1 deletion packages/vscode-ext/src/commitjiCommit/utils/getWorkflow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { App, Settings } from '@commitji/core';
import { App } from '@commitji/core';

import { basicWorkflow, jiraWorkflow } from '../workflows';
import { Settings } from '../types';

type Workflow = {
key: App.BasicWorkflow | App.JiraWorkflow;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { QuickPickItem, window } from 'vscode';

import { commitTypes, CommitType, Message, Settings } from '@commitji/core';
import { commitTypes, CommitType, Message } from '@commitji/core';
import { Settings } from '../types';

type ShowCommitTypePickerResult = CommitType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { Message } from '@commitji/core';
import { alerter } from './alerter';
import { clipboard } from './clipboard';

export const writeCommitToTerminal = (commitText: string) => {
export const writeCommitToTerminal = (commitText: string, autoCommitToTerminal = false) => {
const commitMessage = `git commit -m "${commitText}"`;
const terminal = window.activeTerminal;
const autoCommitToTerminal = false;

clipboard.copy(commitMessage);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { formatter, basicCommitParser, Settings } from '@commitji/core';
import { formatter, basicCommitParser } from '@commitji/core';

import { showCommitTypePicker, showCommitBodyInputBox, writeCommitToTerminal } from '../utils';
import { Settings } from '../types';

export const basicWorkflow = async (settings: Settings) => {
const commitType = await showCommitTypePicker(settings);
Expand All @@ -15,5 +16,5 @@ export const basicWorkflow = async (settings: Settings) => {
commitMessage,
});

writeCommitToTerminal(formattedCommitText);
writeCommitToTerminal(formattedCommitText, settings.autoCommit);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatter, jiraCommitParser, Settings } from '@commitji/core';
import { formatter, jiraCommitParser } from '@commitji/core';

import {
showCommitTypePicker,
Expand All @@ -7,6 +7,7 @@ import {
showJiraWorkflowTransitionPicker,
writeCommitToTerminal,
} from '../utils';
import { Settings } from '../types';

export const jiraWorkflow = async (settings: Settings) => {
const commitType = await showCommitTypePicker(settings);
Expand All @@ -28,5 +29,5 @@ export const jiraWorkflow = async (settings: Settings) => {
workflowTransition,
});

writeCommitToTerminal(formattedCommitText);
writeCommitToTerminal(formattedCommitText, settings.autoCommit);
};