@ -1,7 +1,7 @@
'use strict' ;
'use strict' ;
import * as fs from 'fs' ;
import * as os from 'os' ;
import * as paths from 'path' ;
import { readdir , realpath , stat , Stats } from 'fs' ;
import { hostname , userInfo } from 'os' ;
import { dirname , relative , resolve as resolvePath } from 'path' ;
import {
import {
Disposable ,
Disposable ,
env ,
env ,
@ -100,7 +100,7 @@ import {
GitDocumentState ,
GitDocumentState ,
TrackedDocument ,
TrackedDocument ,
} from '../../../trackers/gitDocumentTracker' ;
} from '../../../trackers/gitDocumentTracker' ;
import { Git , GitErrors , isFolderGlob , maxGitCliLength } from './git' ;
import { Git , GitErrors , maxGitCliLength } from './git' ;
import { findGitPath , GitLocation , InvalidGitConfigError , UnableToFindGitError } from './locator' ;
import { findGitPath , GitLocation , InvalidGitConfigError , UnableToFindGitError } from './locator' ;
import { fsExists , RunError } from './shell' ;
import { fsExists , RunError } from './shell' ;
@ -393,7 +393,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
}
for ( let p of repoPaths ) {
for ( let p of repoPaths ) {
p = paths . dirname( p ) ;
p = dirname ( p ) ;
// If we are the same as the root, skip it
// If we are the same as the root, skip it
if ( Strings . normalizePath ( p ) === rootPath ) continue ;
if ( Strings . normalizePath ( p ) === rootPath ) continue ;
@ -420,7 +420,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const cc = Logger . getCorrelationContext ( ) ;
const cc = Logger . getCorrelationContext ( ) ;
return new Promise < string [ ] > ( ( resolve , reject ) = > {
return new Promise < string [ ] > ( ( resolve , reject ) = > {
fs . readdir( root , { withFileTypes : true } , async ( err , files ) = > {
readdir ( root , { withFileTypes : true } , async ( err , files ) = > {
if ( err != null ) {
if ( err != null ) {
reject ( err ) ;
reject ( err ) ;
return ;
return ;
@ -438,10 +438,10 @@ export class LocalGitProvider implements GitProvider, Disposable {
if ( ! f . isDirectory ( ) ) continue ;
if ( ! f . isDirectory ( ) ) continue ;
if ( f . name === '.git' ) {
if ( f . name === '.git' ) {
repositories . push ( paths . resolve( root , f . name ) ) ;
repositories . push ( resolvePath ( root , f . name ) ) ;
} else if ( depth >= 0 && excludes [ f . name ] !== true ) {
} else if ( depth >= 0 && excludes [ f . name ] !== true ) {
try {
try {
await this . repositorySearchCore ( paths . resolve( root , f . name ) , depth , excludes , repositories ) ;
await this . repositorySearchCore ( resolvePath ( root , f . name ) , depth , excludes , repositories ) ;
} catch ( ex ) {
} catch ( ex ) {
Logger . error ( ex , cc , 'FAILED' ) ;
Logger . error ( ex , cc , 'FAILED' ) ;
}
}
@ -1299,7 +1299,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
} while ( true ) ;
} while ( true ) ;
} else {
} else {
user . name =
user . name =
process . env . GIT_AUTHOR_NAME || process . env . GIT_COMMITTER_NAME || os . userInfo( ) ? . username || undefined ;
process . env . GIT_AUTHOR_NAME || process . env . GIT_COMMITTER_NAME || userInfo ( ) ? . username || undefined ;
if ( ! user . name ) {
if ( ! user . name ) {
// If we found no user data, mark it so we won't bother trying again
// If we found no user data, mark it so we won't bother trying again
this . _userMapCache . set ( repoPath , null ) ;
this . _userMapCache . set ( repoPath , null ) ;
@ -1310,7 +1310,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
process . env . GIT_AUTHOR_EMAIL ||
process . env . GIT_AUTHOR_EMAIL ||
process . env . GIT_COMMITTER_EMAIL ||
process . env . GIT_COMMITTER_EMAIL ||
process . env . EMAIL ||
process . env . EMAIL ||
` ${ user . name } @ ${ os . hostname( ) } ` ;
` ${ user . name } @ ${ hostname ( ) } ` ;
}
}
const author = ` ${ user . name } < ${ user . email } > ` ;
const author = ` ${ user . name } < ${ user . email } > ` ;
@ -2130,7 +2130,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const log = GitLogParser . parse (
const log = GitLogParser . parse (
data ,
data ,
// If this is the log of a folder, parse it as a normal log rather than a file log
// If this is the log of a folder, parse it as a normal log rather than a file log
isFolderGlob ( file ) ? GitCommitType.Log : GitCommitType.LogFile ,
Paths . isFolderGlob( file ) ? GitCommitType.Log : GitCommitType.LogFile ,
root ,
root ,
file ,
file ,
ref ,
ref ,
@ -3056,10 +3056,10 @@ export class LocalGitProvider implements GitProvider, Disposable {
if ( isDirectory ) {
if ( isDirectory ) {
path = filePath ;
path = filePath ;
} else {
} else {
const stat = await new Promise < fs. Stats | undefined > ( resolve = >
fs . stat( filePath , ( err , stat ) = > resolve ( err == null ? stat : undefined ) ) ,
const stats = await new Promise < Stats | undefined > ( resolve = >
stat ( filePath , ( err , stats ) = > resolve ( err == null ? stats : undefined ) ) ,
) ;
) ;
path = stat ? . isDirectory ( ) ? filePath : paths. dirname( filePath ) ;
path = stats ? . isDirectory ( ) ? filePath : dirname ( filePath ) ;
}
}
repoPath = await Git . rev_parse__show_toplevel ( path ) ;
repoPath = await Git . rev_parse__show_toplevel ( path ) ;
@ -3078,7 +3078,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
try {
try {
const networkPath = await new Promise < string | undefined > ( resolve = >
const networkPath = await new Promise < string | undefined > ( resolve = >
fs . realpath. native ( ` ${ letter } : \\ ` , { encoding : 'utf8' } , ( err , resolvedPath ) = >
realpath . native ( ` ${ letter } : \\ ` , { encoding : 'utf8' } , ( err , resolvedPath ) = >
resolve ( err != null ? undefined : resolvedPath ) ,
resolve ( err != null ? undefined : resolvedPath ) ,
) ,
) ,
) ;
) ;
@ -3103,7 +3103,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
// If we are not on Windows (symlinks don't seem to have the same issue on Windows), check if we are a symlink and if so, use the symlink path (not its resolved path)
// If we are not on Windows (symlinks don't seem to have the same issue on Windows), check if we are a symlink and if so, use the symlink path (not its resolved path)
// This is because VS Code will provide document Uris using the symlinked path
// This is because VS Code will provide document Uris using the symlinked path
repoPath = await new Promise < string | undefined > ( resolve = > {
repoPath = await new Promise < string | undefined > ( resolve = > {
fs . realpath( path , { encoding : 'utf8' } , ( err , resolvedPath ) = > {
realpath ( path , { encoding : 'utf8' } , ( err , resolvedPath ) = > {
if ( err != null ) {
if ( err != null ) {
Logger . debug ( cc , ` fs.realpath failed; repoPath= ${ repoPath } ` ) ;
Logger . debug ( cc , ` fs.realpath failed; repoPath= ${ repoPath } ` ) ;
resolve ( repoPath ) ;
resolve ( repoPath ) ;
@ -3616,7 +3616,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const fileName =
const fileName =
typeof fileNameOrUri === 'string'
typeof fileNameOrUri === 'string'
? fileNameOrUri
? fileNameOrUri
: Strings . normalizePath ( paths . relative( repoPath , fileNameOrUri . fsPath ) ) ;
: Strings . normalizePath ( relative ( repoPath , fileNameOrUri . fsPath ) ) ;
const blob = await Git . rev_parse__verify ( repoPath , ref , fileName ) ;
const blob = await Git . rev_parse__verify ( repoPath , ref , fileName ) ;
if ( blob == null ) return GitRevision . deletedOrMissing ;
if ( blob == null ) return GitRevision . deletedOrMissing ;