Skip to content

Commit aed1e72

Browse files
Remove unused stdinInteractiveOK and go-isatty dependency
The helper was never called from production paths (only tests). Dropping it removes dead code and the direct github.com/mattn/go-isatty module require. Co-authored-by: Ben Schellenberger <bschellenberger2600@users.noreply.github.com>
1 parent 265e6e7 commit aed1e72

4 files changed

Lines changed: 5 additions & 42 deletions

File tree

cmd/root.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"sync/atomic"
1717
"time"
1818

19-
"github.com/mattn/go-isatty"
2019
"github.com/mattn/go-runewidth"
2120
"github.com/spf13/cobra"
2221

@@ -627,22 +626,6 @@ func scanProgressPathMaxLen(prefix string) int {
627626
return dynamic
628627
}
629628

630-
// stdinInteractiveOK reports whether stdin is suitable for blocking prompts.
631-
// Always false under CI / known automation env vars or GIT_RAIN_NON_INTERACTIVE.
632-
func stdinInteractiveOK() bool {
633-
if os.Getenv("CI") != "" || os.Getenv("GITHUB_ACTIONS") != "" {
634-
return false
635-
}
636-
if os.Getenv("GIT_RAIN_NON_INTERACTIVE") != "" {
637-
return false
638-
}
639-
if _, err := os.Stdin.Stat(); err != nil {
640-
return false
641-
}
642-
fd := os.Stdin.Fd()
643-
return isatty.IsTerminal(fd) || isatty.IsCygwinTerminal(fd)
644-
}
645-
646629
// runRainDefaultStream is the default live-run path for `git-rain` (no flags
647630
// other than scope-narrowing ones). It pipelines scan -> registry upsert ->
648631
// per-repo rain so that fetching starts as soon as the first repo is found,

cmd/root_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -720,25 +720,6 @@ func TestScanProgressPathMaxLen(t *testing.T) {
720720
})
721721
}
722722

723-
func TestStdinInteractiveOK(t *testing.T) {
724-
t.Run("CI false", func(t *testing.T) {
725-
t.Setenv("CI", "1")
726-
t.Setenv("GITHUB_ACTIONS", "")
727-
t.Setenv("GIT_RAIN_NON_INTERACTIVE", "")
728-
if stdinInteractiveOK() {
729-
t.Fatal("CI=1 must disable stdin interactivity")
730-
}
731-
})
732-
t.Run("GIT_RAIN_NON_INTERACTIVE false", func(t *testing.T) {
733-
t.Setenv("CI", "")
734-
t.Setenv("GITHUB_ACTIONS", "")
735-
t.Setenv("GIT_RAIN_NON_INTERACTIVE", "1")
736-
if stdinInteractiveOK() {
737-
t.Fatal("GIT_RAIN_NON_INTERACTIVE=1 must disable stdin interactivity")
738-
}
739-
})
740-
}
741-
742723
func hasRainBackupBranch(t *testing.T, repoPath string) bool {
743724
t.Helper()
744725
cmd := exec.Command("git", "branch", "--format=%(refname:short)")

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/charmbracelet/bubbletea v1.3.10
88
github.com/charmbracelet/lipgloss v1.1.0
99
github.com/git-fire/git-testkit v0.2.0
10-
github.com/mattn/go-isatty v0.0.20
10+
github.com/gofrs/flock v0.12.1
1111
github.com/mattn/go-runewidth v0.0.19
1212
github.com/pelletier/go-toml/v2 v2.2.4
1313
github.com/spf13/cobra v1.10.2
@@ -26,9 +26,9 @@ require (
2626
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
2727
github.com/fsnotify/fsnotify v1.9.0 // indirect
2828
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
29-
github.com/gofrs/flock v0.12.1 // indirect
3029
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3130
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
31+
github.com/mattn/go-isatty v0.0.20 // indirect
3232
github.com/mattn/go-localereader v0.0.1 // indirect
3333
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
3434
github.com/muesli/cancelreader v0.2.2 // indirect

go.sum

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,16 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavM
8989
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
9090
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
9191
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
92+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
93+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
9294
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9395
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
94-
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
95-
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9696
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
9797
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
9898
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
9999
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
100100
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
101-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
102-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
103101
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
102+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
104103
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
105104
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)