From 75218a1fa0cf40af89421998552843a73843c8b3 Mon Sep 17 00:00:00 2001 From: tavo Date: Thu, 22 Oct 2020 20:23:38 +0300 Subject: [PATCH] CORE-33 Remove --run and --build options (#34) Squashed commit of the following: commit 0086a784cec76ea1aca69d0bdeb8a3262b56448f Author: tavo Date: Thu Oct 22 19:54:32 2020 +0300 Fix typo commit 8b1c3f6ad358f8ec553123745612662d97272e98 Author: tavo Date: Wed Oct 21 22:18:45 2020 +0300 Got reviewdog working again commit fcbb728404f7667e7ca917f36b49fe70ad986774 Author: tavo Date: Wed Oct 21 22:12:46 2020 +0300 test not static commit 2efd41a424215cbc642c329fec916f4297f511bd Author: tavo Date: Wed Oct 21 22:07:03 2020 +0300 Add build again commit d2652fa9dfd030ccc5de974952d92cc81a5c746e Author: tavo Date: Wed Oct 21 21:58:17 2020 +0300 test reviewdog commit e6b30324e29e2fac355b85f759b88fc477748372 Author: tavo Date: Wed Oct 21 21:54:19 2020 +0300 Minor style fixes commit 45d4e2f9fb8e52ab2d50d0500e443ddc25d08b53 Author: tavo Date: Wed Oct 21 20:59:11 2020 +0300 Remove --run and --build options --- .github/workflows/golangci-lint.yml | 4 ++-- .gitignore | 4 ++-- command/record.go | 28 ++-------------------------- note/note.go | 4 ++-- project/project.go | 10 +++++----- scm/git_test.go | 4 ++-- 6 files changed, 15 insertions(+), 39 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index ea81db0..330171e 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -38,8 +38,8 @@ jobs: cd vendor/libgit2 mkdir build && cd build cmake .. - cd ../../.. - make install-static + make + sudo make install go get -v -d github.com/kilpkonn/gtm-enhanced - name: golangci-lint uses: reviewdog/action-golangci-lint@v1 diff --git a/.gitignore b/.gitignore index a6bb59e..12076ab 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,6 @@ gtm ### https://raw.github.com/github/gitignore/10eb19db07e36f5b8b26315ec90e27c5e82a4b47/Global/Vagrant.gitignore .vagrant/ -/.gtm/ ### https://raw.github.com/github/gitignore/10eb19db07e36f5b8b26315ec90e27c5e82a4b47/Global/Vim.gitignore # swap @@ -80,4 +79,5 @@ tags /go_build* /gtm_tests *.png -*.jpg \ No newline at end of file +*.jpg +/.gtm/ diff --git a/command/record.go b/command/record.go index dff7621..69e5c69 100644 --- a/command/record.go +++ b/command/record.go @@ -62,23 +62,17 @@ Options: -long-duration=false Return total time recorded in long duration format. -app=false [event_name] Record an app event. - - -run=false [app_name] Record run event. - - -build=false [app_name] Record build event. ` return strings.TrimSpace(helpText) } // Run executes record command with args func (c RecordCmd) Run(args []string) int { - var status, terminal, run, build, longDuration, app bool + var status, terminal, longDuration, app bool var cwd string cmdFlags := flag.NewFlagSet("record", flag.ContinueOnError) cmdFlags.BoolVar(&status, "status", false, "") cmdFlags.BoolVar(&terminal, "terminal", false, "") - cmdFlags.BoolVar(&run, "run", false, "") - cmdFlags.BoolVar(&build, "build", false, "") cmdFlags.BoolVar(&longDuration, "long-duration", false, "") cmdFlags.BoolVar(&app, "app", false, "") cmdFlags.StringVar(&cwd, "cwd", "", "") @@ -95,10 +89,6 @@ func (c RecordCmd) Run(args []string) int { var fileToRecord string if terminal { fileToRecord = c.appToFile("terminal", cwd) - } else if run { - fileToRecord = c.runToFile(strings.ToLower(strings.Join(cmdFlags.Args(), "-")), cwd) - } else if build { - fileToRecord = c.buildToFile(strings.ToLower(strings.Join(cmdFlags.Args(), "-")), cwd) } else if app { fileToRecord = c.appToFile(strings.ToLower(strings.Join(cmdFlags.Args(), "-")), cwd) // TODO: list of configurable allowed options } else { @@ -160,20 +150,6 @@ func (c RecordCmd) appToFile(appName string, cwd string) string { return eventToFile(appName, "app", cwd) } -func (c RecordCmd) runToFile(appName string, cwd string) string { - if len(cwd) <= 0 { - return eventToFile(appName, "run") - } - return eventToFile(appName, "run", cwd) -} - -func (c RecordCmd) buildToFile(appName string, cwd string) string { - if len(cwd) <= 0 { - return eventToFile(appName, "build") - } - return eventToFile(appName, "build", cwd) -} - func eventToFile(event string, eventType string, cwd ...string) string { if !(len(event) > 0) { return "" @@ -188,7 +164,7 @@ func eventToFile(event string, eventType string, cwd ...string) string { } var file = filepath.Join(projPath, ".gtm", event+"."+eventType) if _, err := os.Stat(file); os.IsNotExist(err) { - ioutil.WriteFile( + _ = ioutil.WriteFile( file, []byte{}, 0644) diff --git a/note/note.go b/note/note.go index 8e4ffb2..b2310a4 100644 --- a/note/note.go +++ b/note/note.go @@ -81,7 +81,7 @@ func Marshal(n CommitNote) string { func UnMarshal(s string) (CommitNote, error) { var ( version string - files = []FileDetail{} + files []FileDetail ) reHeader := regexp.MustCompile(`\[ver:\d+,total:\d+]`) @@ -201,7 +201,7 @@ func (f *FileDetail) ShortenSourceFile(n int) string { // SortEpochs returns timeline keys sorted by epoch func (f *FileDetail) SortEpochs() []int64 { - keys := []int64{} + var keys []int64 for k := range f.Timeline { keys = append(keys, k) } diff --git a/project/project.go b/project/project.go index 19acc29..5df19ef 100644 --- a/project/project.go +++ b/project/project.go @@ -116,23 +116,23 @@ func Initialize(terminal bool, tags []string, clearTags bool, autoLog string, lo gitRepoPath, err := scm.GitRepoPath(wd) if err != nil { return "", fmt.Errorf( - "Unable to intialize Git Time Metric, Git repository not found in '%s'", gitRepoPath) + "Unable to initialize Git Time Metric, Git repository not found in '%s'", gitRepoPath) } if _, err := os.Stat(gitRepoPath); os.IsNotExist(err) { return "", fmt.Errorf( - "Unable to intialize Git Time Metric, Git repository not found in %s", gitRepoPath) + "Unable to initialize Git Time Metric, Git repository not found in %s", gitRepoPath) } workDirRoot, err := scm.Workdir(gitRepoPath) if err != nil { return "", fmt.Errorf( - "Unable to intialize Git Time Metric, Git working tree root not found in %s", workDirRoot) + "Unable to initialize Git Time Metric, Git working tree root not found in %s", workDirRoot) } if _, err := os.Stat(workDirRoot); os.IsNotExist(err) { return "", fmt.Errorf( - "Unable to intialize Git Time Metric, Git working tree root not found in %s", workDirRoot) + "Unable to initialize Git Time Metric, Git working tree root not found in %s", workDirRoot) } gtmPath := filepath.Join(workDirRoot, GTMDir) @@ -250,7 +250,7 @@ func Uninitialize() (string, error) { gitRepoPath, err := scm.GitRepoPath(wd) if err != nil { return "", fmt.Errorf( - "Unable to unintialize Git Time Metric, Git repository not found in %s", gitRepoPath) + "Unable to uninitialize Git Time Metric, Git repository not found in %s", gitRepoPath) } workDir, _ := scm.Workdir(gitRepoPath) diff --git a/scm/git_test.go b/scm/git_test.go index 5a1e8d3..3f65369 100644 --- a/scm/git_test.go +++ b/scm/git_test.go @@ -56,9 +56,9 @@ func TestGitRepoPath(t *testing.T) { saveDir, err := os.Getwd() util.CheckFatal(t, err) - defer os.Chdir(saveDir) + _ = os.Chdir(saveDir) - os.Chdir(repo.Path()) + _ = os.Chdir(repo.Path()) gotPath, err = GitRepoPath() if err != nil { t.Errorf("GitRepoPath error, %s", err)