func gitCmd(args ...string) *cmd.Cmd { cmd := cmd.New("git") for _, v := range GlobalFlags { cmd.WithArg(v) } for _, a := range args { cmd.WithArg(a) } return cmd }
func Run(command string, args ...string) error { cmd := cmd.New("git") for _, v := range GlobalFlags { cmd.WithArg(v) } cmd.WithArg(command) for _, a := range args { cmd.WithArg(a) } return cmd.Run() }
func Show(sha string) (string, error) { cmd := cmd.New("git") cmd.WithArg("show").WithArg("-s").WithArg("--format=%s%n%+b").WithArg(sha) output, err := cmd.CombinedOutput() output = strings.TrimSpace(output) return output, err }
func gitOutput(input ...string) (outputs []string, err error) { cmd := cmd.New("git") for _, v := range GlobalFlags { cmd.WithArg(v) } for _, i := range input { cmd.WithArg(i) } out, err := cmd.CombinedOutput() for _, line := range strings.Split(out, "\n") { line = strings.TrimSpace(line) if line != "" { outputs = append(outputs, string(line)) } } return outputs, err }