Пример #1
0
Файл: git.go Проект: jingweno/gh
func Spawn(command string, args ...string) error {
	cmd := cmd.New("git")
	cmd.WithArg(command)
	for _, a := range args {
		cmd.WithArg(a)
	}

	return cmd.Exec()
}
Пример #2
0
func Spawn(command string, args ...string) error {
	cmd := cmd.New("git")
	cmd.WithArg(command)
	for _, a := range args {
		cmd.WithArg(a)
	}

	out, err := cmd.ExecOutput()
	if err != nil {
		return errors.New(out)
	}

	return nil
}
Пример #3
0
Файл: git.go Проект: jingweno/gh
func Show(sha string) (string, error) {
	cmd := cmd.New("git")
	cmd.WithArg("show").WithArg("-s").WithArg("--format=%w(78,0,0)%s%n%+b").WithArg(sha)

	output, err := cmd.ExecOutput()
	output = strings.TrimSpace(output)

	return output, err
}
Пример #4
0
func execGitCmd(input ...string) (outputs []string, err error) {
	cmd := cmd.New("git")
	for _, i := range input {
		cmd.WithArg(i)
	}

	out, err := cmd.ExecOutput()
	for _, line := range strings.Split(out, "\n") {
		outputs = append(outputs, string(line))
	}

	return outputs, err
}