diff --git a/buildifier/buildifier.go b/buildifier/buildifier.go index 60124fc2b..840490009 100644 --- a/buildifier/buildifier.go +++ b/buildifier/buildifier.go @@ -146,14 +146,10 @@ func main() { build.DisableRewrites = c.DisableRewrites build.AllowSort = c.AllowSort - differ, deprecationWarning := differ.Find() + differ := differ.Find() if c.DiffCommand != "" { differ.Cmd = c.DiffCommand differ.MultiDiff = c.MultiDiff - } else { - if deprecationWarning && c.Mode == "diff" { - fmt.Fprintf(os.Stderr, "buildifier: selecting diff program with the BUILDIFIER_DIFF, BUILDIFIER_MULTIDIFF, and DISPLAY environment variables is deprecated, use flags -diff_command and -multi_diff instead\n") - } } b := buildifier{c, differ} diff --git a/differ/diff.go b/differ/diff.go index 4fe30d257..4f4de0e6c 100644 --- a/differ/diff.go +++ b/differ/diff.go @@ -21,8 +21,6 @@ import ( "fmt" "os" "os/exec" - "runtime" - "strings" ) // Invocation of different diff commands, according to environment variables. @@ -89,46 +87,11 @@ func (d *Differ) Run() error { return d.run(d.Cmd, d.Args...) } -// Find returns the differ to use, using various environment variables. -func Find() (*Differ, bool) { +// Find returns the default differ to use. +func Find() *Differ { d := &Differ{} - deprecationWarning := false - if cmd := os.Getenv("BUILDIFIER_DIFF"); cmd != "" { - deprecationWarning = true - d.Cmd = cmd - } - // Load MultiDiff setting from environment. - knowMultiDiff := false - if md := os.Getenv("BUILDIFIER_MULTIDIFF"); md == "0" || md == "1" { - deprecationWarning = true - d.MultiDiff = md == "1" - knowMultiDiff = true - } + d.Cmd = "diff --unified" - if d.Cmd != "" { - if !knowMultiDiff { - lower := strings.ToLower(d.Cmd) - d.MultiDiff = strings.Contains(lower, "tkdiff") && - isatty(1) && os.Getenv("DISPLAY") != "" - } - } else { - if !knowMultiDiff { - d.MultiDiff = isatty(1) && os.Getenv("DISPLAY") != "" - if d.MultiDiff { - deprecationWarning = true - } - } - if d.MultiDiff { - d.Cmd = "tkdiff" - } else { - if runtime.GOOS == "windows" { - deprecationWarning = true - d.Cmd = "FC" - } else { - d.Cmd = "diff --unified" - } - } - } - return d, deprecationWarning + return d }