Skip to content

Commit

Permalink
Remove obsolete "Verbose" context property
Browse files Browse the repository at this point in the history
This property will always have its default value of `false`, so any code
that requires it to be set is dead.
  • Loading branch information
kpitt committed Sep 27, 2022
1 parent 4db28d5 commit 38a8230
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
7 changes: 0 additions & 7 deletions internal/backend/storage/gitfs/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"bytes"
"context"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -129,11 +127,6 @@ func (g *Git) captureCmd(ctx context.Context, name string, args ...string) ([]by
cmd.Stdout = bufOut
cmd.Stderr = bufErr

if debug.IsEnabled() && ctxutil.IsVerbose(ctx) {
cmd.Stdout = io.MultiWriter(bufOut, os.Stdout)
cmd.Stderr = io.MultiWriter(bufErr, os.Stderr)
}

debug.Log("store.%s: %s %+v (%s)", name, cmd.Path, cmd.Args, g.fs.Path())
err := cmd.Run()

Expand Down
17 changes: 0 additions & 17 deletions pkg/ctxutil/ctxutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,6 @@ func IsAlwaysYes(ctx context.Context) bool {
return bv
}

// WithVerbose returns a context with the value for verbose set.
func WithVerbose(ctx context.Context, verbose bool) context.Context {
return context.WithValue(ctx, ctxKeyVerbose, verbose)
}

// HasVerbose returns true if a value for Verbose has been set in this context.
func HasVerbose(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyVerbose).(bool)

return ok
}

// IsVerbose returns the value of verbose or the default (false).
func IsVerbose(ctx context.Context) bool {
return is(ctx, ctxKeyVerbose, false)
}

// WithProgressCallback returns a context with the value of ProgressCallback set.
func WithProgressCallback(ctx context.Context, cb ProgressCallback) context.Context {
return context.WithValue(ctx, ctxKeyProgressCallback, cb)
Expand Down
14 changes: 0 additions & 14 deletions pkg/ctxutil/ctxutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ func TestAlwaysYes(t *testing.T) {
assert.Equal(t, false, IsAlwaysYes(WithAlwaysYes(ctx, false)))
}

func TestVerbose(t *testing.T) {
t.Parallel()

ctx := context.Background()

assert.Equal(t, false, IsVerbose(ctx))
assert.Equal(t, true, IsVerbose(WithVerbose(ctx, true)))
assert.Equal(t, false, IsVerbose(WithVerbose(ctx, false)))
}

func TestProgressCallback(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -152,7 +142,6 @@ func TestComposite(t *testing.T) {
ctx = WithShowSafeContent(ctx, true)
ctx = WithGitCommit(ctx, false)
ctx = WithAlwaysYes(ctx, true)
ctx = WithVerbose(ctx, true)
ctx = WithExportKeys(ctx, false)
ctx = WithEmail(ctx, "foo@bar.com")
ctx = WithUsername(ctx, "foo")
Expand Down Expand Up @@ -182,9 +171,6 @@ func TestComposite(t *testing.T) {
assert.Equal(t, true, IsAlwaysYes(ctx))
assert.Equal(t, true, HasAlwaysYes(ctx))

assert.Equal(t, true, IsVerbose(ctx))
assert.Equal(t, true, HasVerbose(ctx))

assert.Equal(t, false, IsExportKeys(ctx))
assert.Equal(t, true, HasExportKeys(ctx))

Expand Down

0 comments on commit 38a8230

Please sign in to comment.