Skip to content

Commit 7d9a491

Browse files
committed
started work on propset
1 parent 8810e66 commit 7d9a491

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
"command": "svn.patch",
9595
"title": "Svn patch",
9696
"category": "SVN"
97+
},
98+
{
99+
"command": "svn.propset:ignore",
100+
"title": "Svn propset:ignore",
101+
"category": "SVN"
97102
}
98103
],
99104
"menus": {

src/commands.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ interface Command {
2828

2929
const Commands: Command[] = [];
3030

31+
const IgnoreOptions: any[] = [
32+
{
33+
name: 'ignore',
34+
type: 'recursive',
35+
flag: '-R'
36+
},
37+
{
38+
name: 'ignore',
39+
type: 'non-recursive',
40+
flag: ''
41+
}
42+
]
43+
3144
function command(commandId: string, options: CommandOptions = {}): Function {
3245
return (target: any, key: string, descriptor: any) => {
3346
if (!(typeof descriptor.value === "function")) {
@@ -38,6 +51,16 @@ function command(commandId: string, options: CommandOptions = {}): Function {
3851
};
3952
}
4053

54+
async function askForFilesAndDirectories() {
55+
return await window
56+
.showInputBox({
57+
value: "",
58+
placeHolder: "Files",
59+
prompt: "Enter a space separated list of the files/directories",
60+
ignoreFocusOut: true
61+
});
62+
}
63+
4164
class CreateBranchItem implements QuickPickItem {
4265
constructor(private commands: SvnCommands) {}
4366

@@ -82,6 +105,55 @@ class SwitchBranchItem implements QuickPickItem {
82105
}
83106
}
84107

108+
// class PropSetItem implements QuickPickItem {
109+
// constructor(private name: string, private flag: string){}
110+
111+
// get label(): string {
112+
// return this.name;
113+
// }
114+
115+
// get description(): string {
116+
// return '';
117+
// }
118+
119+
// async run(repository: Repository): Promise<void> {
120+
// const files = await window
121+
// .showInputBox({
122+
// value: "",
123+
// placeHolder: "Files",
124+
// prompt: "Enter a space separated list of the files/directories",
125+
// ignoreFocusOut: true
126+
// });
127+
128+
// if (!files) {
129+
// return;
130+
// }
131+
132+
// await repository.propset(this.name, files);
133+
// }
134+
// }
135+
class IgnorePropItem implements QuickPickItem {
136+
constructor(private name: string, private type:string, private flag: string){}
137+
138+
get label(): string {
139+
return this.type;
140+
}
141+
142+
get description(): string {
143+
return '';
144+
}
145+
146+
async run(repository: Repository): Promise<void> {
147+
const files = await askForFilesAndDirectories();
148+
149+
if (!files) {
150+
return;
151+
}
152+
153+
repository.propset(this.name, this.flag, files);
154+
}
155+
}
156+
85157
export class SvnCommands {
86158
private commands: any[] = [];
87159

@@ -364,6 +436,19 @@ export class SvnCommands {
364436
window.showErrorMessage("Unable to patch");
365437
}
366438
}
439+
440+
@command("svn.propset:ignore", { repository: true })
441+
async propsetIgnore(repository: Repository) {
442+
const placeHolder = "recursive or non-recursive?";
443+
const picks = IgnoreOptions.map(item => new IgnorePropItem(item.name, item.type, item.flag));
444+
const choice = await window.showQuickPick(picks, { placeHolder });
445+
446+
if (!choice) {
447+
return;
448+
}
449+
450+
await choice.run(repository);
451+
}
367452

368453
private runByRepository<T>(
369454
resource: Uri,

src/repository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,8 @@ export class Repository {
245245
this._onDidChangeRepository.fire();
246246
}
247247
}
248+
249+
async propset(name:string, flag:string, files:string) {
250+
return this.repository.propset(name, flag, files);
251+
}
248252
}

src/svn.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,10 @@ export class Svn {
250250
patch(root: string) {
251251
return this.exec(root, ["diff"]);
252252
}
253+
254+
propset(root:string, name:string, flag:string, files: any[]) {
255+
let args = ['propset', `svn:${name}`, flag, ...files];
256+
257+
return this.exec(root, args);
258+
}
253259
}

src/svnRepository.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,19 @@ export class Repository {
246246
const message = result.stdout;
247247
return message;
248248
}
249+
250+
async propset(name:string, flag:string, files:string) {
251+
const filesArray = files.split(" ");
252+
const result = await this.svn.propset(this.root, name, flag, filesArray);
253+
254+
console.log(result);
255+
256+
if (result.exitCode !== 0) {
257+
throw new Error(result.stderr);
258+
}
259+
260+
console.log(result.stdout);
261+
262+
return result.stdout;
263+
}
249264
}

0 commit comments

Comments
 (0)