diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-09 16:31:09 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-14 08:52:34 +0300 |
commit | 3b03a8bed7526271cb1a3a68aff63a20872b68e8 (patch) | |
tree | 9863c8d69f3c6c72335036ad1d6c0e65af267fe6 | |
parent | e566589b930fce5eeb8d1bc4c89fd9e196fb5b3b (diff) |
stats: Always use `printInteractive()` to print interactive messages
Now that `printInteractive()` doesn't append a newline anymore, we can
convert other callers which up to now had to manually check whether
the `interactive` flag was set.
-rw-r--r-- | internal/git/stats/analyzehttp.go | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/internal/git/stats/analyzehttp.go b/internal/git/stats/analyzehttp.go index 7538554e0..6ad59ca1d 100644 --- a/internal/git/stats/analyzehttp.go +++ b/internal/git/stats/analyzehttp.go @@ -9,7 +9,6 @@ import ( "io" "io/ioutil" "net/http" - "os" "strings" "time" @@ -288,28 +287,19 @@ func (cl *Clone) doPost(ctx context.Context) error { cl.Post.multiband[band].consume(cl.Post.start, data[1:]) // Print progress data as-is - if cl.Interactive && band == bandProgress { - if _, err := os.Stdout.Write(data[1:]); err != nil { - return err - } + if band == bandProgress { + cl.printInteractive("%s", string(data[1:])) } - if cl.Interactive && cl.Post.packets%500 == 0 && cl.Post.packets > 0 && band == bandPack { + if cl.Post.packets%500 == 0 && cl.Post.packets > 0 && band == bandPack { // Print dots to have some sort of progress meter for the user in // interactive mode. It's not accurate progress, but it shows that // something is happening. - if _, err := fmt.Print("."); err != nil { - return err - } + cl.printInteractive(".") } } - if cl.Interactive { - // Trailing newline for progress dots. - if _, err := fmt.Println(""); err != nil { - return err - } - } + cl.printInteractive("\n") if err := scanner.Err(); err != nil { return err |