Skip to content

Commit

Permalink
fixes #84
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnstonCode committed Jan 31, 2018
1 parent fc88008 commit 72e201c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# **v1.11.0**

## What's New

* @JohnstonCode Added commit message list

# **v1.10.0**

## What's New
Expand Down
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "svn-scm",
"displayName": "SVN",
"description": "Integrated Subversion source control",
"version": "1.10.0",
"version": "1.11.0",
"publisher": "johnstoncode",
"engines": {
"vscode": "^1.17.0"
Expand Down Expand Up @@ -126,6 +126,11 @@
"command": "svn.resolve",
"title": "Resolve Conflicts",
"category": "SVN"
},
{
"command": "svn.log",
"title": "Show commit messages",
"category": "SVN"
}
],
"menus": {
Expand All @@ -151,6 +156,10 @@
{
"command": "svn.resolve",
"when": "config.svn.enabled"
},
{
"command": "svn.log",
"when": "config.svn.enabled"
}
],
"scm/resourceGroup/context": [],
Expand Down Expand Up @@ -282,6 +291,12 @@
"description":
"Allow to show in source control the list the external folders",
"default": false
},
"svn.log.length": {
"type": "number",
"minimum": 1,
"description": "Number of commit messages to log",
"default": 50
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,20 @@ export class SvnCommands {
}
}

@command("svn.log", { repository: true })
async log(repository: Repository) {
try {
const result = await repository.repository.log();
// send the log results to a new tab
workspace.openTextDocument({ content: result }).then(doc => {
window.showTextDocument(doc);
});
} catch (error) {
console.error(error);
window.showErrorMessage("Unable to log");
}
}

private runByRepository<T>(
resource: Uri,
fn: (repository: Repository, resource: Uri) => Promise<T>
Expand Down
10 changes: 7 additions & 3 deletions src/svn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class Svn {
this.version = options.version;
}

private log(output: string): void {
private logOutput(output: string): void {
this._onOutput.emit("log", output);
}

Expand All @@ -144,7 +144,7 @@ export class Svn {
}

if (options.log !== false) {
this.log(
this.logOutput(
`[${this.lastCwd.split(/[\\\/]+/).pop()}]$ svn ${args.join(" ")}\n`
);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ export class Svn {
stdout = iconv.decode(stdout, encoding);

if (options.log !== false && stderr.length > 0) {
this.log(`${stderr}\n`);
this.logOutput(`${stderr}\n`);
}

return { exitCode, stdout, stderr };
Expand Down Expand Up @@ -310,4 +310,8 @@ export class Svn {
resolve(file: string, action: string) {
return this.exec("", ["resolve", "--accept", action, file]);
}

log(rootPath: string, length: string) {
return this.exec(rootPath, ["log", "--limit", length]);
}
}
12 changes: 12 additions & 0 deletions src/svnRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,16 @@ export class Repository {

return result.stdout;
}

async log() {
const config = workspace.getConfiguration("svn");
const logLength = config.get<string>("log.length") || "50";
const result = await this.svn.log(this.workspaceRoot, logLength);

if (result.exitCode !== 0) {
throw new Error(result.stderr);
}

return result.stdout;
}
}

0 comments on commit 72e201c

Please sign in to comment.