Skip to content

Commit

Permalink
cleanup parseBool (git-town#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph authored May 7, 2020
1 parent 94b3e45 commit b134ff5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
6 changes: 2 additions & 4 deletions src/util/string.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package util

import (
"fmt"
"os"
"log"
"strconv"
)

// StringToBool parses the given string into a bool
func StringToBool(arg string) bool {
value, err := strconv.ParseBool(arg)
if err != nil {
fmt.Printf("cannot convert string %q to bool: %v\n", arg, err)
os.Exit(1)
log.Fatal(err)
}
return value
}
13 changes: 2 additions & 11 deletions test/steps/configuration_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ConfigurationSteps(suite *godog.Suite, fs *FeatureState) {
suite.Step(`^the new-branch-push-flag configuration is now (true|false)$`, func(text string) error {
want, err := strconv.ParseBool(text)
if err != nil {
return fmt.Errorf("cannot parse %q into bool: %w", text, err)
return err
}
have := fs.activeScenarioState.gitEnvironment.DeveloperRepo.Configuration(true).ShouldNewBranchPush()
if have != want {
Expand All @@ -59,7 +59,7 @@ func ConfigurationSteps(suite *godog.Suite, fs *FeatureState) {
suite.Step(`^the new-branch-push-flag configuration is (true|false)$`, func(value string) error {
b, err := strconv.ParseBool(value)
if err != nil {
return fmt.Errorf("cannot parse %q into bool: %w", value, err)
return err
}
fs.activeScenarioState.gitEnvironment.DeveloperRepo.Configuration(false).SetNewBranchPush(b, false)
return nil
Expand All @@ -83,15 +83,6 @@ func ConfigurationSteps(suite *godog.Suite, fs *FeatureState) {
return nil
})

suite.Step(`^the new-branch-push-flag configuration is set to (true|false)$`, func(text string) error {
value, err := strconv.ParseBool(text)
if err != nil {
return fmt.Errorf("cannot parse %q into bool: %w", text, err)
}
_ = fs.activeScenarioState.gitEnvironment.DeveloperRepo.Configuration(false).SetNewBranchPush(value, false)
return nil
})

suite.Step(`^the perennial branches are not configured$`, func() error {
fs.activeScenarioState.gitEnvironment.DeveloperRepo.Configuration(false).DeletePerennialBranchConfiguration()
return nil
Expand Down

0 comments on commit b134ff5

Please sign in to comment.