Skip to content

Commit 42d3c36

Browse files
authored
feat: Added config option to show previous commits by user (#1023)
1 parent 4bfc25b commit 42d3c36

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,11 @@
12741274
"type": "boolean",
12751275
"description": "Set to ignore externals definitions on update (add --ignore-externals)",
12761276
"default": true
1277+
},
1278+
"svn.previousCommitsUser": {
1279+
"type": "string",
1280+
"description": "Only show previous commits for a given user. Requires svn >= 1.8",
1281+
"default": null
12771282
}
12781283
}
12791284
}

src/commands.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function registerCommands(
9191
disposables.push(new OpenChangeHead());
9292
disposables.push(new OpenHeadFile());
9393
disposables.push(new RevertAll());
94-
disposables.push(new PickCommitMessage());
94+
disposables.push(new PickCommitMessage(sourceControlManager.svn.version));
9595
disposables.push(new RevertExplorer());
9696
disposables.push(new SearchLogByRevision());
9797
disposables.push(new SearchLogByText());

src/commands/pickCommitMessage.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import { QuickPickItem, window } from "vscode";
22
import { Repository } from "../repository";
33
import { Command } from "./command";
4+
import { configuration } from "../helpers/configuration";
5+
import * as semver from "semver";
6+
import { ISvnLogEntry } from "../common/types";
47

58
export class PickCommitMessage extends Command {
6-
constructor() {
9+
constructor(private svnVersion: string) {
710
super("svn.pickCommitMessage", { repository: true });
811
}
912

1013
public async execute(repository: Repository) {
11-
const logs = await repository.log("HEAD", "0", 20);
14+
const is18orGreater = semver.satisfies(this.svnVersion, ">= 1.8");
15+
let logs: ISvnLogEntry[] = [];
16+
const user = configuration.get("previousCommitsUser", null);
17+
if (user && is18orGreater) {
18+
logs = await repository.logByUser(user);
19+
} else {
20+
logs = await repository.log("HEAD", "0", 20);
21+
}
1222

1323
if (!logs.length) {
1424
return;

src/repository.ts

+4
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,10 @@ export class Repository implements IRemoteRepository {
876876
);
877877
}
878878

879+
public async logByUser(user: string) {
880+
return this.run(Operation.Log, () => this.repository.logByUser(user));
881+
}
882+
879883
public async cleanup() {
880884
return this.run(Operation.CleanUp, () => this.repository.cleanup());
881885
}

src/svn.ts

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export function cpErrorHandler(
5959
}
6060

6161
export class Svn {
62+
public version: string;
63+
6264
private svnPath: string;
6365
private lastCwd: string = "";
6466

@@ -69,6 +71,7 @@ export class Svn {
6971

7072
constructor(options: ISvnOptions) {
7173
this.svnPath = options.svnPath;
74+
this.version = options.version;
7275
}
7376

7477
public logOutput(output: string): void {

src/svnRepository.ts

+6
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,12 @@ export class Repository {
702702
return parseSvnLog(result.stdout);
703703
}
704704

705+
public async logByUser(user: string) {
706+
const result = await this.exec(["log", "--xml", "-v", "--search", user]);
707+
708+
return parseSvnLog(result.stdout);
709+
}
710+
705711
public async countNewCommit(revision: string = "BASE:HEAD") {
706712
const result = await this.exec(["log", "-r", revision, "-q", "--xml"]);
707713

0 commit comments

Comments
 (0)