From eb5d6ab84f2a5bbe3de7a10e61fc82571b0e8d43 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 11 Jun 2015 14:43:41 -0700 Subject: [PATCH] Move to upstream progress bar, deleting our fork - needed patches merged by upstream maintainer --- Godeps/Godeps.json | 10 ++-- .../github.com/{minio => cheggaaa}/pb/LICENSE | 0 .../{minio => cheggaaa}/pb/README.md | 0 .../pb/example/copy/copy.go | 0 .../{minio => cheggaaa}/pb/example/pb.go | 0 .../{minio => cheggaaa}/pb/format.go | 0 .../{minio => cheggaaa}/pb/format_test.go | 0 .../github.com/{minio => cheggaaa}/pb/pb.go | 47 ++++++++++++------- .../{minio => cheggaaa}/pb/pb_nix.go | 0 .../{minio => cheggaaa}/pb/pb_solaris.go | 0 .../{minio => cheggaaa}/pb/pb_test.go | 0 .../{minio => cheggaaa}/pb/pb_win.go | 0 .../github.com/{minio => cheggaaa}/pb/pb_x.go | 0 .../{minio => cheggaaa}/pb/reader.go | 0 cp-bar.go | 2 +- main.go | 2 +- 16 files changed, 37 insertions(+), 24 deletions(-) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/LICENSE (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/README.md (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/example/copy/copy.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/example/pb.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/format.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/format_test.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/pb.go (89%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/pb_nix.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/pb_solaris.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/pb_test.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/pb_win.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/pb_x.go (100%) rename Godeps/_workspace/src/github.com/{minio => cheggaaa}/pb/reader.go (100%) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e6bd0375..235040a1 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,10 +1,14 @@ { "ImportPath": "github.com/minio/mc", - "GoVersion": "go1.4.2", + "GoVersion": "go1.4", "Packages": [ "./..." ], "Deps": [ + { + "ImportPath": "github.com/cheggaaa/pb", + "Rev": "e648e12b78cedf14ebb2fc1855033f07b034cfbb" + }, { "ImportPath": "github.com/dustin/go-humanize", "Rev": "8cc1aaa2d955ee82833337cfb10babc42be6bce6" @@ -34,10 +38,6 @@ "ImportPath": "github.com/minio/minio/pkg/iodine", "Rev": "0f58045480309d4b13fe45878f05736c3ff20e7e" }, - { - "ImportPath": "github.com/minio/pb", - "Rev": "23b3da381ac6aed453db51c316a90564f4f3ba7e" - }, { "ImportPath": "github.com/shiena/ansicolor", "Rev": "8368d3b31cf6f2c2464c7a91675342c9a0ac6658" diff --git a/Godeps/_workspace/src/github.com/minio/pb/LICENSE b/Godeps/_workspace/src/github.com/cheggaaa/pb/LICENSE similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/LICENSE rename to Godeps/_workspace/src/github.com/cheggaaa/pb/LICENSE diff --git a/Godeps/_workspace/src/github.com/minio/pb/README.md b/Godeps/_workspace/src/github.com/cheggaaa/pb/README.md similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/README.md rename to Godeps/_workspace/src/github.com/cheggaaa/pb/README.md diff --git a/Godeps/_workspace/src/github.com/minio/pb/example/copy/copy.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/example/copy/copy.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/example/pb.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/example/pb.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/example/pb.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/example/pb.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/format.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/format.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/format.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/format.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/format_test.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/format_test.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/format_test.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/format_test.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go similarity index 89% rename from Godeps/_workspace/src/github.com/minio/pb/pb.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go index fb8112e0..55e00527 100644 --- a/Godeps/_workspace/src/github.com/minio/pb/pb.go +++ b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go @@ -97,7 +97,6 @@ func (pb *ProgressBar) Start() *ProgressBar { pb.startTime = time.Now() pb.startValue = pb.current if pb.Total == 0 { - pb.ShowBar = false pb.ShowTimeLeft = false pb.ShowPercent = false } @@ -239,7 +238,7 @@ func (pb *ProgressBar) write(current int64) { if pb.Total > 0 { countersBox = fmt.Sprintf("%s / %s ", Format(current, pb.Units), Format(pb.Total, pb.Units)) } else { - countersBox = Format(current, pb.Units) + " " + countersBox = Format(current, pb.Units) + " / ? " } } @@ -272,22 +271,36 @@ func (pb *ProgressBar) write(current int64) { if pb.ShowBar { size := width - len(countersBox+pb.BarStart+pb.BarEnd+percentBox+timeLeftBox+speedBox+pb.prefix+pb.postfix) if size > 0 { - curCount := int(math.Ceil((float64(current) / float64(pb.Total)) * float64(size))) - emptCount := size - curCount - barBox = pb.BarStart - if emptCount < 0 { - emptCount = 0 - } - if curCount > size { - curCount = size - } - if emptCount <= 0 { - barBox += strings.Repeat(pb.Current, curCount) - } else if curCount > 0 { - barBox += strings.Repeat(pb.Current, curCount-1) + pb.CurrentN - } + if pb.Total > 0 { + curCount := int(math.Ceil((float64(current) / float64(pb.Total)) * float64(size))) + emptCount := size - curCount + barBox = pb.BarStart + if emptCount < 0 { + emptCount = 0 + } + if curCount > size { + curCount = size + } + if emptCount <= 0 { + barBox += strings.Repeat(pb.Current, curCount) + } else if curCount > 0 { + barBox += strings.Repeat(pb.Current, curCount-1) + pb.CurrentN + } - barBox += strings.Repeat(pb.Empty, emptCount) + pb.BarEnd + barBox += strings.Repeat(pb.Empty, emptCount) + pb.BarEnd + } else { + + barBox = pb.BarStart + pos := size - int(current)%int(size) + if pos-1 > 0 { + barBox += strings.Repeat(pb.Empty, pos-1) + } + barBox += pb.Current + if size-pos-1 > 0 { + barBox += strings.Repeat(pb.Empty, size-pos-1) + } + barBox += pb.BarEnd + } } } diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_nix.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_nix.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_nix.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_nix.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_solaris.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_solaris.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_solaris.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_solaris.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_test.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_test.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_test.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_test.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_win.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_win.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_win.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_win.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/pb_x.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/pb_x.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/pb_x.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/pb_x.go diff --git a/Godeps/_workspace/src/github.com/minio/pb/reader.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/reader.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/pb/reader.go rename to Godeps/_workspace/src/github.com/cheggaaa/pb/reader.go diff --git a/cp-bar.go b/cp-bar.go index 69c2684d..ad467bd3 100644 --- a/cp-bar.go +++ b/cp-bar.go @@ -23,8 +23,8 @@ import ( "sync/atomic" "time" + "github.com/cheggaaa/pb" "github.com/minio/mc/pkg/console" - "github.com/minio/pb" ) type cpBarCmd int diff --git a/main.go b/main.go index 837eeeba..7719cc1e 100644 --- a/main.go +++ b/main.go @@ -24,10 +24,10 @@ import ( "runtime" "strconv" + "github.com/cheggaaa/pb" "github.com/minio/cli" "github.com/minio/mc/pkg/console" "github.com/minio/minio/pkg/iodine" - "github.com/minio/pb" ) // Check for the environment early on and gracefully report.