@@ -6,18 +6,19 @@ import gitHttpClient from 'isomorphic-git/http/node';
66const dir = './.remote' ;
77
88const exec = async ( req : any , action : Action ) : Promise < Action > => {
9+ console . log ( 'TIME: pullRemoteStart' ) ;
10+ const startTime = Date . now ( ) ;
911 const step = new Step ( 'pullRemote' ) ;
1012
1113 try {
12- action . proxyGitPath = `${ dir } /${ action . timestamp } ` ;
13-
14- step . log ( `Creating folder ${ action . proxyGitPath } ` ) ;
14+ action . proxyGitPath = `${ dir } /${ action . id } ` ;
1515
1616 if ( ! fs . existsSync ( dir ) ) {
1717 fs . mkdirSync ( dir ) ;
1818 }
1919
2020 if ( ! fs . existsSync ( action . proxyGitPath ) ) {
21+ step . log ( `Creating folder ${ action . proxyGitPath } ` ) ;
2122 fs . mkdirSync ( action . proxyGitPath , 0o755 ) ;
2223 }
2324
@@ -29,18 +30,31 @@ const exec = async (req: any, action: Action): Promise<Action> => {
2930 . toString ( )
3031 . split ( ':' ) ;
3132
32- await git . clone ( {
33- fs,
34- http : gitHttpClient ,
35- url : action . url ,
36- onAuth : ( ) => ( {
37- username,
38- password,
39- } ) ,
40- dir : `${ action . proxyGitPath } /${ action . repoName } ` ,
41- } ) ;
33+ if ( ! fs . existsSync ( `${ action . proxyGitPath } /${ action . repoName } ` ) ) {
34+ console . log ( 'Clone: ' , action . url ) ;
35+ await git . clone ( {
36+ fs,
37+ http : gitHttpClient ,
38+ url : action . url ,
39+ dir : `${ action . proxyGitPath } /${ action . repoName } ` ,
40+ onAuth : ( ) => ( { username, password } ) ,
41+ singleBranch : true ,
42+ depth : 1 ,
43+ } ) ;
44+ } else {
45+ console . log ( 'Fetch: ' , action . url ) ;
46+ await git . fetch ( {
47+ fs,
48+ http : gitHttpClient ,
49+ url : action . url ,
50+ dir : `${ action . proxyGitPath } /${ action . repoName } ` ,
51+ onAuth : ( ) => ( { username, password } ) ,
52+ singleBranch : true ,
53+ depth : 1 ,
54+ } ) ;
55+ }
4256
43- console . log ( 'Clone Success: ' , action . url ) ;
57+ console . log ( 'Clone/Fetch Success: ' , action . url ) ;
4458
4559 step . log ( `Completed ${ cmd } ` ) ;
4660 step . setContent ( `Completed ${ cmd } ` ) ;
@@ -50,6 +64,9 @@ const exec = async (req: any, action: Action): Promise<Action> => {
5064 } finally {
5165 action . addStep ( step ) ;
5266 }
67+ const endTime = Date . now ( ) ;
68+ const duration = endTime - startTime ;
69+ console . log ( `TIME: pullRemote completed in ${ duration } ms` ) ;
5370 return action ;
5471} ;
5572
0 commit comments