diff --git a/dist/index.js b/dist/index.js index 9a3f96d..ae4cb49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -558,7 +558,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.GitAuthHelper = void 0; const core = __importStar(__nccwpck_require__(2186)); const fs = __importStar(__nccwpck_require__(7147)); -const path = __importStar(__nccwpck_require__(1017)); const url_1 = __nccwpck_require__(7310); const utils = __importStar(__nccwpck_require__(918)); class GitAuthHelper { @@ -653,10 +652,11 @@ class GitAuthHelper { gitConfigStringReplace(find, replace) { return __awaiter(this, void 0, void 0, function* () { if (this.gitConfigPath.length === 0) { - const gitDir = yield this.git.getGitDirectory(); - this.gitConfigPath = path.join(this.workingDirectory, gitDir, 'config'); + this.gitConfigPath = yield this.git.getGitPath('config'); } + console.log(this.gitConfigPath); let content = (yield fs.promises.readFile(this.gitConfigPath)).toString(); + console.log(content); const index = content.indexOf(find); if (index < 0 || index != content.lastIndexOf(find)) { throw new Error(`Unable to replace '${find}' in ${this.gitConfigPath}`); @@ -833,6 +833,15 @@ class GitCommandManager { getGitDirectory() { return this.revParse('--git-dir'); } + getGitPath(path) { + return __awaiter(this, void 0, void 0, function* () { + const args = ['rev-parse', '--git-path']; + if (path) + args.push(path); + const output = yield this.exec(args); + return output.stdout.trim(); + }); + } getWorkingDirectory() { return this.workingDirectory; } diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index 1b6c375..518ca76 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -1,7 +1,6 @@ import * as core from '@actions/core' import * as fs from 'fs' import {GitCommandManager} from './git-command-manager' -import * as path from 'path' import {URL} from 'url' import * as utils from './utils' @@ -133,8 +132,7 @@ export class GitAuthHelper { replace: string ): Promise { if (this.gitConfigPath.length === 0) { - const gitDir = await this.git.getGitDirectory() - this.gitConfigPath = path.join(this.workingDirectory, gitDir, 'config') + this.gitConfigPath = await this.git.getGitPath('config') } let content = (await fs.promises.readFile(this.gitConfigPath)).toString() const index = content.indexOf(find) diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index b77f078..c3024b8 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -150,6 +150,13 @@ export class GitCommandManager { return this.revParse('--git-dir') } + async getGitPath(path?: string): Promise { + const args = ['rev-parse', '--git-path'] + if (path) args.push(path) + const output = await this.exec(args) + return output.stdout.trim() + } + getWorkingDirectory(): string { return this.workingDirectory }