Skip to content

Commit b179bd0

Browse files
edgardmessiasJohnstonCode
authored andcommitted
feat: Added support to pick a previous commit message (close #358) (#599)
1 parent 6defa9d commit b179bd0

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

package.json

+18
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,15 @@
417417
"command": "svn.deleteUnversioned",
418418
"title": "Delete selected files",
419419
"category": "SVN"
420+
},
421+
{
422+
"command": "svn.pickCommitMessage",
423+
"title": "Pick a previous commit message",
424+
"category": "SVN",
425+
"icon": {
426+
"light": "icons/light/icon-history.svg",
427+
"dark": "icons/dark/icon-history.svg"
428+
}
420429
}
421430
],
422431
"menus": {
@@ -576,6 +585,10 @@
576585
{
577586
"command": "svn.itemlog.copymsg",
578587
"when": "false"
588+
},
589+
{
590+
"command": "svn.pickCommitMessage",
591+
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
579592
}
580593
],
581594
"view/title": [
@@ -671,6 +684,11 @@
671684
"group": "navigation",
672685
"when": "config.svn.enabled && scmProvider == svn"
673686
},
687+
{
688+
"command": "svn.pickCommitMessage",
689+
"group": "navigation",
690+
"when": "config.svn.enabled && scmProvider == svn"
691+
},
674692
{
675693
"command": "svn.switchBranch",
676694
"when": "config.svn.enabled && scmProvider == svn"

src/commands.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { OpenResourceHead } from "./commands/openResourceHead";
2323
import { Patch } from "./commands/patch";
2424
import { PatchAll } from "./commands/patchAll";
2525
import { PatchChangeList } from "./commands/patchChangeList";
26+
import { PickCommitMessage } from "./commands/pickCommitMessage";
2627
import { PromptAuth } from "./commands/promptAuth";
2728
import { PromptRemove } from "./commands/promptRemove";
2829
import { PullIncommingChange } from "./commands/pullIncomingChange";
@@ -84,4 +85,5 @@ export function registerCommands(model: Model, disposables: Disposable[]) {
8485
disposables.push(new OpenChangeHead());
8586
disposables.push(new OpenHeadFile());
8687
disposables.push(new RevertAll());
88+
disposables.push(new PickCommitMessage());
8789
}

src/commands/pickCommitMessage.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { QuickPickItem, window } from "vscode";
2+
import { Repository } from "../repository";
3+
import { Command } from "./command";
4+
5+
export class PickCommitMessage extends Command {
6+
constructor() {
7+
super("svn.pickCommitMessage", { repository: true });
8+
}
9+
10+
public async execute(repository: Repository) {
11+
const logs = await repository.log("HEAD", "0", 20);
12+
13+
if (!logs.length) {
14+
return;
15+
}
16+
17+
const picks: QuickPickItem[] = logs.map(l => {
18+
return {
19+
label: l.msg,
20+
description: `r${l.revision} | ${l.author} | ${new Date(
21+
l.date
22+
).toLocaleString()}`
23+
};
24+
});
25+
26+
const selected = await window.showQuickPick(picks);
27+
28+
if (selected === undefined) {
29+
return;
30+
}
31+
32+
const msg = selected.label;
33+
34+
repository.inputBox.value = msg;
35+
36+
return msg;
37+
}
38+
}

0 commit comments

Comments
 (0)