-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathsearch_log_by_text.ts
60 lines (50 loc) · 1.47 KB
/
search_log_by_text.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { Command } from "./command";
import { window, Uri, commands, ProgressLocation } from "vscode";
import { Repository } from "../repository";
import * as cp from "child_process";
import { tempSvnFs } from "../temp_svn_fs";
export class SearchLogByText extends Command {
constructor() {
super("svn.searchLogByText", { repository: true });
}
public async execute(repository: Repository) {
const input = await window.showInputBox({ prompt: "Search query" });
if (!input) {
return;
}
const uri = Uri.parse("svnfs:/svn.log");
tempSvnFs.writeFile(uri, Buffer.from(""), {
create: true,
overwrite: true
});
await commands.executeCommand<void>("vscode.open", uri);
const proc = cp.spawn("svn", ["log", "--search", input], {
cwd: repository.workspaceRoot
});
let content = "";
proc.stdout.on("data", data => {
content += data.toString();
tempSvnFs.writeFile(uri, Buffer.from(content), {
create: true,
overwrite: true
});
});
window.withProgress(
{
cancellable: true,
location: ProgressLocation.Notification,
title: "Searching Log"
},
(_progress, token) => {
token.onCancellationRequested(() => {
proc.kill("SIGINT");
});
return new Promise((resolve, reject) => {
proc.on("exit", (code: number) => {
code === 0 ? resolve() : reject();
});
});
}
);
}
}