Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Revert "Add four-key directory information"
Browse files Browse the repository at this point in the history
This reverts commit 6cd5ae2.
  • Loading branch information
Burak Olgun authored and burakolgun committed Aug 1, 2020
1 parent 6cd5ae2 commit 352dcda
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 62 deletions.
27 changes: 9 additions & 18 deletions command/command.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command
package Command

import (
"errors"
Expand All @@ -11,8 +11,6 @@ import (
"strings"
)

const DefaultFourKeyDirName = "four-key"

func (c *Commander) Info(args ...interface{}) string {
f := c.color("\033[1;36m%s\033[0m")
return f(args)
Expand Down Expand Up @@ -49,7 +47,6 @@ type ICommand interface {
Command(cmd string, p string) error
GetFourKeyPath() string
GetRepositoriesPath(cloneDir string) string
GetUserHomeDir() string
Info(...interface{}) string
Warn(...interface{}) string
Fatal(...interface{}) string
Expand All @@ -75,33 +72,27 @@ func (c *Commander) Command(command string, p string) error {
}

func (c *Commander) GetFourKeyPath() string {
r := c.GetUserHomeDir()

p := path.Join(r, DefaultFourKeyDirName)
err := os.Chdir(p)
r, err := os.UserHomeDir()

if err != nil {
log.Fatal(c.Fatal("four-key path not found! Error: %v", err))
log.Fatal(err)
}

p := path.Join(r, "four-key")
err = os.Mkdir(p, os.ModePerm)

return p
}

func (c *Commander) GetUserHomeDir() string {
func (c *Commander) GetRepositoriesPath(cloneDir string) string {
r, err := os.UserHomeDir()

if err != nil {
log.Fatal(err)
}

return r
}

func (c *Commander) GetRepositoriesPath(cloneDir string) string {
r := c.GetUserHomeDir()

p := path.Join(r, DefaultFourKeyDirName, cloneDir)
err := os.Mkdir(p, os.ModePerm)
p := path.Join(r, "four-key", cloneDir)
err = os.Mkdir(p, os.ModePerm)

log.Println(err)

Expand Down
31 changes: 0 additions & 31 deletions command/command_test.go

This file was deleted.

1 change: 1 addition & 0 deletions helpers/commit_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

func GetTagFixAndFeatureCommits(fixPatterns []string, tagDateRangeTotalCommits []object.Commit, tagCommits []tagCommit) (metricTags []tagMetricData) {

for i := 0; i < len(tagCommits); i++ {
var featureCommits []object.Commit
var fixCommits []object.Commit
Expand Down
4 changes: 2 additions & 2 deletions helpers/repository_metric_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ func IsReleaseTag(tagName, releaseTagPattern string) bool {
func getTagCommitBetweenDates(r *git.Repository, request MetricsRequest) ([]tagCommit, error) {
var commitTags []tagCommit

var sortedTagList = SortTagsByDate(r)
var sortedTagList = GetAscendingOrderByTagDate(r)

var prevTag *tagCommit
var lastTag *tagCommit
var firstTag *tagCommit

lastTagFound := false
firstTagFound := false
for _, t := range sortedTagList {
Expand Down
19 changes: 10 additions & 9 deletions helpers/time_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"time"
)

type TagWrapper struct {
type TagData struct {
tagDate time.Time
tag *plumbing.Reference
}

type timeSlice []TagWrapper
type timeSlice []TagData

func (p timeSlice) Len() int {
return len(p)
Expand All @@ -28,30 +28,31 @@ func (p timeSlice) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}

func SortTagsByDate(r *git.Repository) (tags []TagWrapper) {
var TagWrapperList = make(map[string]TagWrapper)
func GetAscendingOrderByTagDate(r *git.Repository) (tags []TagData) {

var tagDataList = make(map[string]TagData)
rTags, err := r.Tags()
if err != nil {
println(err)
}

var i = 0
err = rTags.ForEach(func(t *plumbing.Reference) error {
c, err := GetCommitFromTagHash(r, t.Hash())
cm, err := GetCommitFromTagHash(r, t.Hash())
if err != nil {
fmt.Println(err)
}

if c != nil {
TagWrapperList[string(i)] = TagWrapper{c.Committer.When, t}
if cm != nil {
tagDataList[string(i)] = TagData{cm.Committer.When, t}
i++
}

return nil
})

sortedTagDataList := make(timeSlice, 0, len(TagWrapperList))
for _, tag := range TagWrapperList {
sortedTagDataList := make(timeSlice, 0, len(tagDataList))
for _, tag := range tagDataList {
sortedTagDataList = append(sortedTagDataList, tag)
}
sort.Sort(sortedTagDataList)
Expand Down
4 changes: 2 additions & 2 deletions settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Setting interface {
var settings Settings
var isLoaded = false

const DefaultConfigurationFileTemplate = `{"output": "%s", "repositories":[]}`
const TemplateConfig = `{"repositories":[]}`
const DefaultTeamName = "master"
const EnvironmentFileName = "four-key.json"
const DefaultRepositoryDirName = "repos"
Expand Down Expand Up @@ -65,7 +65,7 @@ func (s *Settings) Load() error {
return err
}

_, err = f.WriteString(fmt.Sprintf(DefaultConfigurationFileTemplate, s.commander.GetUserHomeDir()))
_, err = f.WriteString(TemplateConfig)

fmt.Println(s.commander.Good("Configuration file added."))
fmt.Println(s.commander.Good("please add an repository and run command like -> ./four-key run -s 2018-01-13 -e 2021-01-13"))
Expand Down

0 comments on commit 352dcda

Please sign in to comment.