Skip to content

Commit

Permalink
close #206 fix error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
groenborg committed Aug 21, 2017
1 parent e2c223f commit aa0b5a9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
24 changes: 12 additions & 12 deletions .phlow
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[default]
integration_branch = master
remote = origin
service = github
issue_url = https://api.github.com
pipeline_url = http://concourse.bosh.praqma.cloud/teams/main/pipelines/git-phlow
delivery_branch_prefix = ready
integration_branch = master
remote = origin
service = github
issue_url = https://api.github.com
pipeline_url = http://concourse.bosh.praqma.cloud/teams/main/pipelines/git-phlow
delivery_branch_prefix = ready

[jira]
integration_branch = master
remote = origin
service = http://jira.teamsinspace.com:8080
issue_url = jira
pipeline_url = http://concourse.bosh.praqma.cloud/teams/main/pipelines/git-phlow
delivery_branch_prefix = ready
integration_branch = master
remote = origin
service = http://jira.teamsinspace.com:8080
issue_url = jira
pipeline_url = http://concourse.bosh.praqma.cloud/teams/main/pipelines/git-phlow
delivery_branch_prefix = ready
1 change: 1 addition & 0 deletions ci/windows/go-test-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cd $env:GOPATH/src/github.com/praqma/git-phlow
go get -d -t -v ./...

#RUN TESTS
cd plugins
go test -v ./...

# USES THE LATEST EXITCODE, WHICH IS FROM GO TEST, AND EXITS WITH THAT. THIS FIXIS
Expand Down
42 changes: 23 additions & 19 deletions setting/setting.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package setting

import (
"os"
"strings"
"github.com/praqma/git-phlow/executor"
"github.com/go-ini/ini"
"fmt"
"os"
"reflect"
"strings"

"github.com/go-errors/errors"
"github.com/praqma/git-phlow/plugins"
"github.com/go-ini/ini"
"github.com/praqma/git-phlow/executor"
"github.com/praqma/git-phlow/githandler"
"github.com/praqma/git-phlow/plugins"
)

//Load internals
Expand Down Expand Up @@ -112,7 +113,7 @@ func LoadProjectSettings(local, global string, INIBlock string) *ProjectSetting

//Try to get default branch otherwise just create the default
defaultBranch, err := GetDefaultBranchFromInternalDefault()
if err != nil {
if err != nil || strings.TrimSpace(defaultBranch) == "" {
defaultBranch = internal_default_integration_branch
}

Expand All @@ -137,7 +138,10 @@ func LoadProjectSettings(local, global string, INIBlock string) *ProjectSetting

//Map section into object
conf := new(ProjectSetting)
loadSetting().MapTo(conf)
err := loadSetting().MapTo(conf)
if err != nil {
panic(err)
}

//Add configuration origin
conf.File = configFile
Expand All @@ -163,7 +167,7 @@ func BootstrapPhlowConfig(local, integrationBranch string) error {
sec.Key("issue_url").SetValue(internal_default_issue_url)
sec.Key("delivery_branch_prefix").SetValue(internal_default_delivery_branch_prefix)

err := cfg.SaveTo(local + "/" + ".phlow")
err := cfg.SaveTo(local + "/" + phlow_file_name)
if err != nil {
return err
}
Expand All @@ -172,35 +176,35 @@ func BootstrapPhlowConfig(local, integrationBranch string) error {
}

//ValidateLoadedSetting ...
func ValidateLoadedSetting(setting *ProjectSetting) (error) {
func ValidateLoadedSetting(setting *ProjectSetting) error {
r := reflect.ValueOf(setting).Elem()
t := r.Type()

//Non Optional Field checks..
for i := 0; i < t.NumField(); i++ {
if t.Field(i).Name == "Service" && (r.Field(i).String() == "") {
return errors.New(fmt.Sprintf("Error in configuration file: %s \n"+
"Non-optional field missing: %s \n In configuration block: %s \n ", setting.Scope+"/"+setting.File, "service", setting.INIBlock))
return errors.New(fmt.Sprintf("Error in configuration file: %s\n"+
"Non-optional field missing: %s \nIn configuration block: %s \n ", setting.Scope+"/"+setting.File, "service", setting.INIBlock))
}

if t.Field(i).Name == "IssueURL" && r.Field(i).String() == "" {
return errors.New(fmt.Sprintf("Error in configuration file: %s \n"+
"Non-optional field missing: %s \n In configuration block: %s \n ", setting.Scope+"/"+setting.File, "issue_url", setting.INIBlock))
return errors.New(fmt.Sprintf("Error in configuration file: %s\n"+
"Non-optional field missing: %s \nIn configuration block: %s \n ", setting.Scope+"/"+setting.File, "issue_url", setting.INIBlock))
}

if t.Field(i).Name == "IntegrationBranch" && r.Field(i).String() == "" {
return errors.New(fmt.Sprintf("Error in configuration file: %s \n"+
"Non-optional field missing: %s \n In configuration block: %s \n ", setting.Scope+"/"+setting.File, "integration_branch", setting.INIBlock))
return errors.New(fmt.Sprintf("Error in configuration file: %s\n"+
"Non-optional field missing: %s \nIn configuration block: %s \n ", setting.Scope+"/"+setting.File, "integration_branch", setting.INIBlock))
}

if t.Field(i).Name == "Remote" && r.Field(i).String() == "" {
return errors.New(fmt.Sprintf("Error in configuration file: %s \n"+
"Non-optional field missing: %s \n In configuration block: %s \n ", setting.Scope+"/"+setting.File, "remote", setting.INIBlock))
return errors.New(fmt.Sprintf("Error in configuration file: %s\n"+
"Non-optional field missing: %s \nIn configuration block: %s \n ", setting.Scope+"/"+setting.File, "remote", setting.INIBlock))
}

if t.Field(i).Name == "DeliveryBranchPrefix" && r.Field(i).String() == "" {
return errors.New(fmt.Sprintf("Error in configuration file: %s \n"+
"Non-optional field missing: %s \n In configuration block: %s \n ", setting.Scope+"/"+setting.File, "delivery_branch_prefix", setting.INIBlock))
return errors.New(fmt.Sprintf("Error in configuration file: %s\n"+
"Non-optional field missing: %s \nIn configuration block: %s \n ", setting.Scope+"/"+setting.File, "delivery_branch_prefix", setting.INIBlock))
}
}
return nil
Expand Down

0 comments on commit aa0b5a9

Please sign in to comment.