Skip to content

Commit 6b324fa

Browse files
committed
Added support to multiple .svn folders (See #30)
1 parent 5ecfafc commit 6b324fa

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/model.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ export class Model {
119119
}
120120
}
121121

122-
async tryOpenRepository(path: string): Promise<void> {
123-
if (this.getRepository(path)) {
122+
async tryOpenRepository(path: string, level = 1): Promise<void> {
123+
// @todo add a config value and run a recursive function to scan folders for the defined depth
124+
if (this.getRepository(path) || level > 4) {
124125
return;
125126
}
126127

@@ -135,7 +136,14 @@ export class Model {
135136

136137
this.open(repository);
137138
} catch (err) {
138-
console.error(err);
139+
const newLevel = level + 1;
140+
fs.readdirSync(path).forEach(file => {
141+
const dir = path + "/" + file;
142+
if (fs.statSync(dir).isDirectory()) {
143+
this.tryOpenRepository(dir, newLevel);
144+
}
145+
});
146+
139147
return;
140148
}
141149
}

src/svn.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ export class SvnError {
9595
export class Svn {
9696
private svnPath: string;
9797
private version: string;
98-
98+
private lastCwd: string = "";
99+
99100
private _onOutput = new EventEmitter();
100101
get onOutput(): EventEmitter {
101102
return this._onOutput;
@@ -112,11 +113,12 @@ export class Svn {
112113

113114
async exec(cwd: string, args: any[], options: CpOptions = {}) {
114115
if (cwd) {
116+
this.lastCwd = cwd;
115117
options.cwd = cwd;
116118
}
117119

118120
if (options.log !== false) {
119-
this.log(`svn ${args.join(" ")}\n`);
121+
this.log(`[${this.lastCwd.split(/[\\\/]+/).pop()}]$ svn ${args.join(" ")}\n`);
120122
}
121123

122124
let process = cp.spawn(this.svnPath, args, options);
@@ -216,7 +218,7 @@ export class Svn {
216218
}
217219

218220
switchBranch(root: string, path: string) {
219-
return this.exec(root, ["switch", path]);
221+
return this.exec(root, ["switch", path, "--ignore-ancestry"]);
220222
}
221223

222224
revert(files: any[]) {

0 commit comments

Comments
 (0)