mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-06 17:40:58 +00:00
Add variadic version of hashFiles (#411)
This commit is contained in:
parent
3dbfe0ed90
commit
4b00c2754d
2 changed files with 10 additions and 5 deletions
|
@ -236,11 +236,15 @@ func vmFromJSON(vm *otto.Otto) {
|
|||
|
||||
func (rc *RunContext) vmHashFiles() func(*otto.Otto) {
|
||||
return func(vm *otto.Otto) {
|
||||
_ = vm.Set("hashFiles", func(path string) string {
|
||||
files, _, err := glob.Glob([]string{filepath.Join(rc.Config.Workdir, path)})
|
||||
if err != nil {
|
||||
logrus.Errorf("Unable to glob.Glob: %v", err)
|
||||
return ""
|
||||
_ = vm.Set("hashFiles", func(paths ...string) string {
|
||||
files := []*glob.FileAsset{}
|
||||
for i := range paths {
|
||||
newFiles, _, err := glob.Glob([]string{filepath.Join(rc.Config.Workdir, paths[i])})
|
||||
if err != nil {
|
||||
logrus.Errorf("Unable to glob.Glob: %v", err)
|
||||
return ""
|
||||
}
|
||||
files = append(files, newFiles...)
|
||||
}
|
||||
hasher := sha256.New()
|
||||
for _, file := range files {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue