From 22dd54682bb4a85f49a147c5f17ca7a499832a45 Mon Sep 17 00:00:00 2001 From: Eriks Zelenka Date: Sun, 10 Mar 2024 15:45:28 +0000 Subject: [PATCH 1/3] fix: replace some git command invocations with go-git library --- .github/workflows/reviewdog.yaml | 33 +++ exec/exec.go | 13 +- exec/mocks/{ShellRunnerI.go => GitRunnerI.go} | 14 +- gitget/get.go | 226 ++++++++++++++---- go.mod | 21 ++ go.sum | 90 ++++++- 6 files changed, 336 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/reviewdog.yaml rename exec/mocks/{ShellRunnerI.go => GitRunnerI.go} (70%) diff --git a/.github/workflows/reviewdog.yaml b/.github/workflows/reviewdog.yaml new file mode 100644 index 0000000..95c6af2 --- /dev/null +++ b/.github/workflows/reviewdog.yaml @@ -0,0 +1,33 @@ +name: reviewdog +on: [pull_request] + +jobs: + reviewdog: + name: linters + runs-on: ubuntu-22.04 + steps: + # UPDATE_HERE + # https://github.com/actions/checkout/releases + - name: check out code into the go module directory + uses: actions/checkout@v4 + + # UPDATE_HERE + # https://github.com/webfactory/ssh-agent/releases + - name: Configure SSH private key for private repos + uses: webfactory/ssh-agent@v0.9.0 + with: + # AWS secret: storm/deploy-ssh-keys + ssh-private-key: | + ${{ secrets.SSH_KEY }} + + # UPDATE_HERE + # https://github.com/reviewdog/action-golangci-lint/releases + - name: golangci-lint + uses: reviewdog/action-golangci-lint@v2 + with: + golangci_lint_flags: "--timeout=4m" + + # UPDATE_HERE + # https://github.com/reviewdog/action-actionlint/releases + - name: action-lint + uses: reviewdog/action-actionlint@v1 diff --git a/exec/exec.go b/exec/exec.go index 704818c..43ab049 100644 --- a/exec/exec.go +++ b/exec/exec.go @@ -7,14 +7,19 @@ import ( const gitCmd = "git" -type ShellRunnerI interface { - ExecGitCommand(args []string, stdoutb *bytes.Buffer, erroutb *bytes.Buffer, dir string) (cmd *exec.Cmd, err error) +type GitRunnerI interface { + ExecGitCommand( + args []string, + stdoutb *bytes.Buffer, + erroutb *bytes.Buffer, + dir string, + ) (cmd *exec.Cmd, err error) } -type ShellRunner struct{} +type ShellGitRunner struct{} // ExecGitCommand executes git with flags passed as `args` and can change working directory if `dir` is passed -func (repo *ShellRunner) ExecGitCommand( +func (repo *ShellGitRunner) ExecGitCommand( args []string, stdoutb *bytes.Buffer, erroutb *bytes.Buffer, diff --git a/exec/mocks/ShellRunnerI.go b/exec/mocks/GitRunnerI.go similarity index 70% rename from exec/mocks/ShellRunnerI.go rename to exec/mocks/GitRunnerI.go index d358b03..3d01724 100644 --- a/exec/mocks/ShellRunnerI.go +++ b/exec/mocks/GitRunnerI.go @@ -9,13 +9,13 @@ import ( mock "github.com/stretchr/testify/mock" ) -// ShellRunnerI is an autogenerated mock type for the ShellRunnerI type -type ShellRunnerI struct { +// GitRunnerI is an autogenerated mock type for the GitRunnerI type +type GitRunnerI struct { mock.Mock } // ExecGitCommand provides a mock function with given fields: args, stdoutb, erroutb, dir -func (_m *ShellRunnerI) ExecGitCommand(args []string, stdoutb *bytes.Buffer, erroutb *bytes.Buffer, dir string) (*exec.Cmd, error) { +func (_m *GitRunnerI) ExecGitCommand(args []string, stdoutb *bytes.Buffer, erroutb *bytes.Buffer, dir string) (*exec.Cmd, error) { ret := _m.Called(args, stdoutb, erroutb, dir) if len(ret) == 0 { @@ -44,13 +44,13 @@ func (_m *ShellRunnerI) ExecGitCommand(args []string, stdoutb *bytes.Buffer, err return r0, r1 } -// NewShellRunnerI creates a new instance of ShellRunnerI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewGitRunnerI creates a new instance of GitRunnerI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewShellRunnerI(t interface { +func NewGitRunnerI(t interface { mock.TestingT Cleanup(func()) -}) *ShellRunnerI { - mock := &ShellRunnerI{} +}) *GitRunnerI { + mock := &GitRunnerI{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/gitget/get.go b/gitget/get.go index 6b92235..39cb3ee 100644 --- a/gitget/get.go +++ b/gitget/get.go @@ -47,6 +47,9 @@ import ( "github.com/isindir/git-get/exec" "github.com/isindir/git-get/github" "github.com/isindir/git-get/gitlab" + + git "github.com/go-git/go-git/v5" + gitPlumbing "github.com/go-git/go-git/v5/plumbing" ) var stayOnRef bool @@ -56,7 +59,7 @@ var mirrorVisibilityMode = "private" var bitbucketMirrorProject = "" var colorHighlight *color.Color var colorRef *color.Color -var shellRunner = new(exec.ShellRunner) +var shellRunner = new(exec.ShellGitRunner) // ConfigGenParamsStruct - data structure to store parameters passed via cli flags type ConfigGenParamsStruct struct { @@ -97,7 +100,7 @@ type Repo struct { sha string `yaml:"sha,omitempty"` mirrorURL string `yaml:"mirror_url,omitempty"` status RepoStatus // keep track of the repository status after operation to provide summary - executor *exec.ShellRunnerI + executor *exec.GitRunnerI } // RepoList is a slice of Repo structs @@ -216,7 +219,7 @@ func generateSha(input string) string { return fmt.Sprintf("%x", h.Sum(nil))[0:7] } -func (repo *Repo) SetShellRunner(exe exec.ShellRunnerI) { +func (repo *Repo) SetShellRunner(exe exec.GitRunnerI) { repo.executor = &exe } @@ -302,13 +305,25 @@ func (repo *Repo) CloneMirror() bool { // PushMirror runs `git push --mirror` command. func (repo *Repo) PushMirror() bool { - log.Infof("%s: Push repository '%s' as a mirror '%s'", repo.sha, repo.URL, repo.mirrorURL) + log.Infof( + "%s: Push repository '%s' as a mirror '%s'", + repo.sha, + repo.URL, + repo.mirrorURL, + ) + var serr bytes.Buffer - _, err := (*repo.executor).ExecGitCommand([]string{"push", "--mirror", repo.mirrorURL}, nil, &serr, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"push", "--mirror", repo.mirrorURL}, + nil, + &serr, + repo.fullPath, + ) if err != nil { log.Errorf("%s: %v %v", repo.sha, err, serr.String()) return false } + return true } @@ -335,7 +350,15 @@ func (repo *Repo) ShallowClone() bool { log.Infof("%s: Clone repository '%s'", repo.sha, repo.URL) var serr bytes.Buffer _, err := (*repo.executor).ExecGitCommand( - []string{"clone", "--depth", "1", "--branch", repo.Ref, repo.URL, repo.fullPath}, + []string{ + "clone", + "--depth", + "1", + "--branch", + repo.Ref, + repo.URL, + repo.fullPath, + }, nil, &serr, "", @@ -363,11 +386,21 @@ func (repo *Repo) RemoveTargetDir(dotGit bool) { } func (repo *Repo) IsClean() bool { - _, err := (*repo.executor).ExecGitCommand([]string{"diff", "--quiet"}, nil, nil, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"diff", "--quiet"}, + nil, + nil, + repo.fullPath, + ) if err != nil { return false } - _, err = (*repo.executor).ExecGitCommand([]string{"diff", "--staged", "--quiet"}, nil, nil, repo.fullPath) + _, err = (*repo.executor).ExecGitCommand( + []string{"diff", "--staged", "--quiet"}, + nil, + nil, + repo.fullPath, + ) if err != nil { return false } @@ -376,7 +409,12 @@ func (repo *Repo) IsClean() bool { func (repo *Repo) IsCurrentBranchRef() bool { var outb, errb bytes.Buffer - _, err := (*repo.executor).ExecGitCommand([]string{"rev-parse", "--abbrev-ref", "HEAD"}, &outb, &errb, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"rev-parse", "--abbrev-ref", "HEAD"}, + &outb, + &errb, + repo.fullPath, + ) if err != nil { log.Errorf("%s: Error when checking branch %v", repo.sha, err) } @@ -385,7 +423,12 @@ func (repo *Repo) IsCurrentBranchRef() bool { func (repo *Repo) GetCurrentBranch() string { var outb, errb bytes.Buffer - _, err := (*repo.executor).ExecGitCommand([]string{"rev-parse", "--abbrev-ref", "HEAD"}, &outb, &errb, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"rev-parse", "--abbrev-ref", "HEAD"}, + &outb, + &errb, + repo.fullPath, + ) if err != nil { log.Errorf("%s: Error when getting branch %v", repo.sha, err) return "" @@ -396,7 +439,12 @@ func (repo *Repo) GetCurrentBranch() string { func (repo *Repo) GitStashSave() bool { log.Infof("%s: Stash unsaved changes", repo.sha) var serr bytes.Buffer - _, err := (*repo.executor).ExecGitCommand([]string{"stash", "save"}, nil, &serr, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"stash", "save"}, + nil, + &serr, + repo.fullPath, + ) if err != nil { repo.status.Error = true log.Warnf("%s: %v: %v", repo.sha, err, serr.String()) @@ -408,7 +456,12 @@ func (repo *Repo) GitStashSave() bool { func (repo *Repo) GitStashPop() bool { log.Infof("%s: Restore stashed changes", repo.sha) var serr bytes.Buffer - _, err := (*repo.executor).ExecGitCommand([]string{"stash", "pop"}, nil, &serr, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"stash", "pop"}, + nil, + &serr, + repo.fullPath, + ) if err != nil { repo.status.Error = true log.Warnf("%s: %v: %v", repo.sha, err, serr.String()) @@ -417,40 +470,40 @@ func (repo *Repo) GitStashPop() bool { return true } -// IsRefBranch returns true if +// IsRefBranch returns true if branch ref exists func (repo *Repo) IsRefBranch() bool { - fullRef := fmt.Sprintf("refs/heads/%s", repo.Ref) - _, err := (*repo.executor).ExecGitCommand( - []string{"show-ref", "--quiet", "--verify", fullRef}, - nil, - nil, - repo.fullPath, - ) + gitRepo, err := git.PlainOpen(repo.fullPath) if err != nil { return false } - return true + + _, err = gitRepo.Reference( + gitPlumbing.NewBranchReferenceName(repo.Ref), + true, + ) + return err == nil } func (repo *Repo) IsRefTag() bool { - fullRef := fmt.Sprintf("refs/tags/%s", repo.Ref) - _, err := (*repo.executor).ExecGitCommand( - []string{"show-ref", "--quiet", "--verify", fullRef}, - nil, - nil, - repo.fullPath, - ) + gitRepo, err := git.PlainOpen(repo.fullPath) if err != nil { return false } - return true + + _, err = gitRepo.Tag(repo.Ref) + return err == nil } func (repo *Repo) GitPull() { if repo.IsRefBranch() { log.Infof("%s: Pulling upstream changes", repo.sha) var serr bytes.Buffer - _, err := (*repo.executor).ExecGitCommand([]string{"pull", "-f"}, nil, &serr, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"pull", "-f"}, + nil, + &serr, + repo.fullPath, + ) if err != nil { repo.status.Error = true log.Errorf("%s: %v: %v", repo.sha, err, serr.String()) @@ -479,11 +532,21 @@ func (repo *Repo) ProcessRepoBasedOnCleaness() { } func (repo *Repo) GitCheckout(branch string) bool { - log.Infof("%s: Checkout to '%s' branch in '%s'", repo.sha, colorHighlight.Sprintf(branch), repo.fullPath) + log.Infof( + "%s: Checkout to '%s' branch in '%s'", + repo.sha, + colorHighlight.Sprintf(branch), + repo.fullPath, + ) var serr bytes.Buffer res := true - _, err := (*repo.executor).ExecGitCommand([]string{"checkout", branch}, nil, &serr, repo.fullPath) + _, err := (*repo.executor).ExecGitCommand( + []string{"checkout", branch}, + nil, + &serr, + repo.fullPath, + ) if err != nil { repo.status.Error = true log.Warnf("%s: %v: %v", repo.sha, err, serr.String()) @@ -511,7 +574,11 @@ func (repo *Repo) ProcessRepoBasedOnCurrentBranch() { if !stayOnRef { repo.GitCheckout(currentBranch) } else { - log.Debugf("%s: Stay on ref branch '%s'", repo.sha, colorRef.Sprintf(repo.Ref)) + log.Debugf( + "%s: Stay on ref branch '%s'", + repo.sha, + colorRef.Sprintf(repo.Ref), + ) } } } @@ -521,7 +588,11 @@ func (repo *Repo) CreateSymlink(symlink string) { // Check if exists - return exists, _ := PathExists(symlink) if exists { - log.Debugf("%s: path for symlink '%s' exists (may not be symlink, don't care)", repo.sha, symlink) + log.Debugf( + "%s: path for symlink '%s' exists (may not be symlink, don't care)", + repo.sha, + symlink, + ) return } @@ -572,20 +643,49 @@ func (repo *Repo) EnsureMirrorExists() { func (repo *Repo) EnsureGitlabMirrorExists() { // ( a/b/c/d -> a , b , b/c/d, d ) - baseURL, projectNameFullPath, projectNameShort := DecomposeGitURL(repo.mirrorURL) - log.Debugf("%s: For Check: BaseURL: %s projectNameFullPath: %s", repo.sha, baseURL, projectNameFullPath) - log.Debugf("%s: For Create: BaseURL: %s projectNameShort: %s", repo.sha, baseURL, projectNameShort) + baseURL, projectNameFullPath, projectNameShort := DecomposeGitURL( + repo.mirrorURL, + ) + log.Debugf( + "%s: For Check: BaseURL: %s projectNameFullPath: %s", + repo.sha, + baseURL, + projectNameFullPath, + ) + log.Debugf( + "%s: For Create: BaseURL: %s projectNameShort: %s", + repo.sha, + baseURL, + projectNameShort, + ) // In gitlab Project is both - repository and directory to aggregate repositories gitlabObj := gitlab.GitGetGitlab{} gitlabObj.Init() - projectFound := gitlabObj.ProjectExists(repo.sha, baseURL, projectNameFullPath) + projectFound := gitlabObj.ProjectExists( + repo.sha, + baseURL, + projectNameFullPath, + ) if !projectFound { - log.Debugf("%s: Gitlab project '%s' does not exist", repo.sha, projectNameFullPath) + log.Debugf( + "%s: Gitlab project '%s' does not exist", + repo.sha, + projectNameFullPath, + ) // identify if part `b` is a group ? then need to create project differently - potentially create all subgroups - projectNamespace, namespaceFullPath := gitlabObj.GetProjectNamespace(repo.sha, baseURL, projectNameFullPath) - log.Debugf("%s: '%s' is '%+v'", repo.sha, projectNameFullPath, projectNamespace) + projectNamespace, namespaceFullPath := gitlabObj.GetProjectNamespace( + repo.sha, + baseURL, + projectNameFullPath, + ) + log.Debugf( + "%s: '%s' is '%+v'", + repo.sha, + projectNameFullPath, + projectNamespace, + ) // If project namespace exists and is user - create project for user // Otherwise ensure group with subgroups exists and create project in subgroup if projectNamespace != nil { @@ -618,7 +718,9 @@ func (repo *Repo) EnsureGitlabMirrorExists() { // MAYBE: space for improvement - ensure group with subgroups is created, then create project log.Fatalf( "%s: Group '%s' does not exist, please ensure it is created using for mirrors", - repo.sha, namespaceFullPath) + repo.sha, + namespaceFullPath, + ) os.Exit(1) } } @@ -650,10 +752,24 @@ func (repo *Repo) EnsureGithubMirrorExists() { workspaceName, repositoryName := repoNameParts[0], repoNameParts[1] ctx := context.Background() if !github.RepositoryExists(ctx, repo.sha, workspaceName, repositoryName) { - log.Debugf("%s: Creating new github repository '%s'", repo.sha, repo.mirrorURL) - github.CreateRepository(ctx, repo.sha, repositoryName, mirrorVisibilityMode, repo.URL) + log.Debugf( + "%s: Creating new github repository '%s'", + repo.sha, + repo.mirrorURL, + ) + github.CreateRepository( + ctx, + repo.sha, + repositoryName, + mirrorVisibilityMode, + repo.URL, + ) } else { - log.Debugf("%s: github repository '%s' exists", repo.sha, repo.mirrorURL) + log.Debugf( + "%s: github repository '%s' exists", + repo.sha, + repo.mirrorURL, + ) } } @@ -663,10 +779,24 @@ func (repo *Repo) EnsureBitbucketMirrorExists() { repoNameParts := strings.SplitN(fullName, "/", 2) workspaceName, repositoryName := repoNameParts[0], repoNameParts[1] if !bitbucket.RepositoryExists(repo.sha, workspaceName, repositoryName) { - log.Debugf("%s: Creating new bitbucket repository '%s'", repo.sha, repo.mirrorURL) - bitbucket.CreateRepository(repo.sha, fullName, mirrorVisibilityMode, repo.URL, bitbucketMirrorProject) + log.Debugf( + "%s: Creating new bitbucket repository '%s'", + repo.sha, + repo.mirrorURL, + ) + bitbucket.CreateRepository( + repo.sha, + fullName, + mirrorVisibilityMode, + repo.URL, + bitbucketMirrorProject, + ) } else { - log.Debugf("%s: bitbucket repository '%s' exists", repo.sha, repo.mirrorURL) + log.Debugf( + "%s: bitbucket repository '%s' exists", + repo.sha, + repo.mirrorURL, + ) } } diff --git a/go.mod b/go.mod index dc45f2f..e820dab 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,8 @@ go 1.23.4 require ( // https://github.com/fatih/color/releases github.com/fatih/color v1.18.0 + // https://github.com/go-git/go-git/releases + github.com/go-git/go-git/v5 v5.11.0 // https://github.com/google/go-github/releases github.com/google/go-github/v67 v67.0.0 // https://github.com/ktrysmt/go-bitbucket/releases @@ -28,17 +30,36 @@ require ( ) require ( + dario.cat/mergo v1.0.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sergi/go-diff v1.1.0 // indirect + github.com/skeema/knownhosts v1.2.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.2 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + golang.org/x/crypto v0.30.0 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.13.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 079fc88..5fc56b3 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,43 @@ cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= +github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= +github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= +github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= +github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= +github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -22,12 +54,17 @@ github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISH github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -41,15 +78,27 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= +github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -59,6 +108,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -68,17 +119,29 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/xanzy/go-gitlab v0.114.0 h1:0wQr/KBckwrZPfEMjRqpUz0HmsKKON9UhCYv9KDy19M= github.com/xanzy/go-gitlab v0.114.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= @@ -90,13 +153,20 @@ golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -106,30 +176,46 @@ golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 75906638420eb6496e3e825340ab8fc739958542 Mon Sep 17 00:00:00 2001 From: Eriks Zelenka Date: Wed, 11 Sep 2024 14:52:11 +0100 Subject: [PATCH 2/3] Fix typo --- Makefile | 2 +- gitget/get.go | 22 ++- gitget/get_test.go | 106 +++++++---- gitget/git_wrapper.go | 12 ++ gitget/mocks/RepoI.go | 366 ++++++++++++++++++++++++++++++++++++ gitget/mocks/RepositoryI.go | 87 +++++++++ 6 files changed, 547 insertions(+), 48 deletions(-) create mode 100644 gitget/git_wrapper.go create mode 100644 gitget/mocks/RepoI.go create mode 100644 gitget/mocks/RepositoryI.go diff --git a/Makefile b/Makefile index d3d78b9..6d9ad92 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ vet: ## Run go vet against code. .PHONY: mockery mockery: ## Regenerate mock files - for i in exec gitlab; do \ + for i in exec gitlab gitget; do \ (cd $$i; rm -fr mocks; mockery --all) ;\ done diff --git a/gitget/get.go b/gitget/get.go index 39cb3ee..6f710c3 100644 --- a/gitget/get.go +++ b/gitget/get.go @@ -117,9 +117,9 @@ type RepoStatus struct { // RepoI interface defined for mocking purposes. type RepoI interface { + ChoosePathPrefix(pathPrefix string) string Clone() bool CreateSymlink(symlink string) - ChoosePathPrefix(pathPrefix string) string EnsurePathExists() GetCurrentBranch() string GetRepoLocalName() string @@ -132,6 +132,7 @@ type RepoI interface { IsRefBranch() bool IsRefTag() bool PathExists(path string) (bool, os.FileInfo) + PlainOpen(repo RepoI) (*git.Repository, error) PrepareForGet() PrepareForMirror(pathPrefix string, mirrorRootURL string) ProcessRepoBasedOnCleaness() @@ -149,6 +150,11 @@ func initColors() { colorRef = color.New(color.FgHiBlue) } +func (r *Repo) PlainOpen(repo RepoI) (*git.Repository, error) { + gitRepo, err := git.PlainOpen(repo.fullPath) + return gitRepo, err +} + // SetDefaultRef sets in place default name of the ref to master (by default) or user passed via flag if not specified func (repo *Repo) SetDefaultRef() { if repo.Ref == "" { @@ -219,14 +225,14 @@ func generateSha(input string) string { return fmt.Sprintf("%x", h.Sum(nil))[0:7] } -func (repo *Repo) SetShellRunner(exe exec.GitRunnerI) { +func (repo *Repo) SetGitRunner(exe exec.GitRunnerI) { repo.executor = &exe } // PrepareForGet performs checks for repository as well as constructs // extra information and sets repository data structure values. func (repo *Repo) PrepareForGet() { - repo.SetShellRunner(shellRunner) + repo.SetGitRunner(shellRunner) repo.EnsurePathExists("") repo.SetDefaultRef() repo.SetRepoLocalName() @@ -239,7 +245,7 @@ func (repo *Repo) PrepareForGet() { // PrepareForMirror - set repository structure fields for mirror operation func (repo *Repo) PrepareForMirror(pathPrefix string, mirrorRootURL string) { - repo.SetShellRunner(shellRunner) + repo.SetGitRunner(shellRunner) repo.SetTempRepoPathForMirror(pathPrefix) repo.SetDefaultRef() repo.SetRepoLocalName() @@ -471,8 +477,8 @@ func (repo *Repo) GitStashPop() bool { } // IsRefBranch returns true if branch ref exists -func (repo *Repo) IsRefBranch() bool { - gitRepo, err := git.PlainOpen(repo.fullPath) +func (r *Repo) IsRefBranch(repo RepoI) bool { + gitRepo, err := repo.PlainOpen(repo) if err != nil { return false } @@ -485,7 +491,7 @@ func (repo *Repo) IsRefBranch() bool { } func (repo *Repo) IsRefTag() bool { - gitRepo, err := git.PlainOpen(repo.fullPath) + gitRepo, err := repo.PlainOpen() if err != nil { return false } @@ -495,7 +501,7 @@ func (repo *Repo) IsRefTag() bool { } func (repo *Repo) GitPull() { - if repo.IsRefBranch() { + if repo.IsRefBranch(repo) { log.Infof("%s: Pulling upstream changes", repo.sha) var serr bytes.Buffer _, err := (*repo.executor).ExecGitCommand( diff --git a/gitget/get_test.go b/gitget/get_test.go index a15880a..4d9fcff 100644 --- a/gitget/get_test.go +++ b/gitget/get_test.go @@ -10,7 +10,8 @@ import ( "path" "testing" - "github.com/isindir/git-get/exec/mocks" + execMocks "github.com/isindir/git-get/exec/mocks" + gitgetMocks "github.com/isindir/git-get/gitget/mocks" "github.com/stretchr/testify/assert" ) @@ -153,22 +154,23 @@ func Test_SetMirrorURL(t *testing.T) { } } +/* func Test_Repo_IsRefTag(t *testing.T) { type testCase struct { name string repo Repo expectedResult bool - returnError error + plainOpenError error } testCases := []testCase{ - {name: "test 1", expectedResult: true, repo: Repo{Ref: "abc", fullPath: "cde_p"}, returnError: nil}, - {name: "test 2", expectedResult: false, repo: Repo{Ref: "cde", fullPath: "cde_a"}, returnError: fmt.Errorf("test error")}, + {name: "test 1", expectedResult: true, repo: Repo{Ref: "abc", fullPath: "cde_p"}, plainOpenError: nil}, + {name: "test 2", expectedResult: false, repo: Repo{Ref: "cde", fullPath: "cde_a"}, plainOpenError: fmt.Errorf("test error")}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} mockGitExec.On( @@ -176,44 +178,70 @@ func Test_Repo_IsRefTag(t *testing.T) { []string{"show-ref", "--quiet", "--verify", fmt.Sprintf("refs/tags/%s", tc.repo.Ref)}, (*bytes.Buffer)(nil), (*bytes.Buffer)(nil), - tc.repo.fullPath).Return(exe, tc.returnError) + tc.repo.fullPath).Return(exe, tc.plainOpenError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.IsRefTag() assert.Equal(t, tc.expectedResult, result) }) } } +*/ func Test_Repo_IsRefBranch(t *testing.T) { type testCase struct { name string repo Repo expectedResult bool - returnError error + plainOpenError error + referenceError error } testCases := []testCase{ - {name: "test 1", expectedResult: true, repo: Repo{Ref: "abc", fullPath: "cde_p"}, returnError: nil}, - {name: "test 2", expectedResult: false, repo: Repo{Ref: "cde", fullPath: "cde_a"}, returnError: fmt.Errorf("test error")}, + { + name: "No errors", + expectedResult: true, + repo: Repo{Ref: "abc", fullPath: "cde_p"}, + plainOpenError: nil, + referenceError: nil, + }, + { + name: "error on plan open", + expectedResult: false, + repo: Repo{Ref: "cde", fullPath: "cde_a"}, + plainOpenError: fmt.Errorf("test error"), + referenceError: nil, + }, + { + name: "error on reference", + expectedResult: false, + repo: Repo{Ref: "cde", fullPath: "cde_a"}, + plainOpenError: nil, + referenceError: fmt.Errorf("test error"), + }, + { + name: "both errors", + expectedResult: false, + repo: Repo{Ref: "cde", fullPath: "cde_a"}, + plainOpenError: fmt.Errorf("test error"), + referenceError: fmt.Errorf("test error"), + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) - exe := &exec.Cmd{} - - mockGitExec.On( - "ExecGitCommand", - []string{"show-ref", "--quiet", "--verify", fmt.Sprintf("refs/heads/%s", tc.repo.Ref)}, - (*bytes.Buffer)(nil), - (*bytes.Buffer)(nil), - tc.repo.fullPath).Return(exe, tc.returnError) + mockGitgetRepo := new(gitgetMocks.RepoI) + mockGoRepository := new(gitgetMocks.RepositoryI) + mockGitgetRepo.On( + "PlainOpen", + ).Return(mockGoRepository, tc.plainOpenError) - tc.repo.SetShellRunner(mockGitExec) + mockGoRepository.On( + "Reference", + ).Return(nil, tc.referenceError) - result := tc.repo.IsRefBranch() + result := tc.repo.IsRefBranch(mockGitgetRepo) assert.Equal(t, tc.expectedResult, result) }) } @@ -234,7 +262,7 @@ func Test_Repo_GitStashPop(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} serr := &bytes.Buffer{} @@ -245,7 +273,7 @@ func Test_Repo_GitStashPop(t *testing.T) { serr, tc.repo.fullPath).Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.GitStashPop() assert.Equal(t, tc.expectedResult, result) @@ -269,7 +297,7 @@ func Test_Repo_GitStashSave(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} serr := &bytes.Buffer{} @@ -280,7 +308,7 @@ func Test_Repo_GitStashSave(t *testing.T) { serr, tc.repo.fullPath).Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.GitStashSave() assert.Equal(t, tc.expectedResult, result) @@ -304,7 +332,7 @@ func Test_Repo_CloneMirror(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} serr := &bytes.Buffer{} @@ -315,7 +343,7 @@ func Test_Repo_CloneMirror(t *testing.T) { serr, "").Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.CloneMirror() assert.Equal(t, tc.expectedResult, result) @@ -339,7 +367,7 @@ func Test_Repo_GetCurrentBranch(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} var outb, errb bytes.Buffer @@ -350,7 +378,7 @@ func Test_Repo_GetCurrentBranch(t *testing.T) { &errb, tc.repo.fullPath).Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.GetCurrentBranch() assert.Equal(t, tc.expectedResult, result) @@ -380,7 +408,7 @@ func Test_Repo_IsClean(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} mockGitExec.On( @@ -396,7 +424,7 @@ func Test_Repo_IsClean(t *testing.T) { (*bytes.Buffer)(nil), tc.repo.fullPath).Return(exe, tc.err2) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.IsClean() assert.Equal(t, tc.expectedResult, result) @@ -419,7 +447,7 @@ func Test_Repo_ShallowClone(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} serr := &bytes.Buffer{} @@ -430,7 +458,7 @@ func Test_Repo_ShallowClone(t *testing.T) { serr, "").Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.ShallowClone() assert.Equal(t, tc.expectedResult, result) @@ -453,7 +481,7 @@ func Test_Repo_Clone(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} serr := &bytes.Buffer{} @@ -464,7 +492,7 @@ func Test_Repo_Clone(t *testing.T) { serr, "").Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.Clone() assert.Equal(t, tc.expectedResult, result) @@ -487,7 +515,7 @@ func Test_Repo_PushMirror(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} serr := &bytes.Buffer{} @@ -498,7 +526,7 @@ func Test_Repo_PushMirror(t *testing.T) { serr, "").Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) result := tc.repo.PushMirror() assert.Equal(t, tc.expectedResult, result) @@ -553,7 +581,7 @@ func Test_Repo_GitCheckout(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - mockGitExec := new(mocks.ShellRunnerI) + mockGitExec := new(execMocks.GitRunnerI) exe := &exec.Cmd{} serr := &bytes.Buffer{} @@ -564,7 +592,7 @@ func Test_Repo_GitCheckout(t *testing.T) { serr, tc.repo.fullPath).Return(exe, tc.returnError) - tc.repo.SetShellRunner(mockGitExec) + tc.repo.SetGitRunner(mockGitExec) initColors() result := tc.repo.GitCheckout(tc.branch) diff --git a/gitget/git_wrapper.go b/gitget/git_wrapper.go new file mode 100644 index 0000000..09a87d1 --- /dev/null +++ b/gitget/git_wrapper.go @@ -0,0 +1,12 @@ +package gitget + +import ( + gitPlumbing "github.com/go-git/go-git/v5/plumbing" +) + +type RepositoryI interface { + Reference(name gitPlumbing.ReferenceName, resolved bool) (*gitPlumbing.Reference, error) + Tag(name string) (*gitPlumbing.Reference, error) +} + +type Repository struct{} diff --git a/gitget/mocks/RepoI.go b/gitget/mocks/RepoI.go new file mode 100644 index 0000000..20766c1 --- /dev/null +++ b/gitget/mocks/RepoI.go @@ -0,0 +1,366 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package mocks + +import ( + fs "io/fs" + + git "github.com/go-git/go-git/v5" + + mock "github.com/stretchr/testify/mock" +) + +// RepoI is an autogenerated mock type for the RepoI type +type RepoI struct { + mock.Mock +} + +// ChoosePathPrefix provides a mock function with given fields: pathPrefix +func (_m *RepoI) ChoosePathPrefix(pathPrefix string) string { + ret := _m.Called(pathPrefix) + + if len(ret) == 0 { + panic("no return value specified for ChoosePathPrefix") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(pathPrefix) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Clone provides a mock function with given fields: +func (_m *RepoI) Clone() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Clone") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CreateSymlink provides a mock function with given fields: symlink +func (_m *RepoI) CreateSymlink(symlink string) { + _m.Called(symlink) +} + +// EnsurePathExists provides a mock function with given fields: +func (_m *RepoI) EnsurePathExists() { + _m.Called() +} + +// GetCurrentBranch provides a mock function with given fields: +func (_m *RepoI) GetCurrentBranch() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetCurrentBranch") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GetRepoLocalName provides a mock function with given fields: +func (_m *RepoI) GetRepoLocalName() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetRepoLocalName") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// GitCheckout provides a mock function with given fields: branch +func (_m *RepoI) GitCheckout(branch string) bool { + ret := _m.Called(branch) + + if len(ret) == 0 { + panic("no return value specified for GitCheckout") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(branch) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// GitPull provides a mock function with given fields: +func (_m *RepoI) GitPull() { + _m.Called() +} + +// GitStashPop provides a mock function with given fields: +func (_m *RepoI) GitStashPop() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GitStashPop") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// GitStashSave provides a mock function with given fields: +func (_m *RepoI) GitStashSave() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GitStashSave") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsClean provides a mock function with given fields: +func (_m *RepoI) IsClean() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsClean") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsCurrentBranchRef provides a mock function with given fields: +func (_m *RepoI) IsCurrentBranchRef() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsCurrentBranchRef") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsRefBranch provides a mock function with given fields: +func (_m *RepoI) IsRefBranch() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsRefBranch") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsRefTag provides a mock function with given fields: +func (_m *RepoI) IsRefTag() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsRefTag") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// PathExists provides a mock function with given fields: path +func (_m *RepoI) PathExists(path string) (bool, fs.FileInfo) { + ret := _m.Called(path) + + if len(ret) == 0 { + panic("no return value specified for PathExists") + } + + var r0 bool + var r1 fs.FileInfo + if rf, ok := ret.Get(0).(func(string) (bool, fs.FileInfo)); ok { + return rf(path) + } + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(path) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(string) fs.FileInfo); ok { + r1 = rf(path) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(fs.FileInfo) + } + } + + return r0, r1 +} + +// PlainOpen provides a mock function with given fields: +func (_m *RepoI) PlainOpen() (*git.Repository, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for PlainOpen") + } + + var r0 *git.Repository + var r1 error + if rf, ok := ret.Get(0).(func() (*git.Repository, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *git.Repository); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*git.Repository) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PrepareForGet provides a mock function with given fields: +func (_m *RepoI) PrepareForGet() { + _m.Called() +} + +// PrepareForMirror provides a mock function with given fields: pathPrefix, mirrorRootURL +func (_m *RepoI) PrepareForMirror(pathPrefix string, mirrorRootURL string) { + _m.Called(pathPrefix, mirrorRootURL) +} + +// ProcessRepoBasedOnCleaness provides a mock function with given fields: +func (_m *RepoI) ProcessRepoBasedOnCleaness() { + _m.Called() +} + +// ProcessRepoBasedOnCurrentBranch provides a mock function with given fields: +func (_m *RepoI) ProcessRepoBasedOnCurrentBranch() { + _m.Called() +} + +// ProcessSymlinks provides a mock function with given fields: +func (_m *RepoI) ProcessSymlinks() { + _m.Called() +} + +// RepoPathExists provides a mock function with given fields: +func (_m *RepoI) RepoPathExists() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RepoPathExists") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// SetDefaultRef provides a mock function with given fields: +func (_m *RepoI) SetDefaultRef() { + _m.Called() +} + +// SetRepoFullPath provides a mock function with given fields: +func (_m *RepoI) SetRepoFullPath() { + _m.Called() +} + +// SetRepoLocalName provides a mock function with given fields: +func (_m *RepoI) SetRepoLocalName() { + _m.Called() +} + +// SetSha provides a mock function with given fields: +func (_m *RepoI) SetSha() { + _m.Called() +} + +// NewRepoI creates a new instance of RepoI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRepoI(t interface { + mock.TestingT + Cleanup(func()) +}) *RepoI { + mock := &RepoI{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/gitget/mocks/RepositoryI.go b/gitget/mocks/RepositoryI.go new file mode 100644 index 0000000..e1369ff --- /dev/null +++ b/gitget/mocks/RepositoryI.go @@ -0,0 +1,87 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package mocks + +import ( + plumbing "github.com/go-git/go-git/v5/plumbing" + mock "github.com/stretchr/testify/mock" +) + +// RepositoryI is an autogenerated mock type for the RepositoryI type +type RepositoryI struct { + mock.Mock +} + +// Reference provides a mock function with given fields: name, resolved +func (_m *RepositoryI) Reference(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) { + ret := _m.Called(name, resolved) + + if len(ret) == 0 { + panic("no return value specified for Reference") + } + + var r0 *plumbing.Reference + var r1 error + if rf, ok := ret.Get(0).(func(plumbing.ReferenceName, bool) (*plumbing.Reference, error)); ok { + return rf(name, resolved) + } + if rf, ok := ret.Get(0).(func(plumbing.ReferenceName, bool) *plumbing.Reference); ok { + r0 = rf(name, resolved) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*plumbing.Reference) + } + } + + if rf, ok := ret.Get(1).(func(plumbing.ReferenceName, bool) error); ok { + r1 = rf(name, resolved) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Tag provides a mock function with given fields: name +func (_m *RepositoryI) Tag(name string) (*plumbing.Reference, error) { + ret := _m.Called(name) + + if len(ret) == 0 { + panic("no return value specified for Tag") + } + + var r0 *plumbing.Reference + var r1 error + if rf, ok := ret.Get(0).(func(string) (*plumbing.Reference, error)); ok { + return rf(name) + } + if rf, ok := ret.Get(0).(func(string) *plumbing.Reference); ok { + r0 = rf(name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*plumbing.Reference) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewRepositoryI creates a new instance of RepositoryI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRepositoryI(t interface { + mock.TestingT + Cleanup(func()) +}) *RepositoryI { + mock := &RepositoryI{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} From 50aeab0d8a243fcaf782f23ff5908833e47d9861 Mon Sep 17 00:00:00 2001 From: Eriks Zelenka Date: Sat, 7 Dec 2024 09:29:39 +0000 Subject: [PATCH 3/3] Fix typo --- gitget/mocks/RepoI.go | 366 ------------------------------------ gitget/mocks/RepositoryI.go | 87 --------- 2 files changed, 453 deletions(-) delete mode 100644 gitget/mocks/RepoI.go delete mode 100644 gitget/mocks/RepositoryI.go diff --git a/gitget/mocks/RepoI.go b/gitget/mocks/RepoI.go deleted file mode 100644 index 20766c1..0000000 --- a/gitget/mocks/RepoI.go +++ /dev/null @@ -1,366 +0,0 @@ -// Code generated by mockery v2.42.0. DO NOT EDIT. - -package mocks - -import ( - fs "io/fs" - - git "github.com/go-git/go-git/v5" - - mock "github.com/stretchr/testify/mock" -) - -// RepoI is an autogenerated mock type for the RepoI type -type RepoI struct { - mock.Mock -} - -// ChoosePathPrefix provides a mock function with given fields: pathPrefix -func (_m *RepoI) ChoosePathPrefix(pathPrefix string) string { - ret := _m.Called(pathPrefix) - - if len(ret) == 0 { - panic("no return value specified for ChoosePathPrefix") - } - - var r0 string - if rf, ok := ret.Get(0).(func(string) string); ok { - r0 = rf(pathPrefix) - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// Clone provides a mock function with given fields: -func (_m *RepoI) Clone() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Clone") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// CreateSymlink provides a mock function with given fields: symlink -func (_m *RepoI) CreateSymlink(symlink string) { - _m.Called(symlink) -} - -// EnsurePathExists provides a mock function with given fields: -func (_m *RepoI) EnsurePathExists() { - _m.Called() -} - -// GetCurrentBranch provides a mock function with given fields: -func (_m *RepoI) GetCurrentBranch() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetCurrentBranch") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// GetRepoLocalName provides a mock function with given fields: -func (_m *RepoI) GetRepoLocalName() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetRepoLocalName") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// GitCheckout provides a mock function with given fields: branch -func (_m *RepoI) GitCheckout(branch string) bool { - ret := _m.Called(branch) - - if len(ret) == 0 { - panic("no return value specified for GitCheckout") - } - - var r0 bool - if rf, ok := ret.Get(0).(func(string) bool); ok { - r0 = rf(branch) - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// GitPull provides a mock function with given fields: -func (_m *RepoI) GitPull() { - _m.Called() -} - -// GitStashPop provides a mock function with given fields: -func (_m *RepoI) GitStashPop() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GitStashPop") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// GitStashSave provides a mock function with given fields: -func (_m *RepoI) GitStashSave() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GitStashSave") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// IsClean provides a mock function with given fields: -func (_m *RepoI) IsClean() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsClean") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// IsCurrentBranchRef provides a mock function with given fields: -func (_m *RepoI) IsCurrentBranchRef() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsCurrentBranchRef") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// IsRefBranch provides a mock function with given fields: -func (_m *RepoI) IsRefBranch() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsRefBranch") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// IsRefTag provides a mock function with given fields: -func (_m *RepoI) IsRefTag() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsRefTag") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// PathExists provides a mock function with given fields: path -func (_m *RepoI) PathExists(path string) (bool, fs.FileInfo) { - ret := _m.Called(path) - - if len(ret) == 0 { - panic("no return value specified for PathExists") - } - - var r0 bool - var r1 fs.FileInfo - if rf, ok := ret.Get(0).(func(string) (bool, fs.FileInfo)); ok { - return rf(path) - } - if rf, ok := ret.Get(0).(func(string) bool); ok { - r0 = rf(path) - } else { - r0 = ret.Get(0).(bool) - } - - if rf, ok := ret.Get(1).(func(string) fs.FileInfo); ok { - r1 = rf(path) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(fs.FileInfo) - } - } - - return r0, r1 -} - -// PlainOpen provides a mock function with given fields: -func (_m *RepoI) PlainOpen() (*git.Repository, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for PlainOpen") - } - - var r0 *git.Repository - var r1 error - if rf, ok := ret.Get(0).(func() (*git.Repository, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() *git.Repository); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*git.Repository) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// PrepareForGet provides a mock function with given fields: -func (_m *RepoI) PrepareForGet() { - _m.Called() -} - -// PrepareForMirror provides a mock function with given fields: pathPrefix, mirrorRootURL -func (_m *RepoI) PrepareForMirror(pathPrefix string, mirrorRootURL string) { - _m.Called(pathPrefix, mirrorRootURL) -} - -// ProcessRepoBasedOnCleaness provides a mock function with given fields: -func (_m *RepoI) ProcessRepoBasedOnCleaness() { - _m.Called() -} - -// ProcessRepoBasedOnCurrentBranch provides a mock function with given fields: -func (_m *RepoI) ProcessRepoBasedOnCurrentBranch() { - _m.Called() -} - -// ProcessSymlinks provides a mock function with given fields: -func (_m *RepoI) ProcessSymlinks() { - _m.Called() -} - -// RepoPathExists provides a mock function with given fields: -func (_m *RepoI) RepoPathExists() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for RepoPathExists") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// SetDefaultRef provides a mock function with given fields: -func (_m *RepoI) SetDefaultRef() { - _m.Called() -} - -// SetRepoFullPath provides a mock function with given fields: -func (_m *RepoI) SetRepoFullPath() { - _m.Called() -} - -// SetRepoLocalName provides a mock function with given fields: -func (_m *RepoI) SetRepoLocalName() { - _m.Called() -} - -// SetSha provides a mock function with given fields: -func (_m *RepoI) SetSha() { - _m.Called() -} - -// NewRepoI creates a new instance of RepoI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewRepoI(t interface { - mock.TestingT - Cleanup(func()) -}) *RepoI { - mock := &RepoI{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/gitget/mocks/RepositoryI.go b/gitget/mocks/RepositoryI.go deleted file mode 100644 index e1369ff..0000000 --- a/gitget/mocks/RepositoryI.go +++ /dev/null @@ -1,87 +0,0 @@ -// Code generated by mockery v2.42.0. DO NOT EDIT. - -package mocks - -import ( - plumbing "github.com/go-git/go-git/v5/plumbing" - mock "github.com/stretchr/testify/mock" -) - -// RepositoryI is an autogenerated mock type for the RepositoryI type -type RepositoryI struct { - mock.Mock -} - -// Reference provides a mock function with given fields: name, resolved -func (_m *RepositoryI) Reference(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) { - ret := _m.Called(name, resolved) - - if len(ret) == 0 { - panic("no return value specified for Reference") - } - - var r0 *plumbing.Reference - var r1 error - if rf, ok := ret.Get(0).(func(plumbing.ReferenceName, bool) (*plumbing.Reference, error)); ok { - return rf(name, resolved) - } - if rf, ok := ret.Get(0).(func(plumbing.ReferenceName, bool) *plumbing.Reference); ok { - r0 = rf(name, resolved) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*plumbing.Reference) - } - } - - if rf, ok := ret.Get(1).(func(plumbing.ReferenceName, bool) error); ok { - r1 = rf(name, resolved) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Tag provides a mock function with given fields: name -func (_m *RepositoryI) Tag(name string) (*plumbing.Reference, error) { - ret := _m.Called(name) - - if len(ret) == 0 { - panic("no return value specified for Tag") - } - - var r0 *plumbing.Reference - var r1 error - if rf, ok := ret.Get(0).(func(string) (*plumbing.Reference, error)); ok { - return rf(name) - } - if rf, ok := ret.Get(0).(func(string) *plumbing.Reference); ok { - r0 = rf(name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*plumbing.Reference) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(name) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewRepositoryI creates a new instance of RepositoryI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewRepositoryI(t interface { - mock.TestingT - Cleanup(func()) -}) *RepositoryI { - mock := &RepositoryI{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}