本文整理匯總了Golang中github.com/evergreen-ci/evergreen/model.Project.GetModuleByName方法的典型用法代碼示例。如果您正苦於以下問題:Golang Project.GetModuleByName方法的具體用法?Golang Project.GetModuleByName怎麽用?Golang Project.GetModuleByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/evergreen-ci/evergreen/model.Project
的用法示例。
在下文中一共展示了Project.GetModuleByName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: applyPatch
func applyPatch(patch *service.RestPatch, rootCloneDir string, conf *model.Project, variant *model.BuildVariant) error {
// patch sets and contain multiple patches, some of them for modules
for _, patchPart := range patch.Patches {
var dir string
if patchPart.ModuleName == "" {
// if patch is not part of a module, just apply patch against src root
dir = rootCloneDir
} else {
fmt.Println("Applying patches for module", patchPart.ModuleName)
// if patch is part of a module, apply patch in module root
module, err := conf.GetModuleByName(patchPart.ModuleName)
if err != nil || module == nil {
return fmt.Errorf("can't find module %v: %v", patchPart.ModuleName, err)
}
// skip the module if this build variant does not use it
if !util.SliceContains(variant.Modules, module.Name) {
continue
}
dir = filepath.Join(rootCloneDir, module.Prefix, module.Name)
}
args := []string{"apply", "--whitespace=fix"}
applyCmd := exec.Command("git", args...)
applyCmd.Stdout, applyCmd.Stderr, applyCmd.Dir = os.Stdout, os.Stderr, dir
applyCmd.Stdin = bytes.NewReader([]byte(patchPart.PatchSet.Patch))
err := applyCmd.Run()
if err != nil {
return err
}
}
return nil
}
示例2: cloneSource
func cloneSource(task *service.RestTask, project *model.ProjectRef, config *model.Project, cloneDir string) error {
// Fetch the outermost repo for the task
err := clone(
cloneOptions{
repo: fmt.Sprintf("[email protected]:%v/%v.git", project.Owner, project.Repo),
revision: task.Revision,
rootDir: cloneDir,
depth: defaultCloneDepth,
},
false,
)
if err != nil {
return err
}
// Then fetch each of the modules
variant := config.FindBuildVariant(task.BuildVariant)
if variant == nil {
return fmt.Errorf("couldn't find build variant '%v' in config", task.BuildVariant)
}
for _, moduleName := range variant.Modules {
module, err := config.GetModuleByName(moduleName)
if err != nil || module == nil {
return fmt.Errorf("variant refers to a module '%v' that doesn't exist.", moduleName)
}
moduleBase := filepath.Join(cloneDir, module.Prefix, module.Name)
fmt.Printf("Fetching module %v at %v\n", moduleName, module.Branch)
err = clone(cloneOptions{
repo: module.Repo,
revision: module.Branch,
rootDir: filepath.ToSlash(moduleBase),
}, false)
if err != nil {
return err
}
}
return nil
}