1- const Step = require ( '../../actions' ) . Step ;
2- const simpleGit = require ( 'simple-git' )
1+ import { Action , Step } from '../../actions' ;
2+ import simpleGit from 'simple-git' ;
33
4-
5- const exec = async ( req , action ) => {
4+ const exec = async ( req : any , action : Action ) : Promise < Action > => {
65 const step = new Step ( 'diff' ) ;
76
87 try {
@@ -11,6 +10,10 @@ const exec = async (req, action) => {
1110 // https://stackoverflow.com/questions/40883798/how-to-get-git-diff-of-the-first-commit
1211 let commitFrom = `4b825dc642cb6eb9a060e54bf8d69288fbee4904` ;
1312
13+ if ( ! action . commitData ) {
14+ throw new Error ( 'No commit data found' ) ;
15+ }
16+
1417 if ( action . commitFrom === '0000000000000000000000000000000000000000' ) {
1518 if ( action . commitData [ 0 ] . parent !== '0000000000000000000000000000000000000000' ) {
1619 commitFrom = `${ action . commitData [ action . commitData . length - 1 ] . parent } ` ;
@@ -24,7 +27,7 @@ const exec = async (req, action) => {
2427 const diff = await git . diff ( [ revisionRange ] ) ;
2528 step . log ( diff ) ;
2629 step . setContent ( diff ) ;
27- } catch ( e ) {
30+ } catch ( e : any ) {
2831 step . setError ( e . toString ( 'utf-8' ) ) ;
2932 } finally {
3033 action . addStep ( step ) ;
@@ -33,4 +36,5 @@ const exec = async (req, action) => {
3336} ;
3437
3538exec . displayName = 'getDiff.exec' ;
36- exports . exec = exec ;
39+
40+ export { exec } ;
0 commit comments