commit bd531004ef2d72e6347b0443e7aa587394032003
Author: Simon Watson <spesk@pm.me>
Date: Tue Dec 5 16:28:24 2023 -0500
Handle the case where there is no git dir without panic
diff --git a/pest.go b/pest.go
index 30f990e..e889e34 100644
--- a/pest.go
+++ b/pest.go
@@ -90,7 +90,8 @@ func parseTomlFromFile(filePath string) (PestConfig, error) {
func gitGetHead(filePath string) (string, string) {
gitObj, err := git.PlainOpen(filePath)
if err != nil {
- panic(err)
+ // Likely not a git dir, return empty
+ return "", ""
}
headRef, err := gitObj.Head()
@@ -209,7 +210,7 @@ func assemble_prompt(config *PestConfig) {
func main() {
- toml, err := parseTomlFromFile("./pest.cfg")
+ toml, err := parseTomlFromFile("/home/swatson/Repos/go-pest/pest.cfg")
if err != nil {
fmt.Println("Couldn't parse TOML const!")
}