v.io/jiri: remove remaining dryrun dead code.
MultiPart: 1/2
Change-Id: I913fae994b5fb5f46e2d8c8bc358b81099bf9fcf
diff --git a/cmd/jiri/cl.go b/cmd/jiri/cl.go
index ac97b13..b600807 100644
--- a/cmd/jiri/cl.go
+++ b/cmd/jiri/cl.go
@@ -616,14 +616,12 @@
}, &e)
// Report an error if the CL is empty.
- if !review.jirix.DryRun() {
- hasDiff, err := gitutil.New(review.jirix.NewSeq()).BranchesDiffer(review.CLOpts.Branch, review.reviewBranch)
- if err != nil {
- return err
- }
- if !hasDiff {
- return emptyChangeError(struct{}{})
- }
+ hasDiff, err := gitutil.New(review.jirix.NewSeq()).BranchesDiffer(review.CLOpts.Branch, review.reviewBranch)
+ if err != nil {
+ return err
+ }
+ if !hasDiff {
+ return emptyChangeError(struct{}{})
}
// If <message> is empty, replace it with the default message.
@@ -861,10 +859,8 @@
// send mails the current branch out for review.
func (review *review) send() error {
- if !review.jirix.DryRun() {
- if err := review.ensureChangeID(); err != nil {
- return err
- }
+ if err := review.ensureChangeID(); err != nil {
+ return err
}
if err := gerrit.Push(review.jirix.NewSeq(), review.CLOpts); err != nil {
return gerritError(err.Error())
diff --git a/profiles/profilesmanager/util.go b/profiles/profilesmanager/util.go
index 337b8cd..38717d1 100644
--- a/profiles/profilesmanager/util.go
+++ b/profiles/profilesmanager/util.go
@@ -23,7 +23,7 @@
default:
return fmt.Errorf("unrecognised action %v", action)
}
- if jirix.Verbose() || jirix.DryRun() {
+ if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%s %v %s\n", verb, action, target)
}
if t := pdb.LookupProfileTarget(installer, profile, target); t != nil {
@@ -41,7 +41,7 @@
return err
}
target.SetVersion(version)
- if jirix.Verbose() || jirix.DryRun() {
+ if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%s %s %s\n", verb, profile, target.DebugString())
}
if action == profiles.Install {
diff --git a/project/project.go b/project/project.go
index b9789ec..5541c37 100644
--- a/project/project.go
+++ b/project/project.go
@@ -1331,10 +1331,6 @@
func InstallTools(jirix *jiri.X, dir string) error {
jirix.TimerPush("install tools")
defer jirix.TimerPop()
- if jirix.DryRun() {
- // In "dry run" mode, no binaries are built.
- return nil
- }
fis, err := ioutil.ReadDir(dir)
if err != nil {
return fmt.Errorf("ReadDir(%v) failed: %v", dir, err)
diff --git a/runutil/.api b/runutil/.api
index c288c41..ffeec6d 100644
--- a/runutil/.api
+++ b/runutil/.api
@@ -3,7 +3,7 @@
pkg runutil, func IsNotExist(error) bool
pkg runutil, func IsPermission(error) bool
pkg runutil, func IsTimeout(error) bool
-pkg runutil, func NewSequence(map[string]string, io.Reader, io.Writer, io.Writer, bool, bool, bool) Sequence
+pkg runutil, func NewSequence(map[string]string, io.Reader, io.Writer, io.Writer, bool, bool) Sequence
pkg runutil, func TranslateExitCode(error) error
pkg runutil, method (*Handle) Kill() error
pkg runutil, method (*Handle) Pid() int
@@ -40,7 +40,7 @@
pkg runutil, method (Sequence) RemoveAll(string) Sequence
pkg runutil, method (Sequence) Rename(string, string) Sequence
pkg runutil, method (Sequence) Run(string, ...string) Sequence
-pkg runutil, method (Sequence) RunOpts() (bool, bool)
+pkg runutil, method (Sequence) RunOpts() bool
pkg runutil, method (Sequence) SetEnv(map[string]string) Sequence
pkg runutil, method (Sequence) Start(string, ...string) (*Handle, error)
pkg runutil, method (Sequence) Stat(string) (os.FileInfo, error)
diff --git a/runutil/sequence.go b/runutil/sequence.go
index 04c459e..65bd400 100644
--- a/runutil/sequence.go
+++ b/runutil/sequence.go
@@ -103,7 +103,7 @@
// environment, stdin, stderr, stdout and other supported options.
// If the environment parameter is nil or empty then the current value of
// os.Environ() will be used instead.
-func NewSequence(env map[string]string, stdin io.Reader, stdout, stderr io.Writer, color, dryRun, verbose bool) Sequence {
+func NewSequence(env map[string]string, stdin io.Reader, stdout, stderr io.Writer, color, verbose bool) Sequence {
if len(env) == 0 {
env = envvar.SliceToMap(os.Environ())
}
@@ -117,11 +117,11 @@
return s
}
-// RunOpts returns the values of dryRun and verbose that were used to
+// RunOpts returns the value of verbose that was used to
// create this sequence.
-func (s Sequence) RunOpts() (dryRun bool, verbose bool) {
+func (s Sequence) RunOpts() (verbose bool) {
opts := s.getOpts()
- return false, opts.verbose
+ return opts.verbose
}
// Capture arranges for the next call to Run or Last to write its stdout and
@@ -866,8 +866,8 @@
return s
}
-// Copy is a wrapper around io.Copy that handles options such as "verbose" or
-// "dry run". Copy is a terminating function.
+// Copy is a wrapper around io.Copy that handles options such as "verbose".
+// Copy is a terminating function.
func (s Sequence) Copy(dst io.Writer, src io.Reader) (n int64, err error) {
if s.err != nil {
return 0, s.Done()
diff --git a/runutil/sequence_test.go b/runutil/sequence_test.go
index 0dab62b..e2b7694 100644
--- a/runutil/sequence_test.go
+++ b/runutil/sequence_test.go
@@ -60,7 +60,7 @@
}
func ExampleSequence() {
- seq := runutil.NewSequence(nil, os.Stdin, ioutil.Discard, ioutil.Discard, false, false, true)
+ seq := runutil.NewSequence(nil, os.Stdin, ioutil.Discard, ioutil.Discard, false, true)
err := seq.
Capture(os.Stdout, nil).Run("echo", "a").
Capture(os.Stdout, nil).Last("echo", "b")
@@ -94,7 +94,7 @@
// stderr.
for _, verbose := range []bool{false, true} {
var cnstrStdout, cnstrStderr bytes.Buffer
- seq := runutil.NewSequence(nil, os.Stdin, &cnstrStdout, &cnstrStderr, false, false, verbose)
+ seq := runutil.NewSequence(nil, os.Stdin, &cnstrStdout, &cnstrStderr, false, verbose)
seq.Run("bash", "-c", "echo a; echo b >&2").
Timeout(time.Microsecond).
Run("sleep", "10000")
@@ -136,7 +136,7 @@
// the command execution errors go to constructor stderr.
for _, verbose := range []bool{false, true} {
var cnstrStdout, cnstrStderr, captureStdout, captureStderr bytes.Buffer
- seq := runutil.NewSequence(nil, os.Stdin, &cnstrStdout, &cnstrStderr, false, false, verbose)
+ seq := runutil.NewSequence(nil, os.Stdin, &cnstrStdout, &cnstrStderr, false, verbose)
seq.Capture(&captureStdout, &captureStderr).
Run("bash", "-c", "echo a; echo b >&2").
Timeout(time.Microsecond).
@@ -166,7 +166,7 @@
// Case 3: we specify stdout/stderr at constructor and use nil
// with Capture to verify that the constructor values are used.
var cnstrStdout, cnstrStderr, captureStdout, captureStderr bytes.Buffer
- seq := runutil.NewSequence(nil, os.Stdin, &cnstrStdout, &cnstrStderr, false, false, false)
+ seq := runutil.NewSequence(nil, os.Stdin, &cnstrStdout, &cnstrStderr, false, false)
err = seq.
Capture(&captureStdout, nil).Run("bash", "-c", "echo a; echo b >&2").
Capture(nil, &captureStderr).Last("bash", "-c", "echo c; echo d >&2")
@@ -186,7 +186,7 @@
}
func TestSequence(t *testing.T) {
- seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
if got, want := seq.Run("echo", "a").Done(), error(nil); got != want {
t.Errorf("got %v, want %v", got, want)
}
@@ -242,7 +242,7 @@
func TestSequenceEnv(t *testing.T) {
// Make sure env provided at construction time is used.
defaultEnv := map[string]string{"A": "dA", "B": "dB"}
- seq := runutil.NewSequence(defaultEnv, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ seq := runutil.NewSequence(defaultEnv, os.Stdin, os.Stdout, os.Stderr, false, true)
var out bytes.Buffer
err := seq.Capture(&out, nil).Last("sh", "-c", "echo $A $B")
if err != nil {
@@ -294,7 +294,7 @@
// Test that modifiers don't get applied beyond the first invocation of Run.
func TestSequenceModifiers(t *testing.T) {
- seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
var out bytes.Buffer
env := map[string]string{
"MYTEST": "hi",
@@ -336,7 +336,7 @@
func TestMoreSequenceModifiers(t *testing.T) {
var stderr, stdout bytes.Buffer
- seq := runutil.NewSequence(nil, os.Stdin, &stdout, &stderr, false, false, true)
+ seq := runutil.NewSequence(nil, os.Stdin, &stdout, &stderr, false, true)
for _, verbose := range []bool{false, true} {
err := seq.Verbose(verbose).Last("sh", "-c", "echo hello")
@@ -363,7 +363,7 @@
var out bytes.Buffer
// Only the output from the command that generates an error is written
// to stderr (i.e. out) when not in verbose mode.
- seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, &out, false, false, false)
+ seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, &out, false, false)
err := seq.Run("sh", "-c", "echo not me").
Run("sh", "-c", "echo ooh; echo ah; echo me; exit 1").
Last("sh", "-c", "echo not me either")
@@ -411,7 +411,7 @@
}
func TestSequenceStreaming(t *testing.T) {
- seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
ts := ×tamped{}
err := seq.
Capture(ts, nil).Last("sh", "-c", `
@@ -435,7 +435,7 @@
}
func TestSequenceTerminatingMethod(t *testing.T) {
- seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ seq := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
filename := "./test-file"
fi, err := os.Create(filename)
if err != nil {
@@ -461,7 +461,7 @@
func TestSequencePushPop(t *testing.T) {
here := getwd(t)
- s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
components := []string{here, "test", "a", "b", "c"}
tree := filepath.Join(components...)
s.MkdirAll(tree, os.FileMode(0755))
@@ -502,7 +502,7 @@
}
func TestExists(t *testing.T) {
- s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
f, err := s.TempFile("", "file-exists")
if err != nil {
t.Fatal(err)
@@ -559,7 +559,7 @@
func TestDirModifier(t *testing.T) {
noError := errors.New("no error")
runner := func(cwd, dir string, ech chan error) {
- s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
var out bytes.Buffer
parent := filepath.Dir(dir)
if err := os.Chdir(parent); err != nil {
@@ -599,7 +599,7 @@
}
func TestStart(t *testing.T) {
- s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, false, true)
+ s := runutil.NewSequence(nil, os.Stdin, os.Stdout, os.Stderr, false, true)
h, err := s.Start("sh", "-c", "sleep 100")
if err != nil {
t.Fatal(err)
@@ -629,7 +629,7 @@
}
dir := "Current Directory: " + cwd + "\n"
var out bytes.Buffer
- s := runutil.NewSequence(nil, os.Stdin, &out, &out, false, false, true)
+ s := runutil.NewSequence(nil, os.Stdin, &out, &out, false, true)
h, err := s.Verbose(false).Start("sh", "-c", "echo hello; echo world; sleep 1; echo wakeup; exit 1")
if err != nil {
t.Fatal(err)
diff --git a/tool/.api b/tool/.api
index 32747af..a565a6d 100644
--- a/tool/.api
+++ b/tool/.api
@@ -5,7 +5,6 @@
pkg tool, func NewDefaultContext() *Context
pkg tool, method (Context) Clone(ContextOpts) *Context
pkg tool, method (Context) Color() bool
-pkg tool, method (Context) DryRun() bool
pkg tool, method (Context) Env() map[string]string
pkg tool, method (Context) Gerrit(*url.URL) *gerrit.Gerrit
pkg tool, method (Context) Jenkins(string) (*jenkins.Jenkins, error)
diff --git a/tool/context.go b/tool/context.go
index c8b0959..7aa75b8 100644
--- a/tool/context.go
+++ b/tool/context.go
@@ -114,11 +114,6 @@
return *ctx.opts.Color
}
-// DryRun returns the dry run setting of the context.
-func (ctx Context) DryRun() bool {
- return false
-}
-
// Env returns the environment of the context.
func (ctx Context) Env() map[string]string {
return ctx.opts.Env
@@ -143,7 +138,7 @@
// NewSeq returns a new instance of Sequence initialized using the options
// stored in the context.
func (ctx Context) NewSeq() runutil.Sequence {
- return runutil.NewSequence(ctx.opts.Env, ctx.opts.Stdin, ctx.opts.Stdout, ctx.opts.Stderr, *ctx.opts.Color, false, *ctx.opts.Verbose)
+ return runutil.NewSequence(ctx.opts.Env, ctx.opts.Stdin, ctx.opts.Stdout, ctx.opts.Stderr, *ctx.opts.Color, *ctx.opts.Verbose)
}
// Stdin returns the standard input of the context.