From 1fc88ca7397afd67b00890e3fb32b314900d27fc Mon Sep 17 00:00:00 2001 From: Edgard Lorraine Messias Date: Fri, 1 Dec 2017 16:00:32 -0200 Subject: [PATCH] Improved multiple svn folders --- CHANGELOG.md | 7 +++++++ package.json | 7 ++++++- src/model.ts | 57 ++++++++++++++++++++++++++++++---------------------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ede51156..b68c08c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # **v1.5.0 UNDER DEVELOPMENT** +# **v1.4.1** + +## Bug Fixes + +* @edgardmessias Not check SVN version if folder not contains ".svn" folder +* @edgardmessias Fixed ignored folder for multifolder svn to work with Windows + # **v1.4.0** ## What's New diff --git a/package.json b/package.json index 8822cb73..20be7b40 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,12 @@ "type": "array", "minimum": 4, "description": "Folders to ignore using SVN", - "default": ["**/.git", "**/.hg", "**/vendor", "**/node_modules"] + "default": [ + "**/.git/**", + "**/.hg/**", + "**/vendor/**", + "**/node_modules/**" + ] } } } diff --git a/src/model.ts b/src/model.ts index 1e0f6686..36b9b94e 100644 --- a/src/model.ts +++ b/src/model.ts @@ -75,11 +75,18 @@ export class Model { // Base on https://github.com/aleclarson/glob-regex/blob/master/index.js const pattern = ignoreList - .join("|") - .replace(/\./g, "\\.") - .replace(/\*\*\//g, "(.+[\\\\/])?") - .replace(/\*\*/g, "(.+[\\\\/])?*") - .replace(/\*/g, "[^\\\\/]+"); + .map((ignored: string) => { + return ignored + .replace(/\\/g, "/") + .replace(/\./g, "\\.") + .replace(/\*\*\//g, "(.+[\\\\/])?") + .replace(/\*\*/g, "(.+[\\\\/])?*") + .replace(/\*/g, "[^\\\\/]+") + .replace(/(\w)\//g, "$1[\\\\/]") + .replace(/\/(\w)/g, "[\\\\/]$1") + .replace(/(\w)$/g, "$1([\\\\/].*)*"); + }) + .join("|"); try { this.ignorePattern = new RegExp("^(" + pattern + ")$"); @@ -177,30 +184,32 @@ export class Model { return; } - try { - const repositoryRoot = await this.svn.getRepositoryRoot(path); - - if (this.getRepository(repositoryRoot)) { - return; - } - - const repository = new Repository(this.svn.open(repositoryRoot, path)); + if (fs.existsSync(path + "/.svn")) { + try { + const repositoryRoot = await this.svn.getRepositoryRoot(path); - this.open(repository); - } catch (err) { - const newLevel = level + 1; + if (this.getRepository(repositoryRoot)) { + return; + } - if (newLevel <= this.maxDepth) { - fs.readdirSync(path).forEach(file => { - const dir = path + "/" + file; - if (fs.statSync(dir).isDirectory() && !this.ignorePattern.test(dir)) { - this.tryOpenRepository(dir, newLevel); - } - }); - } + const repository = new Repository(this.svn.open(repositoryRoot, path)); + this.open(repository); + } catch (err) {} return; } + + const newLevel = level + 1; + if (newLevel <= this.maxDepth) { + fs.readdirSync(path).forEach(file => { + const dir = path + "/" + file; + if (fs.statSync(dir).isDirectory() && !this.ignorePattern.test(dir)) { + this.tryOpenRepository(dir, newLevel); + } + }); + } + + return; } getRepository(hint: any) {