Browse Source

Fixes #932 - path issues with Git 2.25 on Windows

https://github.com/git-for-windows/git/issues/2478
main
Eric Amodio 5 years ago
parent
commit
aa0df78b21
2 changed files with 9 additions and 1 deletions
  1. +2
    -1
      src/git/git.ts
  2. +7
    -0
      src/system/string.ts

+ 2
- 1
src/git/git.ts View File

@ -1018,7 +1018,8 @@ export namespace Git {
export async function rev_parse__show_toplevel(cwd: string): Promise<string | undefined> {
const data = await git<string>({ cwd: cwd, errors: GitErrorHandling.Ignore }, 'rev-parse', '--show-toplevel');
return data.length === 0 ? undefined : data.trim();
// Make sure to normalize: https://github.com/git-for-windows/git/issues/2478
return data.length === 0 ? undefined : Strings.normalizePath(data.trim());
}
export function shortlog(repoPath: string) {

+ 7
- 0
src/system/string.ts View File

@ -1,5 +1,6 @@
'use strict';
import { createHash, HexBase64Latin1Encoding } from 'crypto';
import { isWindows } from '../git/shell';
const emptyStr = '';
@ -58,6 +59,7 @@ export namespace Strings {
return secs * 1000 + Math.floor(nanosecs / 1000000);
}
const driveLetterNormalizeRegex = /(?<=^\/?)([A-Z])(?=:\/)/;
const pathNormalizeRegex = /\\/g;
const pathStripTrailingSlashRegex = /\/$/g;
const tokenRegex = /\$\{(\W*)?([^|]*?)(?:\|(\d+)(-|\?)?)?(\W*)?\}/g;
@ -149,6 +151,11 @@ export namespace Strings {
normalized = `/${normalized}`;
}
if (isWindows) {
// Ensure that drive casing is normalized (lower case)
normalized = normalized.replace(driveLetterNormalizeRegex, (drive: string) => drive.toLowerCase());
}
return normalized;
}

Loading…
Cancel
Save