@@ -11,6 +11,7 @@ import * as fs from 'graceful-fs';
11
11
import { NamedPackageDir , Logger , SfError } from '@salesforce/core' ;
12
12
import { env } from '@salesforce/kit' ;
13
13
import * as git from 'isomorphic-git' ;
14
+ import { Performance } from '@oclif/core' ;
14
15
import { chunkArray , isLwcLocalOnlyTest , pathIsInFolder } from './functions' ;
15
16
16
17
/** returns the full path to where we store the shadow repo */
@@ -105,6 +106,7 @@ export class ShadowRepo {
105
106
*
106
107
*/
107
108
public async gitInit ( ) : Promise < void > {
109
+ this . logger . trace ( `initializing git repo at ${ this . gitDir } ` ) ;
108
110
await fs . promises . mkdir ( this . gitDir , { recursive : true } ) ;
109
111
try {
110
112
await git . init ( { fs, dir : this . projectPath , gitdir : this . gitDir , defaultBranch : 'main' } ) ;
@@ -135,7 +137,10 @@ export class ShadowRepo {
135
137
* @returns StatusRow[]
136
138
*/
137
139
public async getStatus ( noCache = false ) : Promise < StatusRow [ ] > {
140
+ this . logger . trace ( `start: getStatus (noCache = ${ noCache } )` ) ;
141
+
138
142
if ( ! this . status || noCache ) {
143
+ const marker = Performance . mark ( '@salesforce/source-tracking' , 'localShadowRepo.getStatus#withoutCache' ) ;
139
144
// iso-git uses relative, posix paths
140
145
// but packageDirs has already resolved / normalized them
141
146
// so we need to make them project-relative again and convert if windows
@@ -168,7 +173,9 @@ export class ShadowRepo {
168
173
if ( this . isWindows ) {
169
174
this . status = this . status . map ( ( row ) => [ path . normalize ( row [ FILE ] ) , row [ HEAD ] , row [ WORKDIR ] , row [ 3 ] ] ) ;
170
175
}
176
+ marker ?. stop ( ) ;
171
177
}
178
+ this . logger . trace ( `done: getStatus (noCache = ${ noCache } )` ) ;
172
179
return this . status ;
173
180
}
174
181
@@ -247,16 +254,23 @@ export class ShadowRepo {
247
254
return 'no files to commit' ;
248
255
}
249
256
257
+ const marker = Performance . mark ( '@salesforce/source-tracking' , 'localShadowRepo.commitChanges' , {
258
+ deployedFiles : deployedFiles . length ,
259
+ deletedFiles : deletedFiles . length ,
260
+ } ) ;
250
261
// these are stored in posix/style/path format. We have to convert inbound stuff from windows
251
262
if ( os . type ( ) === 'Windows_NT' ) {
263
+ this . logger . trace ( 'start: transforming windows paths to posix' ) ;
252
264
deployedFiles = deployedFiles . map ( ( filepath ) => path . normalize ( filepath ) . split ( path . sep ) . join ( path . posix . sep ) ) ;
253
265
deletedFiles = deletedFiles . map ( ( filepath ) => path . normalize ( filepath ) . split ( path . sep ) . join ( path . posix . sep ) ) ;
266
+ this . logger . trace ( 'done: transforming windows paths to posix' ) ;
254
267
}
255
268
256
269
if ( deployedFiles . length ) {
257
270
const chunks = chunkArray ( [ ...new Set ( deployedFiles ) ] , this . maxFileAdd ) ;
258
271
for ( const chunk of chunks ) {
259
272
try {
273
+ this . logger . debug ( `adding ${ chunk . length } files of ${ deployedFiles . length } deployedFiles to git` ) ;
260
274
// these need to be done sequentially (it's already batched) because isogit manages file locking
261
275
// eslint-disable-next-line no-await-in-loop
262
276
await git . add ( {
@@ -296,6 +310,8 @@ export class ShadowRepo {
296
310
}
297
311
298
312
try {
313
+ this . logger . trace ( 'start: commitChanges git.commit' ) ;
314
+
299
315
const sha = await git . commit ( {
300
316
fs,
301
317
dir : this . projectPath ,
@@ -307,9 +323,11 @@ export class ShadowRepo {
307
323
if ( needsUpdatedStatus ) {
308
324
await this . getStatus ( true ) ;
309
325
}
326
+ this . logger . trace ( 'done: commitChanges git.commit' ) ;
310
327
return sha ;
311
328
} catch ( e ) {
312
329
redirectToCliRepoError ( e as Error ) ;
313
330
}
331
+ marker ?. stop ( ) ;
314
332
}
315
333
}
0 commit comments