Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/platform/model/buildplanner/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (b *BuildPlanner) StageCommit(params StageCommitParams) (*Commit, error) {
if resp.Build.Status == raw.Planning {
resp.Build, err = b.pollBuildPlanned(resp.CommitID.String(), params.Owner, params.Project, nil)
if err != nil {
return nil, errs.Wrap(err, "failed to poll build plan")
return &Commit{resp, nil, nil}, errs.Wrap(err, "failed to poll build plan")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do the same thing earlier in this function:

if response.IsErrorResponse(resp.Build.Type) {
return &Commit{resp, nil, nil}, response.ProcessBuildError(resp.Build, "Could not process error response from stage commit")
}

It's up to the caller to handle error conditions, and state import does something with the returned commit, even if there's an error:

stagedCommit, err := bp.StageCommit(buildplanner.StageCommitParams{
Owner: proj.Owner(),
Project: proj.Name(),
ParentCommit: localCommitId.String(),
Description: msg,
Script: bs,
})
// Always update the local commit ID even if the commit fails to build
if stagedCommit != nil && stagedCommit.Commit != nil && stagedCommit.Commit.CommitID != "" {
if err := localcommit.Set(proj.Dir(), stagedCommit.CommitID.String()); err != nil {
return locale.WrapError(err, "err_package_update_commit_id")
}
}

Other callers just error if err is not nil. The point is, it's okay to return the commit returned by StageCommit, even if there was ultimately an error (the commit was created after all; it just doesn't build).

}
}

Expand Down
Loading