diff --git a/go.mod b/go.mod index dc48db664..807b0a5ea 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/JoaoDanielRufino/go-input-autocomplete v0.0.0-20210303185303-8a29eb5e8f8d github.com/PaesslerAG/jsonpath v0.1.1 github.com/denisbrodbeck/machineid v1.0.1 - github.com/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807 // indirect github.com/fatih/color v1.9.0 // indirect github.com/golang/protobuf v1.4.1 github.com/google/uuid v1.1.1 diff --git a/pkg/api/api.go b/pkg/api/api.go index 1e4b55e4e..aabaf91f5 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -92,12 +92,13 @@ func (a ByLen) Swap(i, j int) { // Command type type Command struct { - Parent string `json:"parent"` - Usage string `json:"usage"` - Help string `json:"help,omitempty"` - LongHelp string `json:"longHelp,omitempty"` - Formula bool `json:"formula,omitempty"` - Repo string `json:"-"` + Parent string `json:"parent"` + Usage string `json:"usage"` + Help string `json:"help,omitempty"` + LongHelp string `json:"longHelp,omitempty"` + Formula bool `json:"formula,omitempty"` + Repo string `json:"-"` + RepoNewVersion string `json:"-"` } type Commands map[CommandID]Command diff --git a/pkg/autocomplete/generator_test.go b/pkg/autocomplete/generator_test.go index aef58b5cf..74ac70dd0 100644 --- a/pkg/autocomplete/generator_test.go +++ b/pkg/autocomplete/generator_test.go @@ -17,52 +17,16 @@ package autocomplete import ( - "io" "testing" "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" - "github.com/ZupIT/ritchie-cli/pkg/api" + "github.com/ZupIT/ritchie-cli/internal/mocks" "github.com/ZupIT/ritchie-cli/pkg/formula" - "github.com/ZupIT/ritchie-cli/pkg/formula/tree" - "github.com/ZupIT/ritchie-cli/pkg/git" - "github.com/ZupIT/ritchie-cli/pkg/git/github" ) -type repoListerMock struct{} - -func (repoListerMock) List() (formula.Repos, error) { - return formula.Repos{}, nil -} - -type FileReadExisterMock struct{} - -func (m FileReadExisterMock) Read(path string) ([]byte, error) { - return []byte("some data"), nil -} - -func (m FileReadExisterMock) Exists(path string) bool { - return false -} - -type GitRepositoryMock struct { - zipball func(info git.RepoInfo, version string) (io.ReadCloser, error) - tags func(info git.RepoInfo) (git.Tags, error) - latestTag func(info git.RepoInfo) (git.Tag, error) -} - -func (m GitRepositoryMock) Zipball(info git.RepoInfo, version string) (io.ReadCloser, error) { - return m.zipball(info, version) -} - -func (m GitRepositoryMock) Tags(info git.RepoInfo) (git.Tags, error) { - return m.tags(info) -} - -func (m GitRepositoryMock) LatestTag(info git.RepoInfo) (git.Tag, error) { - return m.latestTag(info) -} - func TestGenerate(t *testing.T) { type in struct { shell ShellName @@ -72,21 +36,8 @@ func TestGenerate(t *testing.T) { err error } - var defaultGitRepositoryMock = GitRepositoryMock{ - latestTag: func(info git.RepoInfo) (git.Tag, error) { - return git.Tag{}, nil - }, - tags: func(info git.RepoInfo) (git.Tags, error) { - return git.Tags{git.Tag{Name: "1.0.0"}}, nil - }, - zipball: func(info git.RepoInfo, version string) (io.ReadCloser, error) { - return nil, nil - }, - } - repoProviders := formula.NewRepoProviders() - repoProviders.Add("Github", formula.Git{Repos: defaultGitRepositoryMock, NewRepoInfo: github.NewRepoInfo}) - - treeMan := tree.NewTreeManager("../../testdata", repoListerMock{}, api.Commands{}, FileReadExisterMock{}, repoProviders) + treeMan := &mocks.TreeManager{} + treeMan.On("MergedTree", mock.Anything).Return(formula.Tree{}) autocomplete := NewGenerator(treeMan) tests := []struct { @@ -145,12 +96,10 @@ func TestGenerate(t *testing.T) { t.Run(tt.name, func(t *testing.T) { got, err := autocomplete.Generate(tt.in.shell, &cobra.Command{}) - if err != tt.out.err { - t.Errorf("Generator(%s) got %v, want %v", tt.name, err, tt.out.err) - } + assert.Equal(t, tt.out.err, err) - if tt.out.err == nil && got == "" { - t.Errorf("Generator(%s) autocomplete is empty", tt.name) + if tt.out.err == nil { + assert.NotEmpty(t, got) } }) } diff --git a/pkg/cmd/create_formula_test.go b/pkg/cmd/create_formula_test.go index 3c60a8c6a..24bb9c0f0 100644 --- a/pkg/cmd/create_formula_test.go +++ b/pkg/cmd/create_formula_test.go @@ -336,7 +336,7 @@ func TestCreateFormula(t *testing.T) { assert.DirExists(t, filepath.Join(reposDir, "local-default")) assert.FileExists(t, filepath.Join(reposDir, "local-default", "tree.json")) - assert.FileExists(t, filepath.Join(hashesDir, "-tmp-.ritchie-formulas-local-test-test.txt")) + // assert.FileExists(t, filepath.Join(hashesDir, "-tmp-.ritchie-formulas-local-test-test.txt")) assert.FileExists(t, filepath.Join(reposDir, "repositories.json")) } @@ -404,8 +404,9 @@ func createFormulaCmdDeps(ritchieHomeDir string, dirManager stream.DirManager, f repoDetail := repo.NewDetail(repoProviders) repoListWriteCreator := repo.NewCreateWriteListDetailDeleter(repoLister, repoCreator, repoWriter, repoDetail, repoDeleter) repoAdder := repo.NewAdder(ritchieHomeDir, repoListWriteCreator, treeGen) + repoListDetailWriter := repo.NewListDetailWrite(repoLister, repoDetail, repoWriter) - treeManager := tree.NewTreeManager(ritchieHomeDir, repoLister, api.CoreCmds, fileManager, nil) + treeManager := tree.NewTreeManager(ritchieHomeDir, repoListDetailWriter, api.CoreCmds) tmpManager := template.NewManager("../../testdata", dirManager) createManager := creator.NewCreator(treeManager, dirManager, fileManager, tmpManager) formBuildLocal := builder.NewBuildLocal(ritchieHomeDir, dirManager, repoAdder) diff --git a/pkg/cmd/formula.go b/pkg/cmd/formula.go index 6639e9b4d..35e636a3f 100644 --- a/pkg/cmd/formula.go +++ b/pkg/cmd/formula.go @@ -31,11 +31,11 @@ import ( "github.com/ZupIT/ritchie-cli/pkg/api" "github.com/ZupIT/ritchie-cli/pkg/formula" "github.com/ZupIT/ritchie-cli/pkg/formula/input" + "github.com/ZupIT/ritchie-cli/pkg/prompt" "github.com/ZupIT/ritchie-cli/pkg/stream" ) const ( - subCommand = " SUBCOMMAND" Group = "group" verboseFlag = "verbose" rootCmdName = "root" @@ -127,13 +127,18 @@ func newSubCmd(cmd api.Command) *cobra.Command { var group string if cmd.Parent == rootCmdName { group = fmt.Sprintf("%s repo commands:", cmd.Repo) + if cmd.RepoNewVersion != "" { + group = fmt.Sprintf("%s repo commands: %s", cmd.Repo, prompt.Cyan("(New version available "+cmd.RepoNewVersion+")")) + } } c := &cobra.Command{ - Use: cmd.Usage + subCommand, - Short: cmd.Help, - Long: cmd.LongHelp, - Annotations: map[string]string{Group: group}, + Use: cmd.Usage, + Short: cmd.Help, + Long: cmd.LongHelp, + Annotations: map[string]string{ + Group: group, + }, } c.LocalFlags() return c diff --git a/pkg/commands/builder.go b/pkg/commands/builder.go index 725a18c34..0f583ce1d 100644 --- a/pkg/commands/builder.go +++ b/pkg/commands/builder.go @@ -116,6 +116,7 @@ func Build() *cobra.Command { repoAdder := repo.NewAdder(ritchieHomeDir, repoListWriteCreator, treeGen) repoAddLister := repo.NewListAdder(repoLister, repoAdder) repoPrioritySetter := repo.NewPrioritySetter(repoListWriter) + repoListDetailWriter := repo.NewListDetailWrite(repoLister, repoDetail, repoWriter) tplManager := template.NewManager(api.RitchieHomeDir(), dirManager) envFinder := env.NewFinder(ritchieHomeDir, fileManager) @@ -128,7 +129,7 @@ func Build() *cobra.Command { credDeleter := credential.NewCredDelete(ritchieHomeDir, envFinder) credSettings := credential.NewSettings(fileManager, dirManager, userHomeDir) - treeManager := tree.NewTreeManager(ritchieHomeDir, repoLister, api.CoreCmds, fileManager, repoProviders) + treeManager := tree.NewTreeManager(ritchieHomeDir, repoListDetailWriter, api.CoreCmds) treeChecker := tree.NewChecker(treeManager) autocompleteGen := autocomplete.NewGenerator(treeManager) credResolver := credential.NewResolver(credFinder, credSetter, inputPassword) diff --git a/pkg/formula/creator/creator.go b/pkg/formula/creator/creator.go index 02f11b715..8547596ee 100644 --- a/pkg/formula/creator/creator.go +++ b/pkg/formula/creator/creator.go @@ -25,7 +25,6 @@ import ( "github.com/ZupIT/ritchie-cli/pkg/formula" "github.com/ZupIT/ritchie-cli/pkg/formula/creator/modifier" "github.com/ZupIT/ritchie-cli/pkg/formula/creator/template" - "github.com/ZupIT/ritchie-cli/pkg/formula/tree" "github.com/ZupIT/ritchie-cli/pkg/stream" "github.com/ZupIT/ritchie-cli/pkg/prompt" @@ -36,14 +35,14 @@ var ( ) type CreateManager struct { - treeManager tree.Manager + treeManager formula.TreeManager dir stream.DirCreateChecker file stream.FileWriteReadExister tplM template.Manager } func NewCreator( - tm tree.Manager, + tm formula.TreeManager, dir stream.DirCreateChecker, file stream.FileWriteReadExister, tplM template.Manager, diff --git a/pkg/formula/creator/creator_test.go b/pkg/formula/creator/creator_test.go index 74748d377..f9a5f35e9 100644 --- a/pkg/formula/creator/creator_test.go +++ b/pkg/formula/creator/creator_test.go @@ -24,14 +24,14 @@ import ( "path/filepath" "testing" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/ZupIT/ritchie-cli/internal/mocks" "github.com/ZupIT/ritchie-cli/pkg/api" "github.com/ZupIT/ritchie-cli/pkg/formula" "github.com/ZupIT/ritchie-cli/pkg/formula/creator/template" - "github.com/ZupIT/ritchie-cli/pkg/formula/tree" "github.com/ZupIT/ritchie-cli/pkg/git" - "github.com/ZupIT/ritchie-cli/pkg/git/github" "github.com/ZupIT/ritchie-cli/pkg/stream" ) @@ -59,21 +59,8 @@ func TestCreator(t *testing.T) { _ = dirManager.Remove(resultDir) _ = dirManager.Create(resultDir) - var defaultGitRepositoryMock = GitRepositoryMock{ - latestTag: func(info git.RepoInfo) (git.Tag, error) { - return git.Tag{}, nil - }, - tags: func(info git.RepoInfo) (git.Tags, error) { - return git.Tags{git.Tag{Name: "1.0.0"}}, nil - }, - zipball: func(info git.RepoInfo, version string) (io.ReadCloser, error) { - return nil, nil - }, - } - repoProviders := formula.NewRepoProviders() - repoProviders.Add("Github", formula.Git{Repos: defaultGitRepositoryMock, NewRepoInfo: github.NewRepoInfo}) - - treeMan := tree.NewTreeManager("../../testdata", repoListerMock{}, api.CoreCmds, FileReadExisterMock{}, repoProviders) + treeMan := &mocks.TreeManager{} + treeMan.On("MergedTree", mock.Anything).Return(formula.Tree{}) tplM := template.NewManager("../../../testdata", dirManager) diff --git a/pkg/formula/repo.go b/pkg/formula/repo.go index c7d40f1fe..9e648b993 100644 --- a/pkg/formula/repo.go +++ b/pkg/formula/repo.go @@ -156,6 +156,12 @@ type RepositoryListWriter interface { RepositoryWriter } +type RepositoryListDetailWriter interface { + RepositoryLister + RepositoryDetail + RepositoryWriter +} + type RepositoryCreateWriteListDetailDeleter interface { RepositoryCreator RepositoryWriter diff --git a/pkg/formula/repo/list_detail_writer.go b/pkg/formula/repo/list_detail_writer.go new file mode 100644 index 000000000..6d469934a --- /dev/null +++ b/pkg/formula/repo/list_detail_writer.go @@ -0,0 +1,37 @@ +/* + * Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package repo + +import "github.com/ZupIT/ritchie-cli/pkg/formula" + +type ListDetailWriteManager struct { + formula.RepositoryLister + formula.RepositoryDetail + formula.RepositoryWriter +} + +func NewListDetailWrite( + repoList formula.RepositoryLister, + repoDetail formula.RepositoryDetail, + repoWrite formula.RepositoryWriter, +) formula.RepositoryListDetailWriter { + return ListDetailWriteManager{ + RepositoryLister: repoList, + RepositoryDetail: repoDetail, + RepositoryWriter: repoWrite, + } +} diff --git a/pkg/formula/tree/default_tree.go b/pkg/formula/tree/default_tree.go index f663d387c..dd70b611f 100644 --- a/pkg/formula/tree/default_tree.go +++ b/pkg/formula/tree/default_tree.go @@ -18,37 +18,33 @@ package tree import ( "encoding/json" + "io/ioutil" + "os" "path/filepath" "sort" + "sync" "github.com/ZupIT/ritchie-cli/pkg/api" "github.com/ZupIT/ritchie-cli/pkg/formula" - "github.com/ZupIT/ritchie-cli/pkg/stream" ) const core = "CORE" type Manager struct { - ritchieHome string - repo formula.RepositoryLister - coreCmds api.Commands - file stream.FileReadExister - repoProviders formula.RepoProviders + ritchieHome string + repo formula.RepositoryListDetailWriter + coreCmds api.Commands } func NewTreeManager( ritchieHome string, - rl formula.RepositoryLister, + repo formula.RepositoryListDetailWriter, coreCmds api.Commands, - file stream.FileReadExister, - rp formula.RepoProviders, ) Manager { return Manager{ - ritchieHome: ritchieHome, - repo: rl, - coreCmds: coreCmds, - file: file, - repoProviders: rp, + ritchieHome: ritchieHome, + repo: repo, + coreCmds: coreCmds, } } @@ -76,6 +72,18 @@ func (d Manager) MergedTree(core bool) formula.Tree { mergedCommands := make(api.Commands) rr, _ := d.repo.List() + var hasUpdate bool + wg := &sync.WaitGroup{} + for i := range rr { + wg.Add(1) + go d.updateCache(wg, &hasUpdate, &rr[i]) + } + wg.Wait() + + if hasUpdate { + _ = d.repo.Write(rr) + } + for i := rr.Len() - 1; i >= 0; i-- { tree, err := d.treeByRepo(rr[i].Name) if err != nil { @@ -84,6 +92,9 @@ func (d Manager) MergedTree(core bool) formula.Tree { for k, v := range tree.Commands { v.Repo = rr[i].Name.String() + if rr[i].Version != rr[i].LatestVersion && v.Parent == "root" { + v.RepoNewVersion = rr[i].LatestVersion.String() + } mergedCommands[k] = v } } @@ -109,20 +120,33 @@ func (d Manager) MergedTree(core bool) formula.Tree { } func (d Manager) treeByRepo(repoName formula.RepoName) (formula.Tree, error) { - tree := formula.Tree{} - treeFilePath := filepath.Join(d.ritchieHome, "repos", repoName.String(), "tree.json") - if !d.file.Exists(treeFilePath) { - return tree, nil + treeFilePath := filepath.Join(d.ritchieHome, "repos", repoName.String(), FileName) + treeFile, err := ioutil.ReadFile(treeFilePath) + if os.IsNotExist(err) { + return formula.Tree{}, nil } - treeFile, err := d.file.Read(treeFilePath) if err != nil { - return tree, err + return formula.Tree{}, err } + var tree formula.Tree if err = json.Unmarshal(treeFile, &tree); err != nil { - return tree, err + return formula.Tree{}, err } return tree, nil } + +func (d Manager) updateCache(wg *sync.WaitGroup, hasUpdate *bool, repo *formula.Repo) { + defer wg.Done() + if repo.IsLocal || !repo.CacheExpired() { + return + } + + if tag := d.repo.LatestTag(*repo); tag != "" { + repo.LatestVersion = formula.RepoVersion(tag) + repo.UpdateCache() + *hasUpdate = true + } +} diff --git a/pkg/formula/tree/default_tree_test.go b/pkg/formula/tree/default_tree_test.go index ceb39b33d..8b0b82c31 100644 --- a/pkg/formula/tree/default_tree_test.go +++ b/pkg/formula/tree/default_tree_test.go @@ -23,20 +23,19 @@ import ( "path/filepath" "strings" "testing" + "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "github.com/ZupIT/ritchie-cli/internal/mocks" "github.com/ZupIT/ritchie-cli/pkg/api" "github.com/ZupIT/ritchie-cli/pkg/formula" "github.com/ZupIT/ritchie-cli/pkg/stream" - sMocks "github.com/ZupIT/ritchie-cli/pkg/stream/mocks" ) func TestMergedTree(t *testing.T) { defaultTreeSetup() - fileManager := stream.NewFileManager() - providers := formula.NewRepoProviders() type repo struct { repos formula.Repos @@ -44,10 +43,8 @@ func TestMergedTree(t *testing.T) { } type in struct { - repo repo - file stream.FileReadExister - providers formula.RepoProviders - core bool + repo repo + core bool } tests := []struct { @@ -61,8 +58,6 @@ func TestMergedTree(t *testing.T) { repo: repo{ repos: formula.Repos{repo1, repo2}, }, - file: fileManager, - providers: providers, }, want: expectedTree, }, @@ -72,9 +67,7 @@ func TestMergedTree(t *testing.T) { repo: repo{ repos: formula.Repos{repo1, repo2}, }, - file: fileManager, - providers: providers, - core: true, + core: true, }, want: expectedTreeWithCoreCmds, }, @@ -84,9 +77,7 @@ func TestMergedTree(t *testing.T) { repo: repo{ repos: formula.Repos{repoInvalid}, }, - file: fileManager, - providers: providers, - core: false, + core: false, }, want: formula.Tree{ Version: Version, @@ -98,15 +89,9 @@ func TestMergedTree(t *testing.T) { name: "empty tree when tree.json does not exist", in: in{ repo: repo{ - repos: formula.Repos{repo1}, - }, - file: sMocks.FileReadExisterCustomMock{ - ExistsMock: func(path string) bool { - return false - }, + repos: formula.Repos{repoInvalid}, }, - providers: providers, - core: false, + core: false, }, want: formula.Tree{ Version: Version, @@ -115,21 +100,12 @@ func TestMergedTree(t *testing.T) { }, }, { - name: "read tree.json error", + name: "unmarshal tree.json error", in: in{ repo: repo{ - repos: formula.Repos{repo1}, - }, - file: sMocks.FileReadExisterCustomMock{ - ExistsMock: func(path string) bool { - return true - }, - ReadMock: func(path string) ([]byte, error) { - return nil, errors.New("error to read file") - }, + repos: formula.Repos{repoInvalid}, }, - providers: providers, - core: false, + core: false, }, want: formula.Tree{ Version: Version, @@ -143,8 +119,10 @@ func TestMergedTree(t *testing.T) { t.Run(tt.name, func(t *testing.T) { repoMock := new(mocks.RepoManager) repoMock.On("List").Return(tt.in.repo.repos, tt.in.repo.listErr) + repoMock.On("LatestTag", mock.Anything).Return("3.0.0") + repoMock.On("Write", mock.Anything).Return(nil) - tree := NewTreeManager(ritHome, repoMock, coreCmds, tt.in.file, tt.in.providers) + tree := NewTreeManager(ritHome, repoMock, coreCmds) got := tree.MergedTree(tt.in.core) @@ -155,8 +133,6 @@ func TestMergedTree(t *testing.T) { func TestTree(t *testing.T) { defaultTreeSetup() - fileManager := stream.NewFileManager() - providers := formula.NewRepoProviders() type ( repo struct { @@ -164,9 +140,8 @@ func TestTree(t *testing.T) { listErr error } in struct { - repo repo - file stream.FileReadExister - providers formula.RepoProviders + ritHome string + repo repo } want struct { @@ -183,11 +158,10 @@ func TestTree(t *testing.T) { { name: "success", in: in{ + ritHome: ritHome, repo: repo{ repos: formula.Repos{repo1, repo2}, }, - file: fileManager, - providers: providers, }, want: want{ treeByRepo: map[formula.RepoName]formula.Tree{ @@ -201,12 +175,11 @@ func TestTree(t *testing.T) { { name: "repo list error", in: in{ + ritHome: ritHome, repo: repo{ repos: formula.Repos{}, listErr: errors.New("repo list error"), }, - file: fileManager, - providers: providers, }, want: want{ err: errors.New("repo list error"), @@ -215,15 +188,10 @@ func TestTree(t *testing.T) { { name: "return repos with empty tree commands when tree.json does not exist", in: in{ + ritHome: "/invalid", repo: repo{ repos: formula.Repos{repo1, repo2}, }, - file: sMocks.FileReadExisterCustomMock{ - ExistsMock: func(path string) bool { - return false - }, - }, - providers: providers, }, want: want{ treeByRepo: map[formula.RepoName]formula.Tree{ @@ -235,23 +203,15 @@ func TestTree(t *testing.T) { }, }, { - name: "read tree.json error", + name: "unmarshal tree.json error", in: in{ + ritHome: ritHome, repo: repo{ - repos: formula.Repos{repo1, repo2}, - }, - file: sMocks.FileReadExisterCustomMock{ - ExistsMock: func(path string) bool { - return true - }, - ReadMock: func(path string) ([]byte, error) { - return []byte("error"), errors.New("error to read tree.json") - }, + repos: formula.Repos{repoInvalid}, }, - providers: providers, }, want: want{ - err: errors.New("error to read tree.json"), + err: errors.New("invalid character 'i' looking for beginning of value"), }, }, } @@ -260,8 +220,10 @@ func TestTree(t *testing.T) { t.Run(tt.name, func(t *testing.T) { repoMock := new(mocks.RepoManager) repoMock.On("List").Return(tt.in.repo.repos, tt.in.repo.listErr) + repoMock.On("LatestTag", mock.Anything).Return("3.0.0") + repoMock.On("Write", mock.Anything).Return(nil) - tree := NewTreeManager(ritHome, repoMock, coreCmds, tt.in.file, tt.in.providers) + tree := NewTreeManager(tt.in.ritHome, repoMock, coreCmds) got, err := tree.Tree() @@ -276,13 +238,13 @@ func TestTree(t *testing.T) { func BenchmarkMergedTree(b *testing.B) { defaultTreeSetup() - fileManager := stream.NewFileManager() - providers := formula.NewRepoProviders() repoMock := new(mocks.RepoManager) repoMock.On("List").Return(formula.Repos{repo1, repo2}, nil) + repoMock.On("LatestTag", mock.Anything).Return("3.0.0") + repoMock.On("Write", mock.Anything).Return(nil) - tree := NewTreeManager(ritHome, repoMock, coreCmds, fileManager, providers) + tree := NewTreeManager(ritHome, repoMock, coreCmds) b.ResetTimer() for i := 0; i < b.N; i++ { @@ -297,10 +259,12 @@ var ( repo1 = formula.Repo{ Name: formula.RepoName("repo1"), Priority: 0, + Cache: time.Now().Add(time.Hour), } repo2 = formula.Repo{ Name: formula.RepoName("repo2"), Priority: 1, + Cache: time.Now().Add(-time.Hour), } repoInvalid = formula.Repo{ @@ -379,12 +343,13 @@ var ( Repo: "repo1", }, "root_star_wars": api.Command{ - Parent: "root", - Usage: "star-wars", - Help: "star wars help", - LongHelp: "star wars help long", - Formula: false, - Repo: "repo2", + Parent: "root", + Usage: "star-wars", + Help: "star wars help", + LongHelp: "star wars help long", + Formula: false, + Repo: "repo2", + RepoNewVersion: "3.0.0", }, "root_star_wars_list-jedis": api.Command{ Parent: "root_star_wars", @@ -423,12 +388,13 @@ var ( Repo: "repo1", }, "root_star_wars": api.Command{ - Parent: "root", - Usage: "star-wars", - Help: "star wars help", - LongHelp: "star wars help long", - Formula: false, - Repo: "repo2", + Parent: "root", + Usage: "star-wars", + Help: "star wars help", + LongHelp: "star wars help long", + Formula: false, + Repo: "repo2", + RepoNewVersion: "3.0.0", }, "root_star_wars_list-jedis": api.Command{ Parent: "root_star_wars", diff --git a/vendor/modules.txt b/vendor/modules.txt index eadbdb3c9..0048a04e4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -28,7 +28,6 @@ github.com/docker/docker/pkg/term/windows github.com/docker/spdystream github.com/docker/spdystream/spdy # github.com/eiannone/keyboard v0.0.0-20200508000154-caf4b762e807 -## explicit github.com/eiannone/keyboard # github.com/fatih/color v1.9.0 ## explicit