当前位置: 首页>>代码示例>>Golang>>正文


Golang Project.GetModuleByName方法代码示例

本文整理汇总了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
}
开发者ID:tychoish,项目名称:evergreen,代码行数:34,代码来源:fetch.go

示例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
}
开发者ID:tychoish,项目名称:evergreen,代码行数:39,代码来源:fetch.go


注:本文中的github.com/evergreen-ci/evergreen/model.Project.GetModuleByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。