mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
850c2e14f2
We were checking for a .git folder, which would break in cases where goreleaser is running from a subfolder of a monorepo, for example. Check 529af6f#commitcomment-25011738 Closes #402 #403
25 lines
583 B
Go
25 lines
583 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
|
|
}
|