From d77d43f46c6580f9276754ab3d85b462afc7d0b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 May 2023 20:04:45 +0000 Subject: [PATCH] build(deps): bump github.com/gogs/git-module from 1.8.0 to 1.8.2 Bumps [github.com/gogs/git-module](https://github.com/gogs/git-module) from 1.8.0 to 1.8.2. - [Release notes](https://github.com/gogs/git-module/releases) - [Commits](https://github.com/gogs/git-module/compare/v1.8.0...v1.8.2) --- updated-dependencies: - dependency-name: github.com/gogs/git-module dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 +- go.sum | 12 +- vendor/github.com/gogs/git-module/command.go | 146 +++++++++++++----- vendor/github.com/gogs/git-module/repo.go | 28 ++++ .../github.com/gogs/git-module/repo_blame.go | 2 + .../github.com/gogs/git-module/repo_blob.go | 2 + .../github.com/gogs/git-module/repo_commit.go | 2 + .../github.com/gogs/git-module/repo_diff.go | 2 + .../github.com/gogs/git-module/repo_grep.go | 2 + .../github.com/gogs/git-module/repo_pull.go | 2 + .../gogs/git-module/repo_reference.go | 21 ++- .../github.com/gogs/git-module/repo_remote.go | 16 ++ vendor/github.com/gogs/git-module/repo_tag.go | 14 +- .../github.com/gogs/git-module/repo_tree.go | 2 + .../github.com/gogs/git-module/tree_entry.go | 4 +- .../stretchr/testify/assert/assertions.go | 78 ++++------ vendor/modules.txt | 4 +- 17 files changed, 241 insertions(+), 100 deletions(-) diff --git a/go.mod b/go.mod index 5c27c4c..4d8f2bd 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/sermojohn/gitmono go 1.17 require ( - github.com/gogs/git-module v1.8.0 + github.com/gogs/git-module v1.8.2 github.com/google/go-cmdtest v0.4.0 github.com/hashicorp/go-version v1.6.0 github.com/jessevdk/go-flags v1.5.0 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.2 ) require ( diff --git a/go.sum b/go.sum index 9fc2c1d..ba1e3cc 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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/gogs/git-module v1.8.0 h1:IecGCQ0kCm0c7SFwUYcLXtfCbUb8V3Z6KJA0+WQMzms= -github.com/gogs/git-module v1.8.0/go.mod h1:Y3rsSqtFZEbn7lp+3gWf42GKIY1eNTtLt7JrmOy0yAQ= +github.com/gogs/git-module v1.8.2 h1:fwvSMjc51d5bBG3Q2OyFF8HTZFDVbETQ+mSAvfXebQw= +github.com/gogs/git-module v1.8.2/go.mod h1:GUSSUH+RM7fZOtjhS6Obh4B9aAvs3EeROpazfMNMF8g= github.com/google/go-cmdtest v0.4.0 h1:ToXh6W5spLp3npJV92tk6d5hIpUPYEzHLkD+rncbyhI= github.com/google/go-cmdtest v0.4.0/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o= github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= @@ -22,10 +22,10 @@ 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/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 h1:RX8C8PRZc2hTIod4ds8ij+/4RQX3AqhYj3uOHmyaz4E= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/vendor/github.com/gogs/git-module/command.go b/vendor/github.com/gogs/git-module/command.go index bdc366d..4dc5f01 100644 --- a/vendor/github.com/gogs/git-module/command.go +++ b/vendor/github.com/gogs/git-module/command.go @@ -17,15 +17,22 @@ import ( // Command contains the name, arguments and environment variables of a command. type Command struct { - name string - args []string - envs []string + name string + args []string + envs []string + timeout time.Duration + ctx context.Context } // CommandOptions contains options for running a command. +// If timeout is zero, DefaultTimeout will be used. +// If timeout is less than zero, no timeout will be set. +// If context is nil, context.Background() will be used. type CommandOptions struct { - Args []string - Envs []string + Args []string + Envs []string + Timeout time.Duration + Context context.Context } // String returns the string representation of the command. @@ -38,9 +45,16 @@ func (c *Command) String() string { // NewCommand creates and returns a new Command with given arguments for "git". func NewCommand(args ...string) *Command { + return NewCommandWithContext(context.Background(), args...) +} + +// NewCommandWithContext creates and returns a new Command with given arguments +// and context for "git". +func NewCommandWithContext(ctx context.Context, args ...string) *Command { return &Command{ name: "git", args: args, + ctx: ctx, } } @@ -56,9 +70,29 @@ func (c *Command) AddEnvs(envs ...string) *Command { return c } +// WithContext returns a new Command with the given context. +func (c Command) WithContext(ctx context.Context) *Command { + c.ctx = ctx + return &c +} + +// WithTimeout returns a new Command with given timeout. +func (c Command) WithTimeout(timeout time.Duration) *Command { + c.timeout = timeout + return &c +} + +// SetTimeout sets the timeout for the command. +func (c *Command) SetTimeout(timeout time.Duration) { + c.timeout = timeout +} + // AddOptions adds options to the command. +// Note: only the last option will take effect if there are duplicated options. func (c *Command) AddOptions(opts ...CommandOptions) *Command { for _, opt := range opts { + c.timeout = opt.Timeout + c.ctx = opt.Context c.AddArgs(opt.Args...) c.AddEnvs(opt.Envs...) } @@ -111,6 +145,8 @@ type RunInDirOptions struct { // Stderr is the error output from the command. Stderr io.Writer // Timeout is the duration to wait before timing out. + // + // Deprecated: Use CommandOptions.Timeout or *Command.WithTimeout instead. Timeout time.Duration } @@ -124,8 +160,15 @@ func (c *Command) RunInDirWithOptions(dir string, opts ...RunInDirOptions) (err if len(opts) > 0 { opt = opts[0] } - if opt.Timeout < time.Nanosecond { - opt.Timeout = DefaultTimeout + + timeout := c.timeout + // TODO: remove this in newer version + if opt.Timeout > 0 { + timeout = opt.Timeout + } + + if timeout == 0 { + timeout = DefaultTimeout } buf := new(bytes.Buffer) @@ -141,19 +184,27 @@ func (c *Command) RunInDirWithOptions(dir string, opts ...RunInDirOptions) (err defer func() { if len(dir) == 0 { - log("[timeout: %v] %s\n%s", opt.Timeout, c, buf.Bytes()) + log("[timeout: %v] %s\n%s", timeout, c, buf.Bytes()) } else { - log("[timeout: %v] %s: %s\n%s", opt.Timeout, dir, c, buf.Bytes()) + log("[timeout: %v] %s: %s\n%s", timeout, dir, c, buf.Bytes()) } }() - ctx, cancel := context.WithTimeout(context.Background(), opt.Timeout) - defer func() { - cancel() - if err == context.DeadlineExceeded { - err = ErrExecTimeout - } - }() + ctx := context.Background() + if c.ctx != nil { + ctx = c.ctx + } + + if timeout > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, timeout) + defer func() { + cancel() + if err == context.DeadlineExceeded { + err = ErrExecTimeout + } + }() + } cmd := exec.CommandContext(ctx, c.name, c.args...) if len(c.envs) > 0 { @@ -188,55 +239,72 @@ func (c *Command) RunInDirWithOptions(dir string, opts ...RunInDirOptions) (err } +// RunInDirPipeline executes the command in given directory and default timeout +// duration. It pipes stdout and stderr to supplied io.Writer. +func (c *Command) RunInDirPipeline(stdout, stderr io.Writer, dir string) error { + return c.RunInDirWithOptions(dir, RunInDirOptions{ + Stdin: nil, + Stdout: stdout, + Stderr: stderr, + }) +} + // RunInDirPipelineWithTimeout executes the command in given directory and // timeout duration. It pipes stdout and stderr to supplied io.Writer. // DefaultTimeout will be used if the timeout duration is less than // time.Nanosecond (i.e. less than or equal to 0). It returns an ErrExecTimeout // if the execution was timed out. +// +// Deprecated: Use RunInDirPipeline and CommandOptions instead. +// TODO: remove this in the next major version func (c *Command) RunInDirPipelineWithTimeout(timeout time.Duration, stdout, stderr io.Writer, dir string) (err error) { - return c.RunInDirWithOptions(dir, RunInDirOptions{ - Stdin: nil, - Stdout: stdout, - Stderr: stderr, - Timeout: timeout, - }) -} - -// RunInDirPipeline executes the command in given directory and default timeout -// duration. It pipes stdout and stderr to supplied io.Writer. -func (c *Command) RunInDirPipeline(stdout, stderr io.Writer, dir string) error { - return c.RunInDirPipelineWithTimeout(DefaultTimeout, stdout, stderr, dir) + if timeout != 0 { + c = c.WithTimeout(timeout) + } + return c.RunInDirPipeline(stdout, stderr, dir) } // RunInDirWithTimeout executes the command in given directory and timeout // duration. It returns stdout in []byte and error (combined with stderr). +// +// Deprecated: Use RunInDir and CommandOptions instead. +// TODO: remove this in the next major version func (c *Command) RunInDirWithTimeout(timeout time.Duration, dir string) ([]byte, error) { - stdout := new(bytes.Buffer) - stderr := new(bytes.Buffer) - if err := c.RunInDirPipelineWithTimeout(timeout, stdout, stderr, dir); err != nil { - return nil, concatenateError(err, stderr.String()) + if timeout != 0 { + c = c.WithTimeout(timeout) } - return stdout.Bytes(), nil + return c.RunInDir(dir) } // RunInDir executes the command in given directory and default timeout // duration. It returns stdout and error (combined with stderr). func (c *Command) RunInDir(dir string) ([]byte, error) { - return c.RunInDirWithTimeout(DefaultTimeout, dir) + stdout := new(bytes.Buffer) + stderr := new(bytes.Buffer) + if err := c.RunInDirPipeline(stdout, stderr, dir); err != nil { + return nil, concatenateError(err, stderr.String()) + } + return stdout.Bytes(), nil } // RunWithTimeout executes the command in working directory and given timeout // duration. It returns stdout in string and error (combined with stderr). +// +// Deprecated: Use RunInDir and CommandOptions instead. +// TODO: remove this in the next major version func (c *Command) RunWithTimeout(timeout time.Duration) ([]byte, error) { - stdout, err := c.RunInDirWithTimeout(timeout, "") - if err != nil { - return nil, err + if timeout != 0 { + c = c.WithTimeout(timeout) } - return stdout, nil + return c.Run() } // Run executes the command in working directory and default timeout duration. // It returns stdout in string and error (combined with stderr). func (c *Command) Run() ([]byte, error) { - return c.RunWithTimeout(DefaultTimeout) + stdout, err := c.RunInDir("") + if err != nil { + return nil, err + } + return stdout, nil } diff --git a/vendor/github.com/gogs/git-module/repo.go b/vendor/github.com/gogs/git-module/repo.go index e53327d..769a23b 100644 --- a/vendor/github.com/gogs/git-module/repo.go +++ b/vendor/github.com/gogs/git-module/repo.go @@ -60,6 +60,8 @@ type InitOptions struct { Bare bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -119,6 +121,8 @@ type CloneOptions struct { Depth uint64 // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -165,6 +169,8 @@ type FetchOptions struct { Prune bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -200,6 +206,8 @@ type PullOptions struct { Branch string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -236,6 +244,8 @@ func (r *Repository) Pull(opts ...PullOptions) error { type PushOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -272,6 +282,8 @@ type CheckoutOptions struct { BaseBranch string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -315,6 +327,8 @@ type ResetOptions struct { Hard bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -353,6 +367,8 @@ func (r *Repository) Reset(rev string, opts ...ResetOptions) error { type MoveOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -391,6 +407,8 @@ type AddOptions struct { Pathspecs []string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -433,6 +451,8 @@ type CommitOptions struct { Author *Signature // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -488,6 +508,8 @@ type NameStatus struct { type ShowNameStatusOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -554,6 +576,8 @@ func (r *Repository) ShowNameStatus(rev string, opts ...ShowNameStatusOptions) ( type RevParseOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -598,6 +622,8 @@ type CountObject struct { type CountObjectsOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -663,6 +689,8 @@ func (r *Repository) CountObjects(opts ...CountObjectsOptions) (*CountObject, er type FsckOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_blame.go b/vendor/github.com/gogs/git-module/repo_blame.go index d9b46b9..9ac4cae 100644 --- a/vendor/github.com/gogs/git-module/repo_blame.go +++ b/vendor/github.com/gogs/git-module/repo_blame.go @@ -14,6 +14,8 @@ import ( type BlameOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_blob.go b/vendor/github.com/gogs/git-module/repo_blob.go index e9f04c0..4d9bfc2 100644 --- a/vendor/github.com/gogs/git-module/repo_blob.go +++ b/vendor/github.com/gogs/git-module/repo_blob.go @@ -12,6 +12,8 @@ import "time" type CatFileBlobOptions struct { // The timeout duration before giving up for each shell command execution. // The default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_commit.go b/vendor/github.com/gogs/git-module/repo_commit.go index f7ce3bc..e4049a6 100644 --- a/vendor/github.com/gogs/git-module/repo_commit.go +++ b/vendor/github.com/gogs/git-module/repo_commit.go @@ -72,6 +72,8 @@ loop: type CatFileCommitOptions struct { // The timeout duration before giving up for each shell command execution. // The default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_diff.go b/vendor/github.com/gogs/git-module/repo_diff.go index 430bf94..87848bb 100644 --- a/vendor/github.com/gogs/git-module/repo_diff.go +++ b/vendor/github.com/gogs/git-module/repo_diff.go @@ -20,6 +20,8 @@ type DiffOptions struct { Base string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_grep.go b/vendor/github.com/gogs/git-module/repo_grep.go index e091914..81f6e30 100644 --- a/vendor/github.com/gogs/git-module/repo_grep.go +++ b/vendor/github.com/gogs/git-module/repo_grep.go @@ -27,6 +27,8 @@ type GrepOptions struct { ExtendedRegexp bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_pull.go b/vendor/github.com/gogs/git-module/repo_pull.go index 6f0c7bd..111347d 100644 --- a/vendor/github.com/gogs/git-module/repo_pull.go +++ b/vendor/github.com/gogs/git-module/repo_pull.go @@ -15,6 +15,8 @@ import ( type MergeBaseOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_reference.go b/vendor/github.com/gogs/git-module/repo_reference.go index 92a08d2..c4d1c69 100644 --- a/vendor/github.com/gogs/git-module/repo_reference.go +++ b/vendor/github.com/gogs/git-module/repo_reference.go @@ -39,7 +39,11 @@ type Reference struct { type ShowRefVerifyOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration + // The additional options to be passed to the underlying git. + CommandOptions } var ErrReferenceNotExist = errors.New("reference does not exist") @@ -52,7 +56,8 @@ func ShowRefVerify(repoPath, ref string, opts ...ShowRefVerifyOptions) (string, opt = opts[0] } - stdout, err := NewCommand("show-ref", "--verify", ref).RunInDirWithTimeout(opt.Timeout, repoPath) + cmd := NewCommand("show-ref", "--verify", ref).AddOptions(opt.CommandOptions) + stdout, err := cmd.RunInDirWithTimeout(opt.Timeout, repoPath) if err != nil { if strings.Contains(err.Error(), "not a valid ref") { return "", ErrReferenceNotExist @@ -137,7 +142,11 @@ type SymbolicRefOptions struct { Ref string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration + // The additional options to be passed to the underlying git. + CommandOptions } // SymbolicRef returns the reference name (e.g. "refs/heads/master") pointed by @@ -149,7 +158,7 @@ func SymbolicRef(repoPath string, opts ...SymbolicRefOptions) (string, error) { opt = opts[0] } - cmd := NewCommand("symbolic-ref") + cmd := NewCommand("symbolic-ref").AddOptions(opt.CommandOptions) if opt.Name == "" { opt.Name = "HEAD" } @@ -184,6 +193,8 @@ type ShowRefOptions struct { Patterns []string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -250,7 +261,11 @@ type DeleteBranchOptions struct { Force bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration + // The additional options to be passed to the underlying git. + CommandOptions } // DeleteBranch deletes the branch from the repository in given path. @@ -260,7 +275,7 @@ func DeleteBranch(repoPath, name string, opts ...DeleteBranchOptions) error { opt = opts[0] } - cmd := NewCommand("branch") + cmd := NewCommand("branch").AddOptions(opt.CommandOptions) if opt.Force { cmd.AddArgs("-D") } else { diff --git a/vendor/github.com/gogs/git-module/repo_remote.go b/vendor/github.com/gogs/git-module/repo_remote.go index 8a97afe..d8b110d 100644 --- a/vendor/github.com/gogs/git-module/repo_remote.go +++ b/vendor/github.com/gogs/git-module/repo_remote.go @@ -25,6 +25,8 @@ type LsRemoteOptions struct { Patterns []string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -94,6 +96,8 @@ type RemoteAddOptions struct { MirrorFetch bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -143,6 +147,8 @@ func (r *Repository) AddRemote(name, url string, opts ...RemoteAddOptions) error type RemoteRemoveOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -194,6 +200,8 @@ func (r *Repository) RemoveRemote(name string, opts ...RemoteRemoveOptions) erro type RemotesOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -233,6 +241,8 @@ type RemoteGetURLOptions struct { All bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -276,6 +286,8 @@ type RemoteSetURLOptions struct { Regex string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -327,6 +339,8 @@ type RemoteSetURLAddOptions struct { Push bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -371,6 +385,8 @@ type RemoteSetURLDeleteOptions struct { Push bool // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/repo_tag.go b/vendor/github.com/gogs/git-module/repo_tag.go index 475f062..e584370 100644 --- a/vendor/github.com/gogs/git-module/repo_tag.go +++ b/vendor/github.com/gogs/git-module/repo_tag.go @@ -104,6 +104,8 @@ func (r *Repository) getTag(timeout time.Duration, id *SHA1) (*Tag, error) { type TagOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -152,6 +154,8 @@ type TagsOptions struct { Pattern string // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -222,6 +226,8 @@ type CreateTagOptions struct { Author *Signature // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions @@ -257,7 +263,11 @@ func (r *Repository) CreateTag(name, rev string, opts ...CreateTagOptions) error type DeleteTagOptions struct { // The timeout duration before giving up for each shell command execution. // The default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration + // The additional options to be passed to the underlying git. + CommandOptions } // DeleteTag deletes a tag from the repository. @@ -267,6 +277,8 @@ func (r *Repository) DeleteTag(name string, opts ...DeleteTagOptions) error { opt = opts[0] } - _, err := NewCommand("tag", "--delete", name).RunInDirWithTimeout(opt.Timeout, r.path) + _, err := NewCommand("tag", "--delete", name). + AddOptions(opt.CommandOptions). + RunInDirWithTimeout(opt.Timeout, r.path) return err } diff --git a/vendor/github.com/gogs/git-module/repo_tree.go b/vendor/github.com/gogs/git-module/repo_tree.go index 394d7b0..d1a3f46 100644 --- a/vendor/github.com/gogs/git-module/repo_tree.go +++ b/vendor/github.com/gogs/git-module/repo_tree.go @@ -91,6 +91,8 @@ func parseTree(t *Tree, data []byte) ([]*TreeEntry, error) { type LsTreeOptions struct { // The timeout duration before giving up for each shell command execution. The // default timeout duration will be used when not supplied. + // + // Deprecated: Use CommandOptions.Timeout instead. Timeout time.Duration // The additional options to be passed to the underlying git. CommandOptions diff --git a/vendor/github.com/gogs/git-module/tree_entry.go b/vendor/github.com/gogs/git-module/tree_entry.go index cac8764..8fdf251 100644 --- a/vendor/github.com/gogs/git-module/tree_entry.go +++ b/vendor/github.com/gogs/git-module/tree_entry.go @@ -243,10 +243,10 @@ func (es Entries) CommitsInfo(commit *Commit, opts ...CommitsInfoOptions) ([]*En // Get extra information for submodules if e.IsCommit() { + // Be tolerant to implicit submodules info.Submodule, err = commit.Submodule(epath) if err != nil { - setError(fmt.Errorf("get submodule %q: %v", epath, err)) - return + info.Submodule = &Submodule{Name: epath} } } diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index fa1245b..2924cf3 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -8,7 +8,6 @@ import ( "fmt" "math" "os" - "path/filepath" "reflect" "regexp" "runtime" @@ -141,12 +140,11 @@ func CallerInfo() []string { } parts := strings.Split(file, "/") - file = parts[len(parts)-1] if len(parts) > 1 { + filename := parts[len(parts)-1] dir := parts[len(parts)-2] - if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { - path, _ := filepath.Abs(file) - callers = append(callers, fmt.Sprintf("%s:%d", path, line)) + if (dir != "assert" && dir != "mock" && dir != "require") || filename == "mock_test.go" { + callers = append(callers, fmt.Sprintf("%s:%d", file, line)) } } @@ -530,7 +528,7 @@ func isNil(object interface{}) bool { []reflect.Kind{ reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, - reflect.Ptr, reflect.Slice}, + reflect.Ptr, reflect.Slice, reflect.UnsafePointer}, kind) if isNilableKind && value.IsNil() { @@ -818,49 +816,44 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok return true // we consider nil to be equal to the nil set } - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) } + subsetKind := reflect.TypeOf(subset).Kind() if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) } - subsetValue := reflect.ValueOf(subset) if subsetKind == reflect.Map && listKind == reflect.Map { - listValue := reflect.ValueOf(list) - subsetKeys := subsetValue.MapKeys() + subsetMap := reflect.ValueOf(subset) + actualMap := reflect.ValueOf(list) - for i := 0; i < len(subsetKeys); i++ { - subsetKey := subsetKeys[i] - subsetElement := subsetValue.MapIndex(subsetKey).Interface() - listElement := listValue.MapIndex(subsetKey).Interface() + for _, k := range subsetMap.MapKeys() { + ev := subsetMap.MapIndex(k) + av := actualMap.MapIndex(k) - if !ObjectsAreEqual(subsetElement, listElement) { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, subsetElement), msgAndArgs...) + if !av.IsValid() { + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) + } + if !ObjectsAreEqual(ev.Interface(), av.Interface()) { + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) } } return true } - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() + subsetList := reflect.ValueOf(subset) + for i := 0; i < subsetList.Len(); i++ { + element := subsetList.Index(i).Interface() ok, found := containsElement(list, element) if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", list), msgAndArgs...) } if !found { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, element), msgAndArgs...) } } @@ -879,34 +872,28 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...) } - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) } + subsetKind := reflect.TypeOf(subset).Kind() if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) } - subsetValue := reflect.ValueOf(subset) if subsetKind == reflect.Map && listKind == reflect.Map { - listValue := reflect.ValueOf(list) - subsetKeys := subsetValue.MapKeys() + subsetMap := reflect.ValueOf(subset) + actualMap := reflect.ValueOf(list) - for i := 0; i < len(subsetKeys); i++ { - subsetKey := subsetKeys[i] - subsetElement := subsetValue.MapIndex(subsetKey).Interface() - listElement := listValue.MapIndex(subsetKey).Interface() + for _, k := range subsetMap.MapKeys() { + ev := subsetMap.MapIndex(k) + av := actualMap.MapIndex(k) - if !ObjectsAreEqual(subsetElement, listElement) { + if !av.IsValid() { + return true + } + if !ObjectsAreEqual(ev.Interface(), av.Interface()) { return true } } @@ -914,8 +901,9 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) } - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() + subsetList := reflect.ValueOf(subset) + for i := 0; i < subsetList.Len(); i++ { + element := subsetList.Index(i).Interface() ok, found := containsElement(list, element) if !ok { return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) diff --git a/vendor/modules.txt b/vendor/modules.txt index aa770bc..c6cf653 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/gogs/git-module v1.8.0 +# github.com/gogs/git-module v1.8.2 ## explicit; go 1.16 github.com/gogs/git-module # github.com/google/go-cmdtest v0.4.0 @@ -29,7 +29,7 @@ github.com/mcuadros/go-version # github.com/pmezard/go-difflib v1.0.0 ## explicit github.com/pmezard/go-difflib/difflib -# github.com/stretchr/testify v1.8.1 +# github.com/stretchr/testify v1.8.2 ## explicit; go 1.13 github.com/stretchr/testify/assert # golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79