Skip to content

Commit 61471ef

Browse files
authored
Merge pull request #266 from achilleas-k/deprecating-the-web
LGTM
2 parents 1681460 + 1047fbc commit 61471ef

File tree

12 files changed

+204
-126
lines changed

12 files changed

+204
-126
lines changed

.travis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ env:
1212

1313
matrix:
1414
include:
15-
- go: "1.11.x"
15+
- go: "1.12.x"
1616
os: linux
1717
- go: tip
1818
os: linux
19-
- go: "1.11.x"
19+
- go: "1.12.x"
2020
os: osx
2121
addons:
2222
homebrew:
@@ -49,7 +49,7 @@ install:
4949
- gofmt -s -l .
5050

5151
script:
52-
- make install
52+
- make testbuild
5353
- go test -v ./...
5454
- if [[ "${TRAVIS_GO_VERSION}" != "tip" ]]; then
5555
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
@@ -62,3 +62,8 @@ script:
6262
popd;
6363
fi;
6464
fi
65+
66+
after_failure:
67+
# upload logs to gist.github.com
68+
- pip3 install requests
69+
- python3 ./tests/scripts/pushtogist.py ./tests/log

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ allplatforms: linux windows macos
3131
install: gin
3232
install $(BUILDLOC)/$(GIN) $(INSTLOC)/$(GIN)
3333

34+
testbuild: gin
35+
mkdir -p $(TESTBINLOC)
36+
install $(BUILDLOC)/$(GIN) $(TESTBINLOC)/$(GIN)
37+
3438
linux: $(BUILDLOC)/linux/$(GIN)
3539

3640
windows: $(BUILDLOC)/windows/$(GIN).exe

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ It offers a simplified interface for downloading and uploading files from reposi
1515
It consists of commands for interfacing with the GIN web API (e.g., listing repositories, creating repositories, managing SSH keys) but primarily, it wraps **git** and **git-annex** commands to make working with data repositories easier.
1616

