@@ -7,40 +7,40 @@ import { EMPTY_COMMIT_HASH } from '../constants';
7
7
const exec = async ( req : any , action : Action ) : Promise < Action > => {
8
8
const step = new Step ( 'getMissingData' ) ;
9
9
10
- try {
11
- if ( ! action . commitData ) {
12
- action . commitData = [ ] ;
13
- }
10
+ if ( action . commitData && action . commitData . length > 0 ) {
11
+ console . log ( 'getMissingData' , action ) ;
12
+ return action ;
13
+ }
14
14
15
- if ( action . commitData . length === 0 ) {
16
- console . log ( `commitData not found, fetching missing commits from git...` ) ;
17
- const path = `${ action . proxyGitPath } /${ action . repoName } ` ;
18
- const git = simpleGit ( path ) ;
19
- const log = await git . log ( { from : action . commitFrom , to : action . commitTo } ) ;
20
-
21
- action . commitData = log . all . toReversed ( ) . map ( ( entry , i , array ) => {
22
- const parent = i === 0 ? action . commitFrom : array [ i - 1 ] . hash ;
23
- const timestamp = Math . floor ( new Date ( entry . date ) . getTime ( ) / 1000 ) . toString ( ) ;
24
- return {
25
- message : entry . message || '' ,
26
- committer : entry . author_name || '' ,
27
- tree : entry . hash || '' ,
28
- parent : parent || '0' . repeat ( 40 ) ,
29
- author : entry . author_name || '' ,
30
- authorEmail : entry . author_email || '' ,
31
- commitTimestamp : timestamp ,
32
- }
33
- } ) ;
34
- console . log ( `Updated commitData:` , { commitData : action . commitData } ) ;
15
+ console . log ( `commitData not found, fetching missing commits from git...` ) ;
35
16
36
- if ( action . commitFrom === EMPTY_COMMIT_HASH ) {
37
- action . commitFrom = action . commitData [ action . commitData . length - 1 ] . parent ;
17
+ try {
18
+ const path = `${ action . proxyGitPath } /${ action . repoName } ` ;
19
+ const git = simpleGit ( path ) ;
20
+ const log = await git . log ( { from : action . commitFrom , to : action . commitTo } ) ;
21
+
22
+ action . commitData = log . all . toReversed ( ) . map ( ( entry , i , array ) => {
23
+ const parent = i === 0 ? action . commitFrom : array [ i - 1 ] . hash ;
24
+ const timestamp = Math . floor ( new Date ( entry . date ) . getTime ( ) / 1000 ) . toString ( ) ;
25
+ return {
26
+ message : entry . message || '' ,
27
+ committer : entry . author_name || '' ,
28
+ tree : entry . hash || '' ,
29
+ parent : parent || '0' . repeat ( 40 ) ,
30
+ author : entry . author_name || '' ,
31
+ authorEmail : entry . author_email || '' ,
32
+ commitTimestamp : timestamp ,
38
33
}
39
- const user = action . commitData [ action . commitData . length - 1 ] . committer ;
40
- action . user = user ;
34
+ } ) ;
35
+ console . log ( `Updated commitData:` , { commitData : action . commitData } ) ;
41
36
42
- return await validateUser ( user , action , step ) ;
37
+ if ( action . commitFrom === EMPTY_COMMIT_HASH ) {
38
+ action . commitFrom = action . commitData [ action . commitData . length - 1 ] . parent ;
43
39
}
40
+ const user = action . commitData [ action . commitData . length - 1 ] . committer ;
41
+ action . user = user ;
42
+
43
+ return await validateUser ( user , action , step ) ;
44
44
} catch ( e : any ) {
45
45
step . setError ( e . toString ( 'utf-8' ) ) ;
46
46
} finally {
0 commit comments