Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Jan 10, 2025
1 parent 4e78309 commit 83a4525
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
30 changes: 30 additions & 0 deletions internal/config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 83a4525

Please sign in to comment.