Skip to content

Commit

Permalink
feat: Added support to pick a previous commit message (close #358) (#599
Browse files Browse the repository at this point in the history
)
  • Loading branch information
edgardmessias authored and JohnstonCode committed Jun 3, 2019
1 parent 6defa9d commit b179bd0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,15 @@
"command": "svn.deleteUnversioned",
"title": "Delete selected files",
"category": "SVN"
},
{
"command": "svn.pickCommitMessage",
"title": "Pick a previous commit message",
"category": "SVN",
"icon": {
"light": "icons/light/icon-history.svg",
"dark": "icons/dark/icon-history.svg"
}
}
],
"menus": {
Expand Down Expand Up @@ -576,6 +585,10 @@
{
"command": "svn.itemlog.copymsg",
"when": "false"
},
{
"command": "svn.pickCommitMessage",
"when": "config.svn.enabled && svnOpenRepositoryCount != 0"
}
],
"view/title": [
Expand Down Expand Up @@ -671,6 +684,11 @@
"group": "navigation",
"when": "config.svn.enabled && scmProvider == svn"
},
{
"command": "svn.pickCommitMessage",
"group": "navigation",
"when": "config.svn.enabled && scmProvider == svn"
},
{
"command": "svn.switchBranch",
"when": "config.svn.enabled && scmProvider == svn"
Expand Down
2 changes: 2 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { OpenResourceHead } from "./commands/openResourceHead";
import { Patch } from "./commands/patch";
import { PatchAll } from "./commands/patchAll";
import { PatchChangeList } from "./commands/patchChangeList";
import { PickCommitMessage } from "./commands/pickCommitMessage";
import { PromptAuth } from "./commands/promptAuth";
import { PromptRemove } from "./commands/promptRemove";
import { PullIncommingChange } from "./commands/pullIncomingChange";
Expand Down Expand Up @@ -84,4 +85,5 @@ export function registerCommands(model: Model, disposables: Disposable[]) {
disposables.push(new OpenChangeHead());
disposables.push(new OpenHeadFile());
disposables.push(new RevertAll());
disposables.push(new PickCommitMessage());
}
38 changes: 38 additions & 0 deletions src/commands/pickCommitMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { QuickPickItem, window } from "vscode";
import { Repository } from "../repository";
import { Command } from "./command";

export class PickCommitMessage extends Command {
constructor() {
super("svn.pickCommitMessage", { repository: true });
}

public async execute(repository: Repository) {
const logs = await repository.log("HEAD", "0", 20);

if (!logs.length) {
return;
}

const picks: QuickPickItem[] = logs.map(l => {
return {
label: l.msg,
description: `r${l.revision} | ${l.author} | ${new Date(
l.date
).toLocaleString()}`
};
});

const selected = await window.showQuickPick(picks);

if (selected === undefined) {
return;
}

const msg = selected.label;

repository.inputBox.value = msg;

return msg;
}
}

0 comments on commit b179bd0

Please sign in to comment.