2025-01-05 07:35:12 +01:00

30 lines
488 B
Go

package roast
import (
"os/exec"
"strings"
)
func (r *Roast) CurrentBranchName() (string, bool) {
head, err := r.repo.Head()
if err != nil {
return "", false
}
return head.Name().Short(), true
}
var gitusername string
func GitUserName() string {
if len(gitusername) != 0 {
return gitusername
}
if out, err := exec.Command("git", "config", "user.name").Output(); err != nil {
return ""
} else {
gitusername = strings.TrimSpace(string(out))
return gitusername
}
}