Skip to content

Commit

Permalink
Merge pull request #3584 from ActiveState/mitchell/dx-3144
Browse files Browse the repository at this point in the history
`state commit` should not poll for build result.
  • Loading branch information
mitchell-as authored and Naatan committed Nov 7, 2024
1 parent 9132b74 commit 4a9f51c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/runners/commit/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (c *Commit) Run() (rerr error) {
}

// Get old buildplan.
oldCommit, err := bp.FetchCommit(localCommitID, proj.Owner(), proj.Name(), nil)
oldCommit, err := bp.FetchCommitNoPoll(localCommitID, proj.Owner(), proj.Name(), nil)
if err != nil {
return errs.Wrap(err, "Failed to fetch old commit")
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/platform/model/buildplanner/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func (c *client) Run(req gqlclient.Request, resp interface{}) error {
const fetchCommitCacheExpiry = time.Hour * 12

func (b *BuildPlanner) FetchCommit(commitID strfmt.UUID, owner, project string, target *string) (*Commit, error) {
return b.fetchCommit(commitID, owner, project, target, true)
}

func (b *BuildPlanner) FetchCommitNoPoll(commitID strfmt.UUID, owner, project string, target *string) (*Commit, error) {
return b.fetchCommit(commitID, owner, project, target, false)
}

func (b *BuildPlanner) fetchCommit(commitID strfmt.UUID, owner, project string, target *string, poll bool) (*Commit, error) {
logging.Debug("FetchCommit, commitID: %s, owner: %s, project: %s", commitID, owner, project)
resp := &response.ProjectCommitResponse{}

Expand Down Expand Up @@ -92,7 +100,7 @@ func (b *BuildPlanner) FetchCommit(commitID strfmt.UUID, owner, project string,
// The BuildPlanner will return a build plan with a status of
// "planning" if the build plan is not ready yet. We need to
// poll the BuildPlanner until the build is ready.
if resp.Project.Commit.Build.Status == raw.Planning {
if poll && resp.Project.Commit.Build.Status == raw.Planning {
resp.Project.Commit.Build, err = b.pollBuildPlanned(commitID.String(), owner, project, target)
if err != nil {
return nil, errs.Wrap(err, "failed to poll build plan")
Expand Down

0 comments on commit 4a9f51c

Please sign in to comment.