diff --git a/.vscode/settings.json b/.vscode/settings.json index e41d8bc..a6b8485 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -30,6 +30,7 @@ "[typescript]": { "editor.defaultFormatter": "vscode.typescript-language-features" }, + "peacock.remoteColor": "#1857a4", "workbench.colorCustomizations": { "activityBar.activeBackground": "#1f6fd0", "activityBar.activeBorder": "#ee90bb", @@ -48,6 +49,5 @@ "titleBar.activeForeground": "#e7e7e7", "titleBar.inactiveBackground": "#1857a499", "titleBar.inactiveForeground": "#e7e7e799" - }, - "peacock.remoteColor": "#1857a4" + } } diff --git a/CHANGELOG.md b/CHANGELOG.md index f5ee12c..45c463e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,32 +2,37 @@ All notable changes to the "gitflow" extension will be documented in this file. +## [1.3.0] 02/27/2022 + +- add - use `git.path` settings. +- enhance - better find git executable path on windows. + ## [1.2.9] 02/07/2022 - security - fix string sanitization -## [1.2.8] 03/07/22 +## [1.2.8] 03/07/2022 - fix - stop command on ESC. - fix - run version bump only when released or hotfix is started - enhance - `CHANGELOG.md` update conditions -## [1.2.7] 03/04/22 +## [1.2.7] 03/04/2022 - fix - changelog update `mm` not to be replaced in a word like co**mm**and. - fix - release message is undefined -## [1.2.0] 03/04/22 +## [1.2.0] 03/04/2022 - change - Now version bump happens on hotfix or release start rather than finish - add - update changelog automatically - enhance - Allow change finish message when finish hotfix or release -## [1.1.0] 02/21/22 +## [1.1.0] 02/21/2022 - optimize - performance improvement using memoization technique. -## [1.0.1] 02/07/22 +## [1.0.1] 02/07/2022 Finlay I have all features I planned in this extension. This is still preview but final extension. @@ -36,12 +41,12 @@ Finlay I have all features I planned in this extension. This is still preview bu - fix - Readme was not visible in marketplace. - optimize - code refactor. -## [0.5.11] 02/05/22 +## [0.5.11] 02/05/2022 - add - Status bar button to call Quick Pick menu - add - Groups in Quick Pick (require VS Code >=1.64.0) -## [0.5.9] 02/04/22 +## [0.5.9] 02/04/2022 - add - Checkout support branch - add - Publish support branch @@ -49,47 +54,47 @@ Finlay I have all features I planned in this extension. This is still preview bu - add - Delete tags local and remote - fix - Release checkout -## [0.5.6] 02/03/22 +## [0.5.6] 02/03/2022 - fix - If error tags shows error as tags - fix - important to update. Fix some release issues. -## [0.5.2] 02/03/22 +## [0.5.2] 02/03/2022 - change - use different bundler for extension - add - Quick Pick popup - optimize - Code was refactored and optimized. 1800 lines to 580. -## [0.4.3] 02/02/22 +## [0.4.3] 02/02/2022 - add - Support for multiple folder workspaces - fix - Progress notification not resolving -## [0.3.0] 02/02/22 +## [0.3.0] 02/02/2022 - add - Support (Start, Checkout, Rebase, Delete) - add - Release checkout - add - Hotfix checkout -## [0.2.14] 01/31/22 +## [0.2.14] 01/31/2022 - enhance - Order and group context menu elements. - enhance - use VS Code theme icons instead of SVG. This will apply Product icons theme to this extension too. - enhance - not related to features of this extension, but CI flow was created for fast delivery of new versions. - enhance - README overview updated with new features and new picture. -## [0.2.11] 01/30/22 +## [0.2.11] 01/30/2022 - fix - take name of flow branches from configuration - fix - ui buttons -## [0.2.9] 01/28/22 +## [0.2.9] 01/28/2022 - add - single command to sync all root branches (develop and master ot main) - add - command to checkout root branches - enhance - better icons -## [0.2.5] - 01/27/22 +## [0.2.5] - 01/27/2022 - fix - Git authenticated commands to remote - add - icons to menu elements @@ -98,6 +103,6 @@ Finlay I have all features I planned in this extension. This is still preview bu - add - progress notification during process - Update `README.md` with important instructions -## [0.1.5] - 01/26/22 +## [0.1.5] - 01/26/2022 - Initial release diff --git a/README.md b/README.md index 2d3d6b7..bca3e68 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,16 @@ GitHub CLI will automatically store your Git credentials for you when you choose ## Changelog -- 1.2.0 +- 1.3.0 + - add - use `git.path` settings. + - enhance - better find git executable path on windows. +- 1.2.9 + - security - fix string sanitization + - fix - stop command on ESC. + - fix - run version bump only when released or hotfix is started + - enhance - `CHANGELOG.md` update conditions + - fix - changelog update `mm` not to be replaced in a word like co**mm**and. + - fix - release message is undefined - change - Now version bump happens on hotfix or release start rather than finish - add - update changelog automatically - enhance - Allow change finish message when finish hotfix or release diff --git a/SECURITY.md b/SECURITY.md index d27717d..0577ec7 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,8 +6,8 @@ Versions are currently being supported with security updates. | Version | Supported | | ------- | ------------------ | -| 1.x.x | :white_check_mark: | +| 1.2.9 | :white_check_mark: | ## Reporting a Vulnerability -To report a vulnerabilty, please open an issue. +To report a vulnerability, please open an issue. diff --git a/package-lock.json b/package-lock.json index f1fc301..bccb273 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-gitflow", - "version": "1.0.1", + "version": "1.2.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-gitflow", - "version": "1.0.1", + "version": "1.2.9", "dependencies": { "semver": "^7.3.5", "typescript-memoize": "^1.1.0" @@ -23,7 +23,7 @@ "eslint": "^8.6.0", "glob": "^7.2.0", "mocha": "^9.1.3", - "typescript": "^4.5.4", + "typescript": "^4.6.3", "vsce": "^2.6.4" }, "engines": { @@ -3504,9 +3504,9 @@ } }, "node_modules/typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", + "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -6351,9 +6351,9 @@ } }, "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", + "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", "dev": true }, "typescript-memoize": { diff --git a/package.json b/package.json index 8c5d034..8b85ec9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-gitflow", "displayName": "Git Flow", "description": "Git-Flow support for VS Code", - "version": "1.2.9", + "version": "1.3.0", "engines": { "vscode": "^1.64.0" }, @@ -39,7 +39,8 @@ "onView:gitflowTags" ], "extensionDependencies": [ - "vscode.git" + "vscode.git", + "vscode.git-base" ], "repository": { "type": "git", @@ -724,15 +725,15 @@ ] } }, - "main": "./out/main.js", + "main": "./out/extension.js", "scripts": { - "vscode:prepublish": "npm run esbuild-base -- --minify", + "_vscode:prepublish": "npm run esbuild-base -- --minify", "esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node", "esbuild": "npm run esbuild-base -- --sourcemap", "esbuild-watch": "npm run esbuild-base -- --sourcemap --watch", "watch": "tsc -watch -p ./", "publish": "vsce package && gh release create $(node -pe \"require('./package.json')['version']\") --generate-notes \"./vscode-gitflow-$(node -pe \"require('./package.json')['version']\").vsix\" && vsce publish", - "_vscode:prepublish": "npm run compile", + "vscode:prepublish": "npm run compile", "compile": "tsc -p ./", "pretest": "npm run compile && npm run lint", "lint": "eslint src --ext ts", @@ -751,7 +752,7 @@ "eslint": "^8.6.0", "glob": "^7.2.0", "mocha": "^9.1.3", - "typescript": "^4.5.4", + "typescript": "^4.6.3", "vsce": "^2.6.4" }, "dependencies": { diff --git a/src/ViewBranches.ts b/src/ViewBranches.ts index 823c8cf..62f1e9f 100644 --- a/src/ViewBranches.ts +++ b/src/ViewBranches.ts @@ -25,6 +25,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { public curBranch: string = ""; public listBranches: string[] = []; public listRemoteBranches: string[] = []; + public hasOrigin: boolean = false; private terminal: vscode.Terminal | null; private branches: BranchList; @@ -56,7 +57,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { let tree: Flow[] = []; if (element === undefined) { - let list = this.util.execSync("git flow config list"); + let list = this.util.execSync(`"${this.util.path}" flow config list`); if (list.toLowerCase().search("not a gitflow-enabled repo yet") > 0) { let initLink = "Init"; @@ -73,9 +74,9 @@ export class TreeViewBranches implements vscode.TreeDataProvider { return Promise.resolve([]); } - this.curBranch = this.util.execSync("git rev-parse --abbrev-ref HEAD").trim(); + this.curBranch = this.util.execSync(`"${this.util.path}" rev-parse --abbrev-ref HEAD`).trim(); - let b = this.util.execSync("git flow config list").replace("\r", "").split("\n"); + let b = this.util.execSync(`"${this.util.path}" flow config list`).replace("\r", "").split("\n"); this.branches.master = b[0].split(": ")[1].trim(); this.branches.develop = b[1].split(": ")[1].trim(); this.branches.feature = b[2].split(": ")[1].trim(); @@ -85,21 +86,24 @@ export class TreeViewBranches implements vscode.TreeDataProvider { this.branches.support = b[6].split(": ")[1].trim(); // this.listRemotes = [...new Set( - // this.util.execSync('git remote -v') + // this.util.execSync(`"${this.util.path}" remote -v') // .split("\n") // .map(el => el.split("\t")[0].trim()) // .filter(el => el !== '') // )]; this.listBranches = this.util - .execSync("git branch") + .execSync(`"${this.util.path}" branch`) .split("\n") .map((el) => el.trim().replace("* ", "")) .filter((el) => el !== ""); this.listRemoteBranches = this.util - .execSync("git branch -r") + .execSync(`"${this.util.path}" branch -r`) .split("\n") .map((el) => { + if(el.toLowerCase().search("origin/") !== -1){ + this.hasOrigin = true; + } let a = el.split("/"); a.shift(); return a.join("/"); @@ -214,12 +218,16 @@ export class TreeViewBranches implements vscode.TreeDataProvider { } fetchAllBranches() { - this.util.exec("git fetch --all", true, (s) => { + this.util.exec(`"${this.util.path}" fetch --all`, true, (s) => { this._onDidChangeTreeData.fire(); }); } syncAll() { + if(!this.hasOrigin) { + vscode.window.showWarningMessage("No ORIGIN remote has been found!"); + return; + } vscode.window .withProgress( { @@ -234,9 +242,9 @@ export class TreeViewBranches implements vscode.TreeDataProvider { .filter((el) => el.split("/").length < 2) .forEach((el) => { if (this.listRemoteBranches.includes(el)) { - this.util.execSync(`git pull origin ${el}`); + this.util.execSync(`"${this.util.path}" pull origin ${el}`); } - this.util.execSync(`git push origin ${el}:${el}`); + this.util.execSync(`"${this.util.path}" push origin ${el}:${el}`); }); resolve(); }, 100); @@ -256,7 +264,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { ); } - let cmd = `git checkout -q ${name}`; + let cmd = `"${this.util.path}" checkout -q ${name}`; this.util.exec(cmd, false, (s) => { this._onDidChangeTreeData.fire(); @@ -318,7 +326,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { if (feature === "support") { base = await vscode.window.showQuickPick( this.util - .execSync("git tag --sort=-v:refname") + .execSync(`"${this.util.path}" tag --sort=-v:refname`) .split("\n") .map((el) => el.trim().replace("* ", "")) .filter((el) => el !== ""), @@ -374,7 +382,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { case "support": let root = this.listBranches.filter((el) => el.split("/").length < 2); let tags = this.util - .execSync("git tag --sort=-v:refname") + .execSync(`"${this.util.path}" tag --sort=-v:refname`) .split("\n") .map((el) => el.trim().replace("* ", "")) .filter((el) => el !== ""); @@ -445,8 +453,8 @@ export class TreeViewBranches implements vscode.TreeDataProvider { if (updated) { writeFileSync(this.util.workspaceRoot + "/CHANGELOG.md", chc); - this.util.execSync("git add ./CHANGELOG.md"); - this.util.execSync('git commit ./CHANGELOG.md -m"Update Changelog"'); + this.util.execSync(`"${this.util.path}" add ./CHANGELOG.md`); + this.util.execSync(`"${this.util.path}" commit ./CHANGELOG.md -m"Update Changelog"`); } } } @@ -457,7 +465,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { vscode.workspace.getConfiguration("gitflow").get("showAllCommands") === true ? " --showcommands " : " "; - let cmd = `git flow ${feature} ${what}${command}${option} ${name} ${base}`; + let cmd = `"${this.util.path}" flow ${feature} ${what}${command}${option} ${name} ${base}`; console.log(cmd); this.util.exec(cmd, progress, (s) => { @@ -477,8 +485,8 @@ export class TreeViewBranches implements vscode.TreeDataProvider { `${name}` ) ); - this.util.execSync("git add ./package.json"); - this.util.execSync('git commit ./package.json -m"Version bump"'); + this.util.execSync(`"${this.util.path}" add ./package.json`); + this.util.execSync(`"${this.util.path}" commit ./package.json -m"Version bump"`); } } }); @@ -590,11 +598,11 @@ export class TreeViewBranches implements vscode.TreeDataProvider { }); let option = options?.includes("[-f] Force deletion") ? "-D" : "-d"; - this.util.execSync(`git checkout -d ${this.branches.develop}`); - this.util.execSync(`git branch ${option} ${name}`); + this.util.execSync(`"${this.util.path}" checkout -d ${this.branches.develop}`); + this.util.execSync(`"${this.util.path}" branch ${option} ${name}`); if (options?.includes("[-r] Delete remote branch")) { - this.util.exec(`git push --delete origin ${name}`, true, () => { + this.util.exec(`"${this.util.path}" push --delete origin ${name}`, true, () => { this._onDidChangeTreeData.fire(); }); return; @@ -603,6 +611,10 @@ export class TreeViewBranches implements vscode.TreeDataProvider { this._onDidChangeTreeData.fire(); } async publishSupport(node: Flow | undefined) { + if(!this.hasOrigin) { + vscode.window.showWarningMessage("No ORIGIN remote has been found!"); + return; + } let name = node?.full; if (name === undefined) { name = await vscode.window.showQuickPick( @@ -614,7 +626,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { return; } - let cmd = `git push origin ${name}`; + let cmd = `"${this.util.path}" push origin ${name}`; this.util.exec(cmd, true, (s) => { this._onDidChangeTreeData.fire(); @@ -632,7 +644,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { return; } - let cmd = `git checkout -q ${name}`; + let cmd = `"${this.util.path}" checkout -q ${name}`; this.util.exec(cmd, false, (s) => { this._onDidChangeTreeData.fire(); @@ -725,7 +737,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { if (name === undefined) { return; } - let cmd = `git checkout -q ${name}`; + let cmd = `"${this.util.path}" checkout -q ${name}`; this.util.exec(cmd, false, (s) => { this._onDidChangeTreeData.fire(); @@ -749,7 +761,7 @@ export class TreeViewBranches implements vscode.TreeDataProvider { //#endregion version(): string { - return this.util.execSync("git flow version"); + return this.util.execSync(`"${this.util.path}" flow version`); } refresh(): void { diff --git a/src/ViewVersions.ts b/src/ViewVersions.ts index 6f4d96b..eb572fe 100644 --- a/src/ViewVersions.ts +++ b/src/ViewVersions.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; -import {Util} from "./lib/Util"; +import { Util } from "./lib/Util"; -let checked:boolean = false; +let checked: boolean = false; export class TreeViewVersions implements vscode.TreeDataProvider { private _onDidChangeTreeData: vscode.EventEmitter = @@ -11,6 +11,7 @@ export class TreeViewVersions implements vscode.TreeDataProvider { private terminal: vscode.Terminal | null; private remotes: string[] = []; private tags: string[] = []; + private hasOrigin: boolean = false; constructor(private util: Util) { this.terminal = null; @@ -29,15 +30,25 @@ export class TreeViewVersions implements vscode.TreeDataProvider { return Promise.resolve([]); } checked = true; - - this.remotes = this.util - .execSync("git ls-remote --tags origin") + this.util + .execSync(`"${this.util.path}" remote`) .split("\n") - .filter((el) => el.trim().search("refs/tags/") > 0) - .map((el) => el.split("/")[2].replace("^{}", "")); + .map((el) => { + if (el.toLowerCase().trim() === "origin") { + this.hasOrigin = true; + } + }); + + if (this.hasOrigin) { + this.remotes = this.util + .execSync(`"${this.util.path}" ls-remote --tags origin`) + .split("\n") + .filter((el) => el.trim().search("refs/tags/") > 0) + .map((el) => el.split("/")[2].replace("^{}", "")); + } this.tags = this.util - .execSync("git tag --sort=-v:refname") + .execSync(`"${this.util.path}" tag --sort=-v:refname`) .split("\n") .map((el) => el.trim()) .filter((el) => el !== ""); @@ -56,7 +67,7 @@ export class TreeViewVersions implements vscode.TreeDataProvider { let name = node?.label; if (node === undefined) { let tags = this.util - .execSync("git tag --sort=-v:refname") + .execSync(`"${this.util.path}" tag --sort=-v:refname`) .split("\n") .map((el) => el.trim()) .filter((el) => el !== ""); @@ -75,15 +86,19 @@ export class TreeViewVersions implements vscode.TreeDataProvider { })) || []; } if (remotes.includes("Delete Remote")) { - this.util.execSync(`git push --delete origin ${name}`); + this.util.execSync(`"${this.util.path}" push --delete origin ${name}`); } if (remotes.includes("Delete local")) { - this.util.execSync(`git tag -d ${name}`); + this.util.execSync(`"${this.util.path}" tag -d ${name}`); } this._onDidChangeTreeData.fire(); } async pushTag(node: Tag | undefined) { + if(!this.hasOrigin) { + vscode.window.showWarningMessage("No ORIGIN remote has been found!"); + return; + } let name = node?.label; if (node === undefined) { let tags = this.util @@ -97,12 +112,16 @@ export class TreeViewVersions implements vscode.TreeDataProvider { return; } - this.util.exec(`git push origin ${name}`, true, (s) => { + this.util.exec(`"${this.util.path}" push origin ${name}`, true, (s) => { this._onDidChangeTreeData.fire(); }); } pushTags() { - this.util.exec(`git push origin --tags`, true, (s) => { + if(!this.hasOrigin) { + vscode.window.showWarningMessage("No ORIGIN remote has been found!"); + return; + } + this.util.exec(`"${this.util.path}" push origin --tags`, true, (s) => { this._onDidChangeTreeData.fire(); }); } diff --git a/src/extension.ts b/src/extension.ts index 7f4f0de..b900777 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,9 +1,9 @@ import * as vscode from "vscode"; -import {CommandManager} from "./lib/cm"; -import {Logger} from "./lib/logger"; -import {Util} from "./lib/Util"; -import {Flow, TreeViewBranches} from "./ViewBranches"; -import {TreeViewVersions, Tag} from "./ViewVersions"; +import { CommandManager } from "./lib/cm"; +import { Logger } from "./lib/logger"; +import { Util } from "./lib/Util"; +import { Flow, TreeViewBranches } from "./ViewBranches"; +import { TreeViewVersions, Tag } from "./ViewVersions"; export function activate(context: vscode.ExtensionContext) { let rootPath: string = @@ -13,6 +13,7 @@ export function activate(context: vscode.ExtensionContext) { const logger = new Logger(); logger.log("Extension activate", "activate"); + logger.log(rootPath, "Root"); const util = new Util(rootPath, logger); @@ -63,13 +64,7 @@ export function activate(context: vscode.ExtensionContext) { }); } -export function deactivate() {} - -// import {GitExtension, API as GitAPI} from "./lib/git"; -// import {GitBaseExtension, API as GitBaseAPI} from "./lib/git-base"; - -// const gitExtension = extensions.getExtension("vscode.git")!.exports; -// const git = gitExtension.getAPI(1); +export function deactivate() { } // const gitBaseExtension = extensions.getExtension("vscode.git-base")!.exports; // const gitbase = gitExtension.getAPI(1); diff --git a/src/lib/Util.ts b/src/lib/Util.ts index 50e47df..bb1b531 100644 --- a/src/lib/Util.ts +++ b/src/lib/Util.ts @@ -2,6 +2,8 @@ import * as vscode from "vscode"; import { execSync, exec, spawn, SpawnOptions } from "child_process"; import { Logger, LogLevels } from "./logger"; import { Memoize, MemoizeExpiring } from "typescript-memoize"; +import { GitExtension, API as GitAPI } from "./git"; +// import { GitBaseExtension, API as GitBaseAPI } from "./lib/git-base"; type CmdResult = { retc: number | null; @@ -10,7 +12,19 @@ type CmdResult = { }; export class Util { - constructor(public workspaceRoot: string, private logger: Logger) { } + public path: string = ''; + constructor(public workspaceRoot: string, private logger: Logger) { + this.path = vscode.workspace.getConfiguration('git').get('path') || ""; + if (this.path.trim().length === 0) { + const gitExtension = vscode.extensions.getExtension("vscode.git")!.exports; + const git = gitExtension.getAPI(1); + this.path = git.git.path; + } + if (this.path.trim().length === 0) { + vscode.window.showWarningMessage("Git is not found"); + } + this.logger.log("Git found (path)", this.path); + } private progress(cmd: string, cb: (s: string) => void) { vscode.window.withProgress( @@ -41,12 +55,15 @@ export class Util { @MemoizeExpiring(1000) public execSync(cmd: string): string { + if (this.path.trim().length === 0) { + return ""; + } try { let out = execSync(cmd, { cwd: this.workspaceRoot }).toString(); this.logger.log(out, cmd); return out; } catch (e) { - this.logger.log(`${e}`, cmd, LogLevels.error); + this.logger.log(`ERROR: ${e}`, cmd, LogLevels.error); vscode.window.showErrorMessage(`Error executing: ${cmd} : ${e}`); return "" + e; } @@ -54,11 +71,11 @@ export class Util { @MemoizeExpiring(1000) private execCb(cmd: string, cb: (s: string) => void, resolve?: any): void { + if (this.path.trim().length === 0) { + return; + } exec( - cmd, - { - cwd: this.workspaceRoot, - }, + cmd, { cwd: this.workspaceRoot, }, (err, stdout, stderr) => { if (err) { vscode.window.showErrorMessage(`Error executing: ${cmd} : ${err}`); @@ -80,20 +97,20 @@ export class Util { vscode.window.showErrorMessage("No folder opened"); return false; } - let status = this.execSync("git version").toLowerCase(); + let status = this.execSync(`"${this.path}" version`).toLowerCase(); if (status.search("git version") === -1) { vscode.window.showWarningMessage("Looks like git CLI is not installed."); return false; } - status = this.execSync("git status").toLowerCase(); + status = this.execSync(`"${this.path}" status`).toLowerCase(); if (status.search("not a git repository") !== -1) { vscode.window.showWarningMessage("This project is not a Git repository."); return false; } - if (this.execSync("git flow").toLowerCase().search("is not a git command") !== -1) { + if (this.execSync(`"${this.path}" flow log`).toLowerCase().search("is not a git command") !== -1) { let installLink = "Install"; vscode.window .showWarningMessage("To use Git Flow extension please install Git flow (AVH).", installLink)