Skip to content

Commit

Permalink
fix issue neoclide#217, Support cgywin/msys2 bash environment
Browse files Browse the repository at this point in the history
  • Loading branch information
lsq committed Dec 20, 2024
1 parent cfc2b86 commit d7886b0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/model/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export default class Git {

public async getRepositoryRoot(repositoryPath: string): Promise<string> {
const result = await this.exec(repositoryPath, ['rev-parse', '--show-toplevel'])
return path.normalize(result.stdout.trim())
let repoRootPath = path.normalize(result.stdout.trim());
if (process.platform === 'win32' && repoRootPath .startsWith('\\') && !process.env.SHELL ) {
repoRootPath = repoRootPath.replace(/^\\([^\\]*)\\/, '$1:\\')
}
return repoRootPath;
}

public async exec(cwd: string, args: string[], options: SpawnOptions = {}): Promise<IExecutionResult<string>> {
Expand Down Expand Up @@ -83,7 +87,9 @@ export default class Git {
options.env = Object.assign({}, process.env, options.env || {}, {
LC_ALL: 'en_US.UTF-8',
LANG: 'en_US.UTF-8'
})
})

options.shell = options.env.SHELL? options.env.SHELL : (process.platform === 'win32' || !!options.shell);

if (options.log !== false) {
this.log(`> git ${args.join(' ')}\n`)
Expand Down

0 comments on commit d7886b0

Please sign in to comment.