File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -537,6 +537,18 @@ func mergeJobsSlice(src, dest []interface{}) []interface{} {
537
537
destSubJobs = mergeJobsSlice (srcSubJobs , destSubJobs )
538
538
}
539
539
540
+ // Replace possible {cmd} before merging the jobs
541
+ switch srcRun := srcJob ["run" ].(type ) {
542
+ case string :
543
+ switch destRun := destJob ["run" ].(type ) {
544
+ case string :
545
+ newRun := strings .ReplaceAll (srcRun , CMD , destRun )
546
+ srcJob ["run" ] = newRun
547
+ default :
548
+ }
549
+ default :
550
+ }
551
+
540
552
maps .Merge (srcJob , destJob )
541
553
542
554
if len (destSubJobs ) != 0 {
Original file line number Diff line number Diff line change @@ -809,6 +809,36 @@ pre-commit:
809
809
},
810
810
},
811
811
},
812
+ "with jobs overwrite" : {
813
+ files : map [string ]string {
814
+ "lefthook.yml" : `
815
+ pre-commit:
816
+ jobs:
817
+ - name: job 1
818
+ run: echo from job 1
819
+ ` ,
820
+ "lefthook-local.yml" : `
821
+ pre-commit:
822
+ jobs:
823
+ - name: job 1
824
+ run: wrap {cmd}
825
+ ` ,
826
+ },
827
+ result : & Config {
828
+ SourceDir : ".lefthook" ,
829
+ SourceDirLocal : ".lefthook-local" ,
830
+ Hooks : map [string ]* Hook {
831
+ "pre-commit" : {
832
+ Jobs : []* Job {
833
+ {
834
+ Name : "job 1" ,
835
+ Run : "wrap echo from job 1" ,
836
+ },
837
+ },
838
+ },
839
+ },
840
+ },
841
+ },
812
842
} {
813
843
fs := afero.Afero {Fs : afero .NewMemMapFs ()}
814
844
repo := & git.Repository {
You can’t perform that action at this time.
0 commit comments