Skip to content

Commit

Permalink
fix (api): tree status (#1592)
Browse files Browse the repository at this point in the history
* fix(ui): load version without remote filter if no repository linked

Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>

* fix(ui): load version without remote filter if no repository linked

Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>
  • Loading branch information
bnjjj authored and yesnault committed Nov 28, 2017
1 parent a1798d6 commit d1d53f5
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions engine/api/workflowv0/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,9 @@ func LoadCDTree(db gorp.SqlExecutor, store cache.Store, projectkey, appName stri
pipeline.LoadPipelineBuildOpts.WithBranchName(branchName),
}

if remote == "" || (root.Application.RepositoryFullname != "" && remote == root.Application.RepositoryFullname) {
opts = append(opts, pipeline.LoadPipelineBuildOpts.WithEmptyRemote(root.Application.RepositoryFullname))
} else if root.Application.RepositoryFullname != "" && remote != "" {
opts = append(opts, pipeline.LoadPipelineBuildOpts.WithRemoteName(remote))
remoteOpts := getRemoteOpts(remote, root.Application.RepositoryFullname)
if remoteOpts != nil {
opts = append(opts, remoteOpts)
}

builds, errPB := pipeline.LoadPipelineBuildsByApplicationAndPipeline(db, root.Application.ID, root.Pipeline.ID, e.ID, 1, opts...)
Expand All @@ -319,10 +318,9 @@ func LoadCDTree(db gorp.SqlExecutor, store cache.Store, projectkey, appName stri
pipeline.LoadPipelineBuildOpts.WithBranchName(branchName),
}

if remote == "" || (root.Application.RepositoryFullname != "" && remote == root.Application.RepositoryFullname) {
opts = append(opts, pipeline.LoadPipelineBuildOpts.WithEmptyRemote(root.Application.RepositoryFullname))
} else if root.Application.RepositoryFullname != "" && remote != "" {
opts = append(opts, pipeline.LoadPipelineBuildOpts.WithRemoteName(remote))
remoteOpts := getRemoteOpts(remote, root.Application.RepositoryFullname)
if remoteOpts != nil {
opts = append(opts, remoteOpts)
}

builds, errPB := pipeline.LoadPipelineBuildsByApplicationAndPipeline(db, root.Application.ID, root.Pipeline.ID, root.Environment.ID, 1, opts...)
Expand Down Expand Up @@ -503,10 +501,9 @@ func getChild(db gorp.SqlExecutor, parent *sdk.CDPipeline, user *sdk.User, branc
}

if parent.Application.Name == child.Application.Name {
if remote == "" || remote == parent.Application.RepositoryFullname {
opts = append(opts, pipeline.LoadPipelineBuildOpts.WithEmptyRemote(parent.Application.RepositoryFullname))
} else {
opts = append(opts, pipeline.LoadPipelineBuildOpts.WithRemoteName(remote))
remoteOpts := getRemoteOpts(remote, parent.Application.RepositoryFullname)
if remoteOpts != nil {
opts = append(opts, remoteOpts)
}
}

Expand Down Expand Up @@ -547,6 +544,16 @@ func getChild(db gorp.SqlExecutor, parent *sdk.CDPipeline, user *sdk.User, branc
return nil
}

func getRemoteOpts(remoteFilter, repoFullName string) pipeline.ExecOptionFunc {
if remoteFilter == "" || (repoFullName != "" && remoteFilter == repoFullName) {
return pipeline.LoadPipelineBuildOpts.WithEmptyRemote(repoFullName)
} else if repoFullName != "" && remoteFilter != "" {
return pipeline.LoadPipelineBuildOpts.WithRemoteName(remoteFilter)
}

return nil
}

func buildTreeOrder(parent *sdk.CDPipeline, listChild []sdk.CDPipeline, user *sdk.User) sdk.CDPipeline {

for _, child := range listChild {
Expand Down

0 comments on commit d1d53f5

Please sign in to comment.