commit ae1ac7961a81cc3033f9b652cfec2951585f62d7 Author: Tai Groot Date: Sun Jun 12 12:46:09 2022 -0700 placeholder code in place diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa67075 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +gico diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a8e481 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# GiCo + +Goals: +1. Provide a git post-commit hook binary that allows you to track commit frequency locally + - requires a lock file +1. Save a history locally to a JSON file + - requires a lock file +1. Provide functionality to display the data: + - bubbletea interactive, scrollable graph + - one-shot printed graph for a date range (default 1 year) + - print out commit count + - today + - this week + - this month + - this year +1. Provide an import method to add old repos to history +1. Expose parsing / counting functions to other libraries + +Future: + - possibly use a client-server model to make the execution of the git hook much faster (no need to load, parse, save the file every execution) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..51403b5 --- /dev/null +++ b/go.mod @@ -0,0 +1,27 @@ +module github.com/taigrr/gico + +go 1.18 + +replace github.com/charmbracelet/bubbles => github.com/taigrr/bubbles v0.10.5 + +replace github.com/muesli/termenv => github.com/taigrr/termenv v0.11.2 + +replace github.com/charmbracelet/lipgloss => github.com/taigrr/lipgloss v0.5.1 + +require ( + github.com/charmbracelet/bubbletea v0.20.0 + github.com/charmbracelet/lipgloss v0.5.0 +) + +require ( + github.com/containerd/console v1.0.3 // indirect + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 // indirect + github.com/muesli/reflow v0.3.0 // indirect + github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect + github.com/rivo/uniseg v0.2.0 // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..266bcbd --- /dev/null +++ b/go.sum @@ -0,0 +1,33 @@ +github.com/charmbracelet/bubbletea v0.20.0 h1:/b8LEPgCbNr7WWZ2LuE/BV1/r4t5PyYJtDb+J3vpwxc= +github.com/charmbracelet/bubbletea v0.20.0/go.mod h1:zpkze1Rioo4rJELjRyGlm9T2YNou1Fm4LIJQSa5QMEM= +github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= +github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= +github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= +github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= +github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho= +github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 h1:kMlmsLSbjkikxQJ1IPwaM+7LJ9ltFu/fi8CRzvSnQmA= +github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho= +github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ= +github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= +github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= +github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/taigrr/lipgloss v0.5.1 h1:lzmrLEzXyR/AOP/zGPPuIlmNuBKX81F3gHqn3/8e+bc= +github.com/taigrr/lipgloss v0.5.1/go.mod h1:EZLha/HbzEt7cYqdFPovlqy5FZPj0xFhg5SaqxScmgs= +github.com/taigrr/termenv v0.11.2 h1:oqZR08HjGIzFWml4ROmoFvWi3KRG4UZYTPRrI9/lrPA= +github.com/taigrr/termenv v0.11.2/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20210422114643-f5beecf764ed/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8= +golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/main.go b/main.go new file mode 100644 index 0000000..5d401f5 --- /dev/null +++ b/main.go @@ -0,0 +1,82 @@ +package main + +import ( + "flag" + "fmt" + "os" + "time" +) + +type Month string + +var months = []Month{"Jan", "Feb", "Mar", + "Apr", "May", "Jun", + "Jul", "Aug", "Sep", + "Oct", "Nov", "Dec"} + +var days [366]int + +func init() { + // parse configs + // choose action from CLI +} + +func main() { + flag.Parse() + args := flag.Args() + if len(args) < 1 { + printGraph() + os.Exit(0) + } + switch args[0] { + case "inc", "increment", "add": + increment() + case "graph": + printGraph() + case "interactive": + interactiveGraph() + case "loadRepo": + loadRepo() + default: + printHelp() + } +} + +type Commit struct { + LOC int `json:"loc"` + Message string `json:"message"` + TimeStamp time.Time `json:"ts"` + Author string `json:"author"` +} + +type DataSet map[time.Time]WorkDay + +type WorkDay struct { + Day time.Time `json:"day"` + Count int `json:"count"` + Message string `json:"message,omitempty"` + Commits []Commit `json:"commits,omitempty"` +} + +func loadRepo() { + +} + +func readCommitDB() DataSet { + ds := DataSet{} + ds = append(ds, + return ds +} +func printHelp() { + fmt.Println("help:") +} + +func increment() { + commits := readCommitDB() + + fmt.Printf("%v\n", commits) +} + +func printGraph() { + fmt.Println("printGraph") +}