Skip to content

Commit a6226f1

Browse files
committed
cli: use switch correctly to read bare option
Signed-off-by: Javi Fontan <[email protected]>
1 parent b3ccf54 commit a6226f1

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

cmd/gitbase/command/server.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,10 @@ func (c *Server) addDirectory(d directory) error {
372372
return nil
373373
}
374374

375-
type bareness int
375+
type bareOpt int
376376

377377
const (
378-
bareAuto bareness = iota
378+
bareAuto bareOpt = iota
379379
bareOn
380380
bareOff
381381
)
@@ -385,7 +385,7 @@ type directory struct {
385385
Format string
386386
Bucket int
387387
Rooted bool
388-
Bare bareness
388+
Bare bareOpt
389389
}
390390

391391
var (
@@ -431,18 +431,17 @@ func parseDirectory(dir directory) (directory, error) {
431431
dir.Format = val
432432

433433
case "bare":
434-
if val != "true" && val != "false" && val != "auto" {
435-
logrus.Errorf("invalid value in bare, it can only "+
436-
"be true, false, or auto %v", val)
437-
return dir, ErrInvalid
438-
}
439434
switch val {
440435
case "true":
441436
dir.Bare = bareOn
442437
case "false":
443438
dir.Bare = bareOff
444439
case "auto":
445440
dir.Bare = bareAuto
441+
default:
442+
logrus.Errorf("invalid value in bare, it can only "+
443+
"be true, false, or auto %v", val)
444+
return dir, ErrInvalid
446445
}
447446

448447
case "rooted":

cmd/gitbase/command/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func TestDiscoverBare(t *testing.T) {
182182

183183
tests := []struct {
184184
path string
185-
bare bareness
185+
bare bareOpt
186186
expected bool
187187
err bool
188188
}{

0 commit comments

Comments
 (0)