all repos — glog @ 90d360c23c40a30bf8b137c991ac16f79577ae5f

Provide config with flags
Tim Izzo tim@5ika.ch
Mon, 21 Apr 2025 18:28:08 +0200
commit

90d360c23c40a30bf8b137c991ac16f79577ae5f

parent

a507639246bfd7d68efd05373e55bf74bd4a963d

2 files changed, 12 insertions(+), 4 deletions(-)

jump to
M git.gogit.go

@@ -29,6 +29,9 @@ defer s.Close()

return repo, err } else if errors.Is(err, fs.ErrNotExist) { + if url == "" { + log.Fatal("No git URL provided") + } log.Info("Clone repo from " + url + " to " + path) repo, err := git.PlainClone(path, false, &git.CloneOptions{ URL: url,
M main.gomain.go

@@ -1,7 +1,10 @@

package main import ( + "flag" "fmt" + + "github.com/charmbracelet/log" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing/object"

@@ -13,11 +16,13 @@ fmt.Printf("%s %s", style.date.Render(c.Author.When.Format(DATE_FORMAT)), c.Message)

} func main() { - url := "ssh://git.5ika.ch:1917/myglog" - path := "/tmp/glog" - repo, err := getRepo(url, path) - CheckIfError(err) + url := flag.String("url", "", "URL of the targeted git repository with logs") + path := flag.String("path", ".", "Path for the local git clone") + flag.Parse() + log.Info("Use " + *url + " cloned in " + *path) + repo, err := getRepo(*url, *path) + CheckIfError(err) ref, err := repo.Head() CheckIfError(err)