revParse git path to find config file
This commit is contained in:
parent
989188a00c
commit
46db4850df
3 changed files with 20 additions and 6 deletions
|
@ -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<void> {
|
||||
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)
|
||||
|
|
|
@ -150,6 +150,13 @@ export class GitCommandManager {
|
|||
return this.revParse('--git-dir')
|
||||
}
|
||||
|
||||
async getGitPath(path?: string): Promise<string> {
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue