Exemplo n.º 1
0
func validate(c *cli.Context) {
	if err := common.ExactArgs(c, 1); err != nil {
		common.OSErrf(err.Error())
		return
	}

	// imageName := c.Args().First()
}
Exemplo n.º 2
0
func copr(c *cli.Context) {
	cliArgs := c.Args()
	if err := common.ExactArgs(c, 1); err != nil {
		common.OSErrf(err.Error())
		return
	}

	repoPath, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
	if err != nil {
		common.OSErrf(err.Error())
		return
	}
	repo := path.Base(strings.Trim(string(repoPath), "\n"))
	var fetchAll string
	if !c.Bool("skip-fetch-all") {
		fetchAll = "git fetch --all"
	}

	argParts := strings.Split(cliArgs[0], ":")
	args := map[string]string{
		"User":     argParts[0],
		"Repo":     repo,
		"Branch":   argParts[1],
		"Base":     strings.Replace(c.String("base"), ":", "/", -1),
		"FetchAll": fetchAll,
		"Host":     c.String("host"),
	}
	bashScript, err := util.FormatOutput(args, coprcmd)
	if err != nil {
		common.OSErrf(err.Error())
		return
	}

	if c.Bool("dry-run") {
		fmt.Println("execute the following bash script:")
		fmt.Println(bashScript)
		return
	}

	cmd := exec.Command("bash", "-c", bashScript)
	cmd.Stderr = os.Stderr
	cmd.Stdout = os.Stdout
	err = cmd.Run()
	if err != nil {
		common.OSErrf(err.Error())
		return
	}
}