Skip to content

Commit

Permalink
refacto: remove legacy code
Browse files Browse the repository at this point in the history
/spend 2m
  • Loading branch information
Goutte committed Mar 29, 2023
1 parent 464f06d commit 5bac8dd
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions gitime/reader/stdin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 3,10 @@ package reader
import (
"fmt"
"io"
"log"
"os"
)

func DoesStdinHaveData() bool {
fileInfo, err := os.Stdin.Stat()
if err != nil {
return false
}

if os.Getenv("GIT_SPEND_NO_STDIN") == "1" {
return false
}

// Both yield false positives in CI, careful
//if (fileInfo.Mode() & os.ModeCharDevice) == 0 { // alternatively?
if (fileInfo.Mode() & os.ModeNamedPipe) != 0 {
return true
}

return false
}

func ReadStdin() string {
stdin, err := io.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}
stdin, _ := io.ReadAll(os.Stdin)
return fmt.Sprintf("%s", stdin)
}

0 comments on commit 5bac8dd

Please sign in to comment.