30 lines
488 B
Go
Raw Normal View History

2025-01-05 06:30:54 +01:00
package roast
2025-01-05 07:35:12 +01:00
import (
"os/exec"
"strings"
)
2025-01-05 06:30:54 +01:00
func (r *Roast) CurrentBranchName() (string, bool) {
head, err := r.repo.Head()
if err != nil {
return "", false
}
return head.Name().Short(), true
}
2025-01-05 07:35:12 +01:00
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
}
}