Skip to content

Commit b8fa561

Browse files
committed
fixes #100
1 parent f0a3058 commit b8fa561

File tree

5 files changed

+74
-1
lines changed

5 files changed

+74
-1
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898
"command": "svn.patch",
9999
"title": "Svn patch",
100100
"category": "SVN"
101+
},
102+
{
103+
"command": "svn.remove",
104+
"title": "Remove Selected",
105+
"category": "SVN"
101106
}
102107
],
103108
"menus": {
@@ -142,6 +147,11 @@
142147
"command": "svn.revert",
143148
"when": "scmProvider == svn && scmResourceGroup == changes",
144149
"group": "1_modification"
150+
},
151+
{
152+
"command": "svn.remove",
153+
"when": "scmProvider == svn && scmResourceGroup == changes",
154+
"group": "2_modification"
145155
}
146156
],
147157
"editor/title": []

src/commands.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,41 @@ export class SvnCommands {
365365
}
366366
}
367367

368+
@command("svn.remove", { repository: true })
369+
async remove(
370+
repository: Repository,
371+
...resourceStates: Resource[]
372+
): Promise<void> {
373+
let keepLocal;
374+
const answer = await window.showWarningMessage(
375+
"Would you like to keep a local copy of the files?.",
376+
"Yes",
377+
"No"
378+
);
379+
380+
if (!answer) {
381+
return;
382+
}
383+
384+
if (answer === "Yes") {
385+
keepLocal = true;
386+
} else {
387+
keepLocal = false;
388+
}
389+
390+
try {
391+
const paths = resourceStates.map(state => {
392+
return state.resourceUri.fsPath;
393+
});
394+
395+
const result = await repository.repository.removeFiles(paths, keepLocal);
396+
repository.update();
397+
} catch (error) {
398+
console.error(error);
399+
window.showErrorMessage("Unable to remove files");
400+
}
401+
}
402+
368403
private runByRepository<T>(
369404
resource: Uri,
370405
fn: (repository: Repository, resource: Uri) => Promise<T>

src/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class Repository {
167167
const fileConfig = workspace.getConfiguration("files");
168168
const svnConfig = workspace.getConfiguration("svn");
169169

170-
const filesToExclude = fileConfig.get<any>("exclude", {});
170+
const filesToExclude = fileConfig.get<any>("exclude", null);
171171

172172
let excludeList: string[] = [];
173173
for (const pattern in filesToExclude) {

src/svn.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,22 @@ export class Svn {
271271
patch(root: string) {
272272
return this.exec(root, ["diff"]);
273273
}
274+
275+
remove(files: any[], keepLocal: boolean) {
276+
let args = ["remove"];
277+
278+
if (keepLocal) {
279+
args.push("--keep-local");
280+
}
281+
282+
for (let file of files) {
283+
if (file instanceof Uri) {
284+
args.push(file.fsPath);
285+
} else {
286+
args.push(file);
287+
}
288+
}
289+
290+
return this.exec("", args);
291+
}
274292
}

src/svnRepository.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,14 @@ export class Repository {
264264
const message = result.stdout;
265265
return message;
266266
}
267+
268+
async removeFiles(files: any[], keepLocal: boolean) {
269+
const result = await this.svn.remove(files, keepLocal);
270+
271+
if (result.exitCode !== 0) {
272+
throw new Error(result.stderr);
273+
}
274+
275+
return result.stdout;
276+
}
267277
}

0 commit comments

Comments
 (0)