Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Hiltunen <shiltunen@gitlab.com>2022-11-15 13:40:54 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2022-11-17 17:44:16 +0300
commit7a54aef42d3dcc7beb4f3c6522fc9674280716b2 (patch)
treed0f183e55f9363085e4abe2ee91a76b6ea06156e
parent0d6dba880d7352c637452d461000988e351dcf5d (diff)
Remove unnecessary contextWithoutDonePanics string type
Command package panics if a command is created without a Done channel. The panic is using a custom type string for some reason. Remove the custom typed string since it doesn't bring a benefit.
-rw-r--r--internal/command/command.go4
-rw-r--r--internal/command/command_test.go2
2 files changed, 2 insertions, 4 deletions
diff --git a/internal/command/command.go b/internal/command/command.go
index f7d6b4c0e..e461b1052 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -155,7 +155,7 @@ type Command struct {
// reaped automatically.
func New(ctx context.Context, nameAndArgs []string, opts ...Option) (*Command, error) {
if ctx.Done() == nil {
- panic(contextWithoutDonePanic("command spawned with context without Done() channel"))
+ panic("command spawned with context without Done() channel")
}
if len(nameAndArgs) == 0 {
@@ -488,8 +488,6 @@ func (c *Command) Pid() int {
return c.cmd.Process.Pid
}
-type contextWithoutDonePanic string
-
var getSpawnTokenAcquiringSeconds = func(t time.Time) float64 {
return time.Since(t).Seconds()
}
diff --git a/internal/command/command_test.go b/internal/command/command_test.go
index 3268b2f84..2dd42f317 100644
--- a/internal/command/command_test.go
+++ b/internal/command/command_test.go
@@ -145,7 +145,7 @@ func TestNew_unexportedEnv(t *testing.T) {
func TestNew_rejectContextWithoutDone(t *testing.T) {
t.Parallel()
- require.PanicsWithValue(t, contextWithoutDonePanic("command spawned with context without Done() channel"), func() {
+ require.PanicsWithValue(t, "command spawned with context without Done() channel", func() {
_, err := New(testhelper.ContextWithoutCancel(), []string{"true"})
require.NoError(t, err)
})