From 2be20429bd635af26e012daad5f90a787e1cc935 Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Fri, 12 Jun 2020 00:52:45 -0400 Subject: [PATCH 01/11] started working on a check for .gitignore files --- pkg/comments/comments.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/comments/comments.go b/pkg/comments/comments.go index 204c025..f98c353 100644 --- a/pkg/comments/comments.go +++ b/pkg/comments/comments.go @@ -75,12 +75,16 @@ func SearchDir(dirPath string, cb func(comment *Comment)) error { pathComponents := strings.Split(localPath, string(os.PathSeparator)) // let's ignore git directories TODO: figure out a more generic way to set ignores matched, err := filepath.Match(".git", pathComponents[0]) + ignore, err := filepath.Match(".gitignore", pathComponents[0]) if err != nil { return err } if matched { return nil } + if ignore { + return nil + } if de.IsRegular() { p, err := filepath.Abs(path) if err != nil { From 474091f1f18bc60435fed24bd19db237a5dfc77a Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Mon, 15 Jun 2020 13:15:19 -0400 Subject: [PATCH 02/11] added a new parameter to NewToDo --- cmd/commands/todos.go | 4 +++- pkg/todos/todos.go | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/commands/todos.go b/cmd/commands/todos.go index ee6751a..9d392f0 100644 --- a/cmd/commands/todos.go +++ b/cmd/commands/todos.go @@ -17,6 +17,8 @@ import ( ) var csvOutput bool +var startingMatchPhrases []string +startingMatchPhrases = {"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} func init() { todosCmd.Flags().BoolVar(&csvOutput, "csv-output", false, "specify whether or not output should be in CSV format") @@ -47,7 +49,7 @@ var todosCmd = &cobra.Command{ foundToDos := make(todos.ToDos, 0) err = comments.SearchDir(dir, func(comment *comments.Comment) { - todo := todos.NewToDo(*comment) + todo := todos.NewToDo(*comment, startingMatchPhrases) if todo != nil { foundToDos = append(foundToDos, todo) s.Suffix = fmt.Sprintf(" %d TODOs found", len(foundToDos)) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index 34110c5..efbcb94 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -31,11 +31,11 @@ func (t *ToDo) TimeAgo() string { } // NewToDo produces a pointer to a ToDo from a comment -func NewToDo(comment comments.Comment) *ToDo { +func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { // FIXME this should be configurable and probably NOT hardcoded here // in fact, this list might be too expansive for a sensible default - startingMatchPhrases := []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} - var matchPhrases []string + //startingMatchPhrases := []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} + //var matchPhrases []string for _, phrase := range startingMatchPhrases { // populates matchPhrases with the contents of startingMatchPhrases plus the @+lowerCase version of each phrase matchPhrases = append(matchPhrases, phrase, "@"+strings.ToLower(phrase)) From 4294ed98eb0f03f4f7efa67540011e885dc9740f Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Mon, 15 Jun 2020 16:41:32 -0400 Subject: [PATCH 03/11] Revert "started working on a check for .gitignore files" This reverts commit 2be20429bd635af26e012daad5f90a787e1cc935. --- pkg/comments/comments.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/comments/comments.go b/pkg/comments/comments.go index 11896a7..8c1f06e 100644 --- a/pkg/comments/comments.go +++ b/pkg/comments/comments.go @@ -75,16 +75,12 @@ func SearchDir(dirPath string, cb func(comment *Comment)) error { pathComponents := strings.Split(localPath, string(os.PathSeparator)) // let's ignore git directories TODO: figure out a more generic way to set ignores matched, err := filepath.Match(".git", pathComponents[0]) - ignore, err := filepath.Match(".gitignore", pathComponents[0]) if err != nil { return err } if matched { return nil } - if ignore { - return nil - } if de.IsRegular() { p, err := filepath.Abs(path) if err != nil { From 5caf79787f29b597e93189b6c7c6a287954d9a2b Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Mon, 15 Jun 2020 19:57:30 -0400 Subject: [PATCH 04/11] update todos.go --- pkg/todos/todos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index fa392a8..06fc777 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -58,7 +58,7 @@ func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { func NewToDos(comments comments.Comments) ToDos { todos := make(ToDos, 0) for _, comment := range comments { - todo := NewToDo(*comment) + todo := NewToDo(*comment, mat) if todo != nil { todos = append(todos, todo) } From bf88ae72841384b73e81d34ab76109dad08a32be Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Tue, 16 Jun 2020 11:46:31 -0400 Subject: [PATCH 05/11] update todos.go --- pkg/todos/todos.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index 06fc777..dd87cec 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -19,6 +19,8 @@ type ToDo struct { // ToDos represents a list of ToDo items type ToDos []*ToDo +var startingMatchPhrases []string +startingMatchPhrases = {"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} // TimeAgo returns a human readable string indicating the time since the todo was added func (t *ToDo) TimeAgo() string { @@ -58,7 +60,7 @@ func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { func NewToDos(comments comments.Comments) ToDos { todos := make(ToDos, 0) for _, comment := range comments { - todo := NewToDo(*comment, mat) + todo := NewToDo(*comment, startingMatchPhrases) if todo != nil { todos = append(todos, todo) } From 4f14b98a7ada81090cc7173adba33eb41a609a67 Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Tue, 16 Jun 2020 16:12:03 -0400 Subject: [PATCH 06/11] update todos.go again --- pkg/todos/todos.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index dd87cec..1c1aea0 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -19,8 +19,8 @@ type ToDo struct { // ToDos represents a list of ToDo items type ToDos []*ToDo -var startingMatchPhrases []string -startingMatchPhrases = {"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} + +var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} // TimeAgo returns a human readable string indicating the time since the todo was added func (t *ToDo) TimeAgo() string { @@ -36,7 +36,7 @@ func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { // in fact, this list might be too expansive for a sensible default //startingMatchPhrases := []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} //var matchPhrases []string - for _, phrase := range startingMatchPhrases { + for _, phrase := range matchPhrases { // populates matchPhrases with the contents of startingMatchPhrases plus the @+lowerCase version of each phrase matchPhrases = append(matchPhrases, phrase, "@"+strings.ToLower(phrase)) } From 1f3d7dcff44cd0fca5fdb22db5ce177c63869895 Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Tue, 16 Jun 2020 16:21:46 -0400 Subject: [PATCH 07/11] update NewToDo --- cmd/tickgit/commands/todos.go | 3 +-- pkg/todos/todos_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/tickgit/commands/todos.go b/cmd/tickgit/commands/todos.go index f7aff58..b9ae311 100644 --- a/cmd/tickgit/commands/todos.go +++ b/cmd/tickgit/commands/todos.go @@ -17,8 +17,7 @@ import ( ) var csvOutput bool -var startingMatchPhrases []string -startingMatchPhrases = {"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} +var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} func init() { todosCmd.Flags().BoolVar(&csvOutput, "csv-output", false, "specify whether or not output should be in CSV format") diff --git a/pkg/todos/todos_test.go b/pkg/todos/todos_test.go index 8b71967..e2777d6 100644 --- a/pkg/todos/todos_test.go +++ b/pkg/todos/todos_test.go @@ -7,12 +7,14 @@ import ( "github.com/augmentable-dev/tickgit/pkg/comments" ) +var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} + func TestNewToDoNil(t *testing.T) { collection := lege.NewCollection(lege.Location{}, lege.Location{}, lege.Boundary{}, "Hello World") comment := comments.Comment{ Collection: *collection, } - todo := NewToDo(comment) + todo := NewToDo(comment, startingMatchPhrases) if todo != nil { t.Fatalf("did not expect a TODO, got: %v", todo) @@ -24,7 +26,7 @@ func TestNewToDo(t *testing.T) { comment := comments.Comment{ Collection: *collection, } - todo := NewToDo(comment) + todo := NewToDo(comment, startingMatchPhrases) if todo == nil { t.Fatalf("expected a TODO, got: %v", todo) From e0ebd28fd98c2829b55465b63c596c38b5ce903d Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Tue, 16 Jun 2020 16:27:47 -0400 Subject: [PATCH 08/11] fix redeclaration of startingMatchPhrases --- pkg/todos/todos_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/todos/todos_test.go b/pkg/todos/todos_test.go index e2777d6..42d66db 100644 --- a/pkg/todos/todos_test.go +++ b/pkg/todos/todos_test.go @@ -7,7 +7,7 @@ import ( "github.com/augmentable-dev/tickgit/pkg/comments" ) -var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} +//var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} func TestNewToDoNil(t *testing.T) { collection := lege.NewCollection(lege.Location{}, lege.Location{}, lege.Boundary{}, "Hello World") From 11bd4e202b2a3de158f8097f1cc628d5bc5cadc1 Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Wed, 24 Jun 2020 14:21:21 -0400 Subject: [PATCH 09/11] add matchPhrases string[] as parameter --- pkg/todos/todos.go | 8 +++----- pkg/todos/todos_test.go | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index 1c1aea0..1a29141 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -33,9 +33,7 @@ func (t *ToDo) TimeAgo() string { // NewToDo produces a pointer to a ToDo from a comment func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { // FIXME this should be configurable and probably NOT hardcoded here - // in fact, this list might be too expansive for a sensible default - //startingMatchPhrases := []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} - //var matchPhrases []string + // in fact, this list might be too expansive for a sensible defaul for _, phrase := range matchPhrases { // populates matchPhrases with the contents of startingMatchPhrases plus the @+lowerCase version of each phrase matchPhrases = append(matchPhrases, phrase, "@"+strings.ToLower(phrase)) @@ -57,10 +55,10 @@ func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { } // NewToDos produces a list of ToDos from a list of comments -func NewToDos(comments comments.Comments) ToDos { +func NewToDos(comments comments.Comments, matchPhrases string[]) ToDos { todos := make(ToDos, 0) for _, comment := range comments { - todo := NewToDo(*comment, startingMatchPhrases) + todo := NewToDo(*comment, matchPhrases) if todo != nil { todos = append(todos, todo) } diff --git a/pkg/todos/todos_test.go b/pkg/todos/todos_test.go index 42d66db..b0b9ec5 100644 --- a/pkg/todos/todos_test.go +++ b/pkg/todos/todos_test.go @@ -7,8 +7,6 @@ import ( "github.com/augmentable-dev/tickgit/pkg/comments" ) -//var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} - func TestNewToDoNil(t *testing.T) { collection := lege.NewCollection(lege.Location{}, lege.Location{}, lege.Boundary{}, "Hello World") comment := comments.Comment{ From 0253090d985b6ff7e22dadcd8db1bb79a9db6423 Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Wed, 24 Jun 2020 14:30:33 -0400 Subject: [PATCH 10/11] fix typo --- pkg/todos/todos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index 1a29141..7635007 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -55,7 +55,7 @@ func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { } // NewToDos produces a list of ToDos from a list of comments -func NewToDos(comments comments.Comments, matchPhrases string[]) ToDos { +func NewToDos(comments comments.Comments, matchPhrases []string) ToDos { todos := make(ToDos, 0) for _, comment := range comments { todo := NewToDo(*comment, matchPhrases) From adcd6a89ddcab5a175079793e3368fed8396a0ff Mon Sep 17 00:00:00 2001 From: Emmy Sohn Date: Tue, 30 Jun 2020 13:26:36 -0400 Subject: [PATCH 11/11] move startingMatchPhrases to todos_test.go --- pkg/todos/todos.go | 2 -- pkg/todos/todos_test.go | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index 7635007..1a66ba6 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -20,8 +20,6 @@ type ToDo struct { // ToDos represents a list of ToDo items type ToDos []*ToDo -var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} - // TimeAgo returns a human readable string indicating the time since the todo was added func (t *ToDo) TimeAgo() string { if t.Blame == nil { diff --git a/pkg/todos/todos_test.go b/pkg/todos/todos_test.go index b0b9ec5..e2777d6 100644 --- a/pkg/todos/todos_test.go +++ b/pkg/todos/todos_test.go @@ -7,6 +7,8 @@ import ( "github.com/augmentable-dev/tickgit/pkg/comments" ) +var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} + func TestNewToDoNil(t *testing.T) { collection := lege.NewCollection(lege.Location{}, lege.Location{}, lege.Boundary{}, "Hello World") comment := comments.Comment{