Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 610a3fc

Browse files
axelproxnitayneeman
authored andcommitted
feat: add scope template placeholder (#6)
1 parent 8644829 commit 610a3fc

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

‎package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
"default": "--quiet",
5151
"markdownDescription": "Specifies which [arguments](https://git-scm.com/docs/git-commit#_options) to be passed when the commit is executed."
5252
},
53+
"gitSemanticCommit.scopeTemplate": {
54+
"type": "string",
55+
"default": "($scope)",
56+
"markdownDescription": "Specifies scope template (`$scope` placeholder will be replaced with passed scope)"
57+
},
5358
"gitSemanticCommit.preserveScope": {
5459
"type": "boolean",
5560
"default": false,

‎src/commands/semantic-commit.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { window, workspace, ExtensionContext, QuickPickItem } from 'vscode';
22

33
import { getConfiguration, ConfigurationProperties } from '../config';
44
import { Git } from '../git';
5-
import { workspaceStorageKey } from '../constants';
5+
import { workspaceStorageKey,scopeTemplatePlaceholder } from '../constants';
66
import { Command } from './common';
77

88
const enum ActionType {
@@ -75,6 +75,11 @@ export class SemanticCommitCommand extends Command {
7575
return getConfiguration()[ConfigurationProperties.stageAll];
7676
}
7777

78+
private get scopeTemplate() {
79+
const template = getConfiguration()[ConfigurationProperties.scopeTemplate];
80+
return template.length ? template : scopeTemplatePlaceholder;
81+
}
82+
7883
private hasScope() {
7984
return this.scope.length > 0;
8085
}
@@ -129,7 +134,7 @@ export class SemanticCommitCommand extends Command {
129134

130135
private async performCommit(type: string, subject: string) {
131136
if (subject.length > 0) {
132-
const message = `${type}${this.hasScope() ? `(${this.scope})` : ''}: ${subject}`;
137+
const message = `${type}${this.hasScope() ? this.scopeTemplate.replace(scopeTemplatePlaceholder,this.scope) : ''}: ${subject}`;
133138

134139
if (this.isStageAllEnabled()) {
135140
try {

‎src/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ enum ConfigurationProperties {
88
commitOptions = 'commitOptions',
99
preserveScope = 'preserveScope',
1010
stageAll = 'stageAll',
11+
scopeTemplate = 'scopeTemplate',
1112
types = 'types'
1213
}
1314

‎src/constants.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ const extensionIdentifier = 'gitSemanticCommit';
22

33
const workspaceStorageKey = 'gitSemanticCommit';
44

5-
export { extensionIdentifier, workspaceStorageKey };
5+
const scopeTemplatePlaceholder = '$scope';
6+
7+
export { extensionIdentifier, workspaceStorageKey, scopeTemplatePlaceholder };

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /