Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 5b826a4

Browse files
committed
feat: add configuration for prefered merge method
1 parent 589ba74 commit 5b826a4

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,31 @@
1010
"version": "0.5.0",
1111
"publisher": "KnisterPeter",
1212
"engines": {
13-
"vscode": "^1.5.0"
13+
"vscode": "^1.7.0"
1414
},
1515
"categories": [
1616
"Other"
1717
],
18+
"keywords": [
19+
"git",
20+
"github",
21+
"pull-request",
22+
"pull request"
23+
],
1824
"activationEvents": [
1925
"*"
2026
],
2127
"main": "./out/src/extension",
2228
"contributes": {
29+
"configuration": {
30+
"title": "GitHub configuration",
31+
"properties": {
32+
"github.preferedMergeMethod": {
33+
"type": "string",
34+
"description": "By default the extension asks the user during merge process. This could be set to on of 'merge', 'squash' or 'rebase' to define the prefered method and not to be asked every time."
35+
}
36+
}
37+
},
2338
"commands": [
2439
{
2540
"command": "extension.setGitHubToken",

src/extension.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,29 +131,36 @@ class Extension {
131131
});
132132
}
133133

134+
private async getMergeMethdod(): Promise<MergeMethod> {
135+
if (vscode.workspace.getConfiguration('github').has('preferedMergeMethod')) {
136+
return vscode.workspace.getConfiguration('github').get<MergeMethod>('preferedMergeMethod');
137+
}
138+
const items: MergeOptionItems[] = [
139+
{
140+
label: 'Create merge commit',
141+
description: '',
142+
method: 'merge'
143+
},
144+
{
145+
label: 'Squash and merge',
146+
description: '',
147+
method: 'squash'
148+
},
149+
{
150+
label: 'Rebase and merge',
151+
description: '',
152+
method: 'rebase'
153+
}
154+
];
155+
return (await vscode.window.showQuickPick(items)).method;
156+
}
157+
134158
private async mergePullRequest(): Promise<void> {
135159
const pullRequest = await this.githubManager.getPullRequestForCurrentBranch();
136160
if (pullRequest && pullRequest.mergeable) {
137-
const items: MergeOptionItems[] = [
138-
{
139-
label: 'Create merge commit',
140-
description: '',
141-
method: 'merge'
142-
},
143-
{
144-
label: 'Squash and merge',
145-
description: '',
146-
method: 'squash'
147-
},
148-
{
149-
label: 'Rebase and merge',
150-
description: '',
151-
method: 'rebase'
152-
}
153-
];
154-
const selected = await vscode.window.showQuickPick(items);
155-
if (selected) {
156-
if (await this.githubManager.mergePullRequest(pullRequest, selected.method)) {
161+
const method = await this.getMergeMethdod();
162+
if (method) {
163+
if (await this.githubManager.mergePullRequest(pullRequest, method)) {
157164
this.statusBarManager.updatePullRequestStatus();
158165
vscode.window.showInformationMessage(`Successfully merged`);
159166
} else {

0 commit comments

Comments
 (0)