1717
## Information, setup, and guides
18-
For installation instructions see the [GIN Client Setup](https://web.gin.g-node.org/G-Node/Info/wiki/GinCliSetup) page.
18+
For installation instructions see the [GIN Client Setup](https://gin.g-node.org/G-Node/Info/wiki/GinCliSetup) page.
1919

20-
General information, help, and guides for using GIN can be found on the [GIN Info Wiki](https://web.gin.g-node.org/G-Node/info/wiki).
20+
General information, help, and guides for using GIN can be found on the [GIN Info Wiki](https://gin.g-node.org/G-Node/info/wiki).
2121
Help and information for the client in particular can be on the following pages:
22-
- [Usage guide (tutorial)](https://web.gin.g-node.org/G-Node/Info/wiki/GinUsageTutorial)
23-
- [Useful recipes and short workflows](https://web.gin.g-node.org/G-Node/Info/wiki/GinCliRecipes)
24-
- [Detailed command overview](https://web.gin.g-node.org/G-Node/Info/wiki/GinClientHelp)
22+
- [Usage guide (tutorial)](https://gin.g-node.org/G-Node/Info/wiki/GinUsageTutorial)
23+
- [Useful recipes and short workflows](https://gin.g-node.org/G-Node/Info/wiki/GinCliRecipes)
24+
- [Detailed command overview](https://gin.g-node.org/G-Node/Info/wiki/GinClientHelp)

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ build: off
33

44
clone_folder: C:\gopath\src\github.com\G-Node\gin-cli
55

6-
stack: go 1.11
6+
stack: go 1.12
77

88
environment:
99
SRCDIR: C:\gopath\src\github.com\G-Node\gin-cli
1010
GOPATH: C:\gopath
1111
BINDIR: bin
1212
# download dev build
13-
BUNDLEURL: https://web.gin.g-node.org/achilleas/gin-cli-builds/raw/master/gin-cli-latest-windows-386.zip
13+
BUNDLEURL: https://gin.g-node.org/achilleas/gin-cli-builds/raw/master/gin-cli-latest-windows-386.zip
1414
GIN_LOG_DIR: C:\gin-log
1515

1616

doc/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ servers:
1919
gin:
2020
web:
2121
protocol: https
22-
host: web.gin.g-node.org
22+
host: gin.g-node.org
2323
port: 443
2424

2525
git:

foobar

Whitespace-only changes.

ginclient/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var (
2626
ginDefaultServer = ServerCfg{
2727
WebCfg{
2828
Protocol: "https",
29-
Host: "web.gin.g-node.org",
29+
Host: "gin.g-node.org",
3030
Port: 443,
3131
},
3232
GitCfg{
@@ -64,7 +64,7 @@ type WebCfg struct {
6464
}
6565

6666
// AddressStr constructs a full address string from the configuration.
67-
// The string has the format Scheme://Host:Port (e.g., https://web.gin.g-node.org:443)
67+
// The string has the format Scheme://Host:Port (e.g., https://gin.g-node.org:443)
6868
func (c WebCfg) AddressStr() string {
6969
return fmt.Sprintf("%s://%s:%d", c.Protocol, c.Host, c.Port)
7070
}

gincmd/addservercmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The following information is required to configure a new server:
117117
For the web server: the protocol, hostname, and port
118118
119119
The protocol should be either 'http' or 'https'.
120-
The hostname for the server (e.g., web.gin.g-node.org).
120+
The hostname for the server (e.g., gin.g-node.org).
121121
The web port for the server (e.g., 80, 443).
122122
123123
For the git server: the git user, hostname, and port
@@ -132,7 +132,7 @@ See the Examples section for a full example.
132132
"<alias>": "The alias (name) for the server.",
133133
}
134134
examples := map[string]string{
135-
"This is what configuring the built-in G-Node GIN server would look like (note: this is already configured)": "$ gin add-server --web https://web.gin.g-node.org:443 --git [email protected]:22 gin",
135+
"This is what configuring the built-in G-Node GIN server would look like (note: this is already configured)": "$ gin add-server --web https://gin.g-node.org:443 --git [email protected]:22 gin",
136136
}
137137
var cmd = &cobra.Command{
138138
Use: "add-server [--web http[s]://<hostname>[:<port>]] [--git [<gituser>@]<hostname>[:<port>]] <alias>",

gincmd/common.go

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,26 +138,61 @@ func printProgressWithBar(statuschan <-chan git.RepoFileStatus, nitems int) (fil
138138
return printProgressOutput(statuschan)
139139
}
140140
ndigits := len(fmt.Sprintf("%d", nitems))
141-
dfmt := fmt.Sprintf("%%%dd/%%%dd", ndigits, ndigits)
141+
dfmt := fmt.Sprintf("%%%dd/%%%dd", ndigits, ndigits) // dynamic formatting string adapts to number of digits in item count
142142
filesuccess = make(map[string]bool)
143-
var barratio float64
144-
var ncomplt int
145-
linewidth := termwidth()
146-
if linewidth > 80 {
147-
linewidth = 80
148-
}
149-
barwidth := linewidth - (5 + ndigits*2)
150-
barratio = float64(barwidth) / float64(nitems)
143+
144+
// closure binds ndigits and nitems but keeps bar width dynamic so it can
145+
// adapt to terminal resizing -- introduces a few operations per refresh,
146+
// but makes the bar printing much nicer
147+
printbar := func(completed int) int {
148+
linewidth := termwidth()
149+
if linewidth > 80 {
150+
linewidth = 80
151+
} else if linewidth < 30 {
152+
// Skip bar printing for very small terminals
153+
fmt.Println()
154+
return 0
155+
}
156+
fullbarwidth := linewidth - (5 + ndigits*2)
157+
if fullbarwidth < 0 {
158+
// Again, skip bar printing if ndigits is so large that a bar would
159+
// have negative width. Since we skip printing the bar if the
160+
// termwidth is < 30, this can only happen when processing more
161+
// than 1e13 files, but if we ever change the min width to
162+
// something smaller than 30 (or make it dynamic somehow), this
163+
// guard will be useful.
164+
fmt.Println()
165+
return 0
166+
}
167+
barratio := float64(fullbarwidth) / float64(nitems)
168+
169+
complsigns := int(math.Floor(float64(completed) * barratio))
170+
blocks := strings.Repeat("=", complsigns)
171+
blanks := strings.Repeat(" ", fullbarwidth-complsigns)
172+
dprg := fmt.Sprintf(dfmt, completed, nitems)
173+
fmt.Printf("\n [%s%s] %s\r", blocks, blanks, dprg)
174+
return linewidth
175+
}
176+
151177
outline := new(bytes.Buffer)
152178
outappend := func(part string) {
153179
if len(part) > 0 {
154180
outline.WriteString(part)
155181
outline.WriteString(" ")
156182
}
157183
}
184+
158185
printed := false
186+
prevlinewidth := 0
187+
ncompleted := 0
159188
for stat := range statuschan {
160-
ncomplt++
189+
ncompleted++
190+
if ncompleted > nitems {
191+
// BUG: Not sure when this occurs, but it's been happening in the
192+
// CI environment for some remove-content calls and I haven't been
193+
// able to reproduce - AK, 2019-07-07
194+
nitems = ncompleted
195+
}
161196
outline.Reset()
162197
outline.WriteString(" ")
163198
outappend(stat.State)
@@ -172,13 +207,9 @@ func printProgressWithBar(statuschan <-chan git.RepoFileStatus, nitems int) (fil
172207
filesuccess[stat.FileName] = false
173208
}
174209
newprint := outline.String()
175-
fmt.Printf("\r%s\r", strings.Repeat(" ", linewidth)) // clear the line
210+
fmt.Printf("\r%s\r", strings.Repeat(" ", prevlinewidth)) // clear the line
176211
fmt.Fprint(color.Output, newprint)
177-
complsigns := int(math.Floor(float64(ncomplt) * barratio))
178-
blocks := strings.Repeat("=", complsigns)
179-
blanks := strings.Repeat(" ", barwidth-complsigns)
180-
dprg := fmt.Sprintf(dfmt, ncomplt, nitems)
181-
fmt.Printf("\n [%s%s] %s\r", blocks, blanks, dprg)
212+
prevlinewidth = printbar(ncompleted)
182213
printed = true
183214
}
184215
if !printed {
@@ -381,7 +412,7 @@ func dependencyInfo(giterr, annexerr error) string {
381412
errmsg = fmt.Sprintf("%s %s\n", errmsg, annexerr)
382413
}
383414

384-
helppage := "https://web.gin.g-node.org/G-Node/Info/wiki/GinCli"
415+
helppage := "https://gin.g-node.org/G-Node/Info/wiki/GinCli"
385416
var anchor string
386417
switch runtime.GOOS {
387418
case "windows":

0 commit comments

Comments
 (0)