// Copyright (c) 2023 Open Anolis Community Distro SIG, all rights reserved. // // Author: Jacob Wang // Xiao Lun // Zhao Hang package directives import ( "path/filepath" "strings" "github.com/go-git/go-git/v5" pkgcrewpb "pkgcrew/pb" "pkgcrew/pkg/data" ) func checkAddPrefix(file string) string { if strings.HasPrefix(file, "SOURCES/") || strings.HasPrefix(file, "SPECS/") { return file } return filepath.Join("SOURCES", file) } func Apply(cfg *pkgcrewpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) []error { var errs []error directives := []func(*pkgcrewpb.Cfg, *data.ProcessData, *data.ModeData, *git.Worktree, *git.Worktree) error{ replace, del, add, specChange, } for _, directive := range directives { err := directive(cfg, pd, md, patchTree, pushTree) if err != nil { errs = append(errs, err) } } if len(errs) > 0 { return errs } return nil }