1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-04-15 11:56:56 +02:00
Carlos Alexandro Becker 87d269dc45 refactor: turned changelog generation into a pipe
I turned myself into a pipe morty!

PipeRick!!!

refs #284
2017-10-18 09:19:36 -02:00

30 lines
735 B
Go

// Package git provides an integration with the git command
package git
import (
"errors"
"os/exec"
"strings"
)
// IsRepo returns true if current folder is a git repository
func IsRepo() bool {
out, err := Run("rev-parse", "--is-inside-work-tree")
return err == nil && strings.TrimSpace(out) == "true"
}
// Run runs a git command and returns its output or errors
func Run(args ...string) (output string, err error) {
var cmd = exec.Command("git", args...)
bts, err := cmd.CombinedOutput()
if err != nil {
return "", errors.New(string(bts))
}
return string(bts), err
}
// Clean the output
func Clean(output string, err error) (string, error) {
return strings.Replace(strings.Split(output, "\n")[0], "'", "", -1), err
}