error out properly when gitfetch can't find a repo

This commit is contained in:
2022-06-19 16:20:51 -06:00
parent bfd6ae92b8
commit b25af96bcc

View File

@@ -1,7 +1,8 @@
package main package main
import ( import (
"log" "fmt"
"os"
"time" "time"
git "github.com/go-git/go-git/v5" git "github.com/go-git/go-git/v5"
@@ -14,9 +15,10 @@ type DataSet map[time.Time]gico.WorkDay
func main() { func main() {
r, err := git.PlainOpen(".git") r, err := git.PlainOpenWithOptions(".", &(git.PlainOpenOptions{DetectDotGit: true}))
if err != nil { if err != nil {
log.Printf("%v\n", err) fmt.Printf("gitfetch error: Could not find a git repository to open!\n")
os.Exit(1)
} }
ref, err := r.Head() ref, err := r.Head()
cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) cIter, err := r.Log(&git.LogOptions{From: ref.Hash()})