Skip to content

Commit

Permalink
cli: use switch correctly to read bare option
Browse files Browse the repository at this point in the history
Signed-off-by: Javi Fontan <jfontan@gmail.com>
  • Loading branch information
jfontan committed Jun 21, 2019
1 parent b3ccf54 commit a6226f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions cmd/gitbase/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ func (c *Server) addDirectory(d directory) error {
return nil
}

type bareness int
type bareOpt int

const (
bareAuto bareness = iota
bareAuto bareOpt = iota
bareOn
bareOff
)
Expand All @@ -385,7 +385,7 @@ type directory struct {
Format string
Bucket int
Rooted bool
Bare bareness
Bare bareOpt
}

var (
Expand Down Expand Up @@ -431,18 +431,17 @@ func parseDirectory(dir directory) (directory, error) {
dir.Format = val

case "bare":
if val != "true" && val != "false" && val != "auto" {
logrus.Errorf("invalid value in bare, it can only "+
"be true, false, or auto %v", val)
return dir, ErrInvalid
}
switch val {
case "true":
dir.Bare = bareOn
case "false":
dir.Bare = bareOff
case "auto":
dir.Bare = bareAuto
default:
logrus.Errorf("invalid value in bare, it can only "+
"be true, false, or auto %v", val)
return dir, ErrInvalid
}

case "rooted":
Expand Down
2 changes: 1 addition & 1 deletion cmd/gitbase/command/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestDiscoverBare(t *testing.T) {

tests := []struct {
path string
bare bareness
bare bareOpt
expected bool
err bool
}{
Expand Down

0 comments on commit a6226f1

Please sign in to comment.