From 83a4525fa1f438abd7e408b471475b398db9918f Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Fri, 10 Jan 2025 17:08:04 +0300 Subject: [PATCH] chore: add test --- internal/config/load.go | 1 + internal/config/load_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/internal/config/load.go b/internal/config/load.go index 34f0b482..3914d4aa 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -537,6 +537,7 @@ func mergeJobsSlice(src, dest []interface{}) []interface{} { destSubJobs = mergeJobsSlice(srcSubJobs, destSubJobs) } + // Replace possible {cmd} before merging the jobs switch srcRun := srcJob["run"].(type) { case string: switch destRun := destJob["run"].(type) { diff --git a/internal/config/load_test.go b/internal/config/load_test.go index f35e9069..6a60c94c 100644 --- a/internal/config/load_test.go +++ b/internal/config/load_test.go @@ -809,6 +809,36 @@ pre-commit: }, }, }, + "with jobs overwrite": { + files: map[string]string{ + "lefthook.yml": ` +pre-commit: + jobs: + - name: job 1 + run: echo from job 1 +`, + "lefthook-local.yml": ` +pre-commit: + jobs: + - name: job 1 + run: wrap {cmd} +`, + }, + result: &Config{ + SourceDir: ".lefthook", + SourceDirLocal: ".lefthook-local", + Hooks: map[string]*Hook{ + "pre-commit": { + Jobs: []*Job{ + { + Name: "job 1", + Run: "wrap echo from job 1", + }, + }, + }, + }, + }, + }, } { fs := afero.Afero{Fs: afero.NewMemMapFs()} repo := &git.Repository{