Skip to content

Commit

Permalink
Merge pull request #5955 from csrwng/fix_start_build
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Nov 19, 2015
2 parents 5e353c0 + 8ccb395 commit 0e3fe6c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/cmd/cli/cmd/startbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,12 @@ func RunStartBuildWebHook(f *clientcmd.Factory, out io.Writer, webhook string, p
}

// TODO: should be a versioned struct
data, err := json.Marshal(event)
if err != nil {
return err
var data []byte
if event != nil {
data, err = json.Marshal(event)
if err != nil {
return err
}
}

httpClient := http.DefaultClient
Expand Down Expand Up @@ -529,7 +532,7 @@ func RunStartBuildWebHook(f *clientcmd.Factory, out io.Writer, webhook string, p
}

// hookEventFromPostReceive creates a GenericWebHookEvent from the provided git repository and
// post receive input. If no inputs are available will return an empty event.
// post receive input. If no inputs are available, it will return nil.
func hookEventFromPostReceive(repo git.Repository, path, postReceivePath string) (*buildapi.GenericWebHookEvent, error) {
// TODO: support other types of refs
event := &buildapi.GenericWebHookEvent{
Expand Down Expand Up @@ -558,6 +561,9 @@ func hookEventFromPostReceive(repo git.Repository, path, postReceivePath string)
}
refs = r
}
if len(refs) == 0 {
return nil, nil
}
for _, ref := range refs {
if len(ref.New) == 0 || ref.New == ref.Old {
continue
Expand Down

0 comments on commit 0e3fe6c

Please sign in to comment.