From ca16dbb99b991fd08833baddd5ca36465f5c2a50 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sun, 19 Jun 2022 16:39:18 -0600 Subject: [PATCH] preparation for choosing a year at the command line --- bin/gitfetch/gitfetch.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/gitfetch/gitfetch.go b/bin/gitfetch/gitfetch.go index a5e436f..89f1c2a 100644 --- a/bin/gitfetch/gitfetch.go +++ b/bin/gitfetch/gitfetch.go @@ -21,9 +21,7 @@ func main() { ref, err := r.Head() cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) - // year := time.Now().Year() - // yearStart := time.Time{} - // yearStart.AddDate(year, 0, 0) + year := time.Now().Year() data := gico.NewDataSet() err = cIter.ForEach(func(c *object.Commit) error { ts := c.Author.When @@ -40,9 +38,13 @@ func main() { data[roundedTS] = wd return nil }) - freq := [366]int{} + yearLength := 365 + if year%4 == 0 { + yearLength++ + } + freq := make([]int, yearLength) for k, v := range data { - if k.Year() != time.Now().Year() { + if k.Year() != year { continue } // this is equivalent to adding len(commits) to the freq total, but