diff --git a/package-lock.json b/package-lock.json index 95b2003f..812afba9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svn-scm", - "version": "1.26.0", + "version": "1.26.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ce502fce..6c9e1498 100644 --- a/package.json +++ b/package.json @@ -17,18 +17,9 @@ "bugs": { "url": "https://github.com/JohnstonCode/svn-scm/issues" }, - "categories": [ - "Other", - "SCM Providers" - ], - "keywords": [ - "multi-root ready", - "scm", - "svn" - ], - "activationEvents": [ - "*" - ], + "categories": ["Other", "SCM Providers"], + "keywords": ["multi-root ready", "scm", "svn"], + "activationEvents": ["*"], "main": "./out/extension", "scripts": { "vscode:prepublish": "tsc -p ./", @@ -216,6 +207,11 @@ "command": "svn.patchChangeList", "title": "Show patch from changelist", "category": "SVN" + }, + { + "command": "svn.addFileToIgnore", + "title": "Ignore", + "category": "SVN" } ], "menus": { @@ -238,11 +234,13 @@ }, { "command": "svn.openChangeBase", - "when": "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges" + "when": + "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges" }, { "command": "svn.openChangeHead", - "when": "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges" + "when": + "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges" }, { "command": "svn.openFile", @@ -298,7 +296,8 @@ }, { "command": "svn.revertSelectedRanges", - "when": "config.svn.enabled && svnOpenRepositoryCount != 0 && svnHasSupportToRegisterDiffCommand == 1" + "when": + "config.svn.enabled && svnOpenRepositoryCount != 0 && svnHasSupportToRegisterDiffCommand == 1" }, { "command": "svn.close", @@ -307,6 +306,10 @@ { "command": "svn.cleanup", "when": "config.svn.enabled && svnOpenRepositoryCount != 0" + }, + { + "command": "svn.addFileToIgnore", + "when": "false" } ], "scm/title": [ @@ -360,73 +363,93 @@ "scm/resourceState/context": [ { "command": "svn.add", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == unversioned", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup == unversioned", "group": "inline" }, { "command": "svn.add", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == unversioned", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup == unversioned", "group": "1_modification" }, { "command": "svn.openFile", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != external", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != external", "group": "navigation" }, { "command": "svn.openHEADFile", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external", "group": "navigation" }, { "command": "svn.openChangeBase", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external", "group": "navigation" }, { "command": "svn.openChangeHead", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external", "group": "navigation" }, { "command": "svn.patch", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", "group": "navigation" }, { "command": "svn.resolve", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup == conflicts", "group": "inline" }, { "command": "svn.resolve", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup == conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup == conflicts", "group": "1_modification" }, { "command": "svn.changelist", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", "group": "inline" }, { "command": "svn.changelist", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", "group": "1_modification" }, { "command": "svn.commit", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", "group": "1_modification" }, { "command": "svn.revert", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", "group": "2_modification" }, { "command": "svn.remove", - "when": "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup != unversioned && scmResourceGroup != external && scmResourceGroup != conflicts", "group": "2_modification" + }, + { + "command": "svn.addFileToIgnore", + "when": + "config.svn.enabled && scmProvider == svn && scmResourceGroup == unversioned", + "group": "1_modification" } ], "scm/change/title": [ @@ -439,22 +462,26 @@ { "command": "svn.openFile", "group": "navigation", - "when": "config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != extension && resourceScheme != merge-conflicts.conflicts-diff" + "when": + "config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != extension && resourceScheme != merge-conflicts.conflicts-diff" }, { "command": "svn.openChangeBase", "group": "navigation", - "when": "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges && !isInDiffEditor && resourceScheme == file" + "when": + "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges && !isInDiffEditor && resourceScheme == file" }, { "command": "svn.openChangeHead", "group": "navigation", - "when": "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges && !isInDiffEditor && resourceScheme == file" + "when": + "config.svn.enabled && svnOpenRepositoryCount != 0 && svnActiveEditorHasChanges && !isInDiffEditor && resourceScheme == file" }, { "command": "svn.revertSelectedRanges", "group": "2_svn@3", - "when": "config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != merge-conflicts.conflicts-diff && && svnHasSupportToRegisterDiffCommand == 1" + "when": + "config.svn.enabled && svnOpenRepositoryCount != 0 && isInDiffEditor && resourceScheme != merge-conflicts.conflicts-diff && && svnHasSupportToRegisterDiffCommand == 1" } ] }, @@ -473,14 +500,12 @@ }, "svn.decorations.enabled": { "type": "boolean", - "description": "Controls if SVN contributes colors and badges to the explorer and the open (VSCode >= 1.18 with proposed-api)", + "description": + "Controls if SVN contributes colors and badges to the explorer and the open (VSCode >= 1.18 with proposed-api)", "default": true }, "svn.path": { - "type": [ - "string", - "null" - ], + "type": ["string", "null"], "description": "Path to the svn executable", "default": null, "isExecutable": true @@ -492,59 +517,47 @@ }, "svn.diff.withHead": { "type": "boolean", - "description": "Show diff changes using latest revision in the repository. Set false to use latest revision in local folder", + "description": + "Show diff changes using latest revision in the repository. Set false to use latest revision in local folder", "default": true }, "svn.layout.trunkRegex": { - "type": [ - "string", - "null" - ], - "description": "Regex to detect path for 'trunk' in SVN URL, 'null' to disable. (Ex.: '(trunk)', '(main)')", + "type": ["string", "null"], + "description": + "Regex to detect path for 'trunk' in SVN URL, 'null' to disable. (Ex.: '(trunk)', '(main)')", "default": "(trunk)(/.*)?" }, "svn.layout.trunkRegexName": { - "type": [ - "number" - ], + "type": ["number"], "description": "Regex group position for name of trunk", "default": 1 }, "svn.layout.branchesRegex": { - "type": [ - "string", - "null" - ], - "description": "Regex to detect path for 'branches' in SVN URL, 'null' to disable. Subpath use 'branches/[^/]+/([^/]+)(/.*)?' (Ex.: 'branches/...', 'versions/...')", + "type": ["string", "null"], + "description": + "Regex to detect path for 'branches' in SVN URL, 'null' to disable. Subpath use 'branches/[^/]+/([^/]+)(/.*)?' (Ex.: 'branches/...', 'versions/...')", "default": "branches/([^/]+)(/.*)?" }, "svn.layout.branchesRegexName": { - "type": [ - "number" - ], + "type": ["number"], "description": "Regex group position for name of branch", "default": 1 }, "svn.layout.tagsRegex": { - "type": [ - "string", - "null" - ], - "description": "Regex to detect path for 'tags' in SVN URL, 'null' to disable. Subpath use 'tags/[^/]+/([^/]+)(/.*)?'. (Ex.: 'tags/...', 'stamps/...')", + "type": ["string", "null"], + "description": + "Regex to detect path for 'tags' in SVN URL, 'null' to disable. Subpath use 'tags/[^/]+/([^/]+)(/.*)?'. (Ex.: 'tags/...', 'stamps/...')", "default": "tags/([^/]+)(/.*)?" }, "svn.layout.tagRegexName": { - "type": [ - "number" - ], + "type": ["number"], "description": "Regex group position for name of tag", "default": 1 }, "svn.layout.showFullName": { - "type": [ - "boolean" - ], - "description": "Set true to show 'branches/' and false to show only ''", + "type": ["boolean"], + "description": + "Set true to show 'branches/' and false to show only ''", "default": true }, "svn.multipleFolders.enabled": { @@ -561,29 +574,24 @@ "svn.multipleFolders.ignore": { "type": "array", "description": "Folders to ignore using SVN", - "default": [ - "**/.git", - "**/.hg", - "**/vendor", - "**/node_modules" - ] + "default": ["**/.git", "**/.hg", "**/vendor", "**/node_modules"] }, "svn.sourceControl.ignoreOnCommit": { "type": "array", "description": "Changelists to ignore on commit", - "default": [ - "ignore-on-commit" - ] + "default": ["ignore-on-commit"] }, "svn.detectExternals": { "type": "boolean", "default": true, - "description": "Controls whether to automatically detect svn externals." + "description": + "Controls whether to automatically detect svn externals." }, "svn.sourceControl.combineExternalIfSameServer": { "type": "boolean", "default": false, - "description": "Combine the svn external in the main if is from the same server." + "description": + "Combine the svn external in the main if is from the same server." }, "svn.sourceControl.countUnversioned": { "type": "boolean", @@ -608,15 +616,14 @@ }, "svn.update.ignoreExternals": { "type": "boolean", - "description": "Set to ignore externals definitions on update (add --ignore-externals)", + "description": + "Set to ignore externals definitions on update (add --ignore-externals)", "default": true }, "svn.default.encoding": { - "type": [ - "string", - "null" - ], - "description": "Encoding of svn output if the output is not utf-8. When this parameter is null, the encoding is automatically detected. Example: 'windows-1252'.", + "type": ["string", "null"], + "description": + "Encoding of svn output if the output is not utf-8. When this parameter is null, the encoding is automatically detected. Example: 'windows-1252'.", "default": null }, "svn.showUpdateMessage": { @@ -627,4 +634,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/commands.ts b/src/commands.ts index 4444d9c9..a4eeb7f7 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -235,15 +235,13 @@ export class SvnCommands implements IDisposable { repository.changelists.forEach((group, changelist) => { if ( - group.resourceStates.some(state => - { - return resources.some(resource => { - return resource.path === state.resourceUri.path; - }); - } - ) + group.resourceStates.some(state => { + return resources.some(resource => { + return resource.path === state.resourceUri.path; + }); + }) ) { - console.log('canRemove true'); + console.log("canRemove true"); canRemove = true; return false; } @@ -699,7 +697,7 @@ export class SvnCommands implements IDisposable { ); const result = await repository.updateRevision(ignoreExternals); - + if (showUpdateMessage) { window.showInformationMessage(result); } @@ -766,15 +764,15 @@ export class SvnCommands implements IDisposable { await this.showDiffPath(repository, content); }); } - + @command("svn.patchChangeList", { repository: true }) async patchChangeList(repository: Repository): Promise { const changelistName = await getPatchChangelist(repository); - + if (!changelistName) { return; } - + const content = await repository.patchChangelist(changelistName); await this.showDiffPath(repository, content); } @@ -1057,6 +1055,34 @@ export class SvnCommands implements IDisposable { await repository.finishCheckout(); } + @command("svn.addFileToIgnore") + async addFileToIgnore( + ...resourceStates: SourceControlResourceState[] + ): Promise { + const selection = this.getResourceStates(resourceStates); + + if (selection.length === 0) { + return; + } + + const uris = selection.map(resource => resource.resourceUri); + + await this.runByRepository(uris, async (repository, resources) => { + if (!repository) { + return; + } + + for (const resource of resources) { + try { + await repository.addFileToIgnore(resource.fsPath); + } catch (error) { + console.log(error); + window.showErrorMessage("Unable to set property"); + } + } + }); + } + private getSCMResource(uri?: Uri): Resource | undefined { uri = uri ? uri diff --git a/src/repository.ts b/src/repository.ts index 231517e2..ef33c2c1 100644 --- a/src/repository.ts +++ b/src/repository.ts @@ -58,7 +58,8 @@ export enum Operation { Show = "Show", Status = "Status", SwitchBranch = "SwitchBranch", - Update = "Update" + Update = "Update", + Ignore = "Ignore" } function isReadOnly(operation: Operation): boolean { @@ -695,6 +696,12 @@ export class Repository { ); } + async addFileToIgnore(filePath: string) { + return await this.run(Operation.Ignore, () => + this.repository.addFileToIgnore(filePath) + ); + } + async promptAuth(): Promise { // Prevent multiple prompts for auth if (this.lastPromptAuth) { diff --git a/src/svnRepository.ts b/src/svnRepository.ts index 25f25542..6a302c65 100644 --- a/src/svnRepository.ts +++ b/src/svnRepository.ts @@ -329,7 +329,7 @@ export class Repository { const message = result.stdout; return message; } - + async patchChangelist(changelistName: string) { const result = await this.exec(["diff", "--changelist", changelistName]); const message = result.stdout; @@ -404,4 +404,31 @@ export class Repository { return parseSvnList(result.stdout); } + + async addFileToIgnore(filePath: string) { + const fileName = path.basename(filePath); + const parentDir = path.dirname(filePath); + let currentIgnore = ""; + + try { + const currentIgnoreResult = await this.exec([ + "propget", + "svn:ignore", + parentDir + ]); + + currentIgnore = currentIgnoreResult.stdout.trim(); + } catch (error) {} + + const newIgnore = currentIgnore + "\n" + fileName; + + const result = await this.exec([ + "propset", + "svn:ignore", + newIgnore, + parentDir + ]); + + return result.stdout; + } }