fix frequency for repo with only one commit

This commit is contained in:
2023-01-25 00:16:40 -08:00
parent 5511fc288d
commit d55a352b7e
2 changed files with 11 additions and 9 deletions

View File

@@ -7,15 +7,16 @@ import (
git "github.com/go-git/go-git/v5" git "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/plumbing/object"
"github.com/taigrr/gico"
gterm "github.com/taigrr/gitgraph/term" gterm "github.com/taigrr/gitgraph/term"
"github.com/taigrr/gico"
) )
func main() { func main() {
GetYear() GetYear()
} }
func GetYear() {
func GetYear() {
r, err := git.PlainOpenWithOptions(".", &(git.PlainOpenOptions{DetectDotGit: true})) r, err := git.PlainOpenWithOptions(".", &(git.PlainOpenOptions{DetectDotGit: true}))
if err != nil { if err != nil {
fmt.Printf("gitfetch error: Could not find a git repository to open!\n") fmt.Printf("gitfetch error: Could not find a git repository to open!\n")
@@ -56,6 +57,5 @@ func GetYear() {
freq[k.YearDay()-1]++ freq[k.YearDay()-1]++
} }
} }
gterm.GetYearUnicode(freq[:]) gterm.GetYearUnicode(freq)
} }

12
gico.go
View File

@@ -1,4 +1,4 @@
package gico package main
import ( import (
"flag" "flag"
@@ -61,20 +61,22 @@ type WorkDay struct {
} }
func NewCommit(Author, Message, Repo, Path string, LOC int) Commit { func NewCommit(Author, Message, Repo, Path string, LOC int) Commit {
ci := Commit{Message: Message, ci := Commit{
Author: Author, LOC: LOC, TimeStamp: time.Now(), Message: Message,
Repo: Repo, Path: Path} Author: Author, LOC: LOC, TimeStamp: time.Now(),
Repo: Repo, Path: Path,
}
return ci return ci
} }
func loadRepo() { func loadRepo() {
} }
func readCommitDB() DataSet { func readCommitDB() DataSet {
ds := DataSet{} ds := DataSet{}
return ds return ds
} }
func printHelp() { func printHelp() {
fmt.Println("help:") fmt.Println("help:")
} }