File tree 2 files changed +57
-5
lines changed
2 files changed +57
-5
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ export function parse(params: ParseParams): any {
140
140
// add level step commits
141
141
const { steps, ...configLevelProps } = configLevel ;
142
142
level = { ...configLevelProps , ...level } ;
143
+
143
144
if ( steps ) {
144
145
steps . forEach ( ( step : T . Step , index : number ) => {
145
146
try {
@@ -151,12 +152,14 @@ export function parse(params: ParseParams): any {
151
152
} ;
152
153
153
154
const stepSetupKey = `${ step . id } :T` ;
155
+
156
+ if ( ! step ?. setup ) {
157
+ step . setup = { } ;
158
+ }
159
+ if ( ! step . setup . commits ) {
160
+ step . setup . commits = [ ] ;
161
+ }
154
162
if ( params . commits [ stepSetupKey ] ) {
155
- if ( ! step . setup ) {
156
- step . setup = {
157
- commits : [ ] ,
158
- } ;
159
- }
160
163
step . setup . commits = params . commits [ stepSetupKey ] ;
161
164
}
162
165
Original file line number Diff line number Diff line change @@ -786,6 +786,55 @@ The first step
786
786
} ;
787
787
expect ( result . levels ) . toEqual ( expected . levels ) ;
788
788
} ) ;
789
+ it ( "should load no commits if none found for a step" , ( ) => {
790
+ const md = `# Title
791
+
792
+ Description.
793
+
794
+ ## 1. Title
795
+
796
+ First line
797
+
798
+ ### 1.1
799
+
800
+ The first step
801
+ ` ;
802
+ const skeleton = {
803
+ levels : [
804
+ {
805
+ id : "1" ,
806
+ steps : [ { id : "1" } ] ,
807
+ } ,
808
+ ] ,
809
+ } ;
810
+ const result = parse ( {
811
+ text : md ,
812
+ skeleton,
813
+ commits : { } ,
814
+ } ) ;
815
+ const expected = {
816
+ summary : {
817
+ description : "Description." ,
818
+ } ,
819
+ levels : [
820
+ {
821
+ id : "1" ,
822
+ summary : "First line" ,
823
+ content : "First line" ,
824
+ steps : [
825
+ {
826
+ id : "1.1" ,
827
+ content : "The first step" ,
828
+ setup : {
829
+ commits : [ ] ,
830
+ } ,
831
+ } ,
832
+ ] ,
833
+ } ,
834
+ ] ,
835
+ } ;
836
+ expect ( result . levels [ 0 ] . steps [ 0 ] ) . toEqual ( expected . levels [ 0 ] . steps [ 0 ] ) ;
837
+ } ) ;
789
838
} ) ;
790
839
791
840
describe ( "config" , ( ) => {
You can’t perform that action at this time.
0 commit comments