Skip to content

Commit

Permalink
CORE-33 Remove --run and --build options (#34)
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 0086a78
Author: tavo <[email protected]>
Date:   Thu Oct 22 19:54:32 2020 +0300

    Fix typo

commit 8b1c3f6
Author: tavo <[email protected]>
Date:   Wed Oct 21 22:18:45 2020 +0300

    Got reviewdog working again

commit fcbb728
Author: tavo <[email protected]>
Date:   Wed Oct 21 22:12:46 2020 +0300

    test not static

commit 2efd41a
Author: tavo <[email protected]>
Date:   Wed Oct 21 22:07:03 2020 +0300

    Add build again

commit d2652fa
Author: tavo <[email protected]>
Date:   Wed Oct 21 21:58:17 2020 +0300

    test reviewdog

commit e6b3032
Author: tavo <[email protected]>
Date:   Wed Oct 21 21:54:19 2020 +0300

    Minor style fixes

commit 45d4e2f
Author: tavo <[email protected]>
Date:   Wed Oct 21 20:59:11 2020 +0300

    Remove --run and --build options
  • Loading branch information
kilpkonn committed Oct 22, 2020
1 parent 813523e commit 75218a1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -80,4 +79,5 @@ tags
/go_build*
/gtm_tests
*.png
*.jpg
*.jpg
/.gtm/
28 changes: 2 additions & 26 deletions command/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "", "")
Expand All @@ -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 {
Expand Down Expand Up @@ -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 ""
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions note/note.go
Original file line number Diff line number Diff line change
Expand Up @@ -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+]`)
Expand Down Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions scm/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 75218a1

Please sign in to comment.