()
| 778 | } |
| 779 | |
| 780 | func (b *Builder) getLastBuild() (*database.WorkspaceBuild, error) { |
| 781 | if b.lastBuild != nil { |
| 782 | return b.lastBuild, nil |
| 783 | } |
| 784 | // last build might not exist, so we also store the error to prevent repeated queries |
| 785 | // for a non-existing build |
| 786 | if b.lastBuildErr != nil { |
| 787 | return nil, *b.lastBuildErr |
| 788 | } |
| 789 | bld, err := b.store.GetLatestWorkspaceBuildByWorkspaceID(b.ctx, b.workspace.ID) |
| 790 | if err != nil { |
| 791 | err = xerrors.Errorf("get workspace %s last build: %w", b.workspace.ID, err) |
| 792 | b.lastBuildErr = &err |
| 793 | return nil, err |
| 794 | } |
| 795 | b.lastBuild = &bld |
| 796 | return b.lastBuild, nil |
| 797 | } |
| 798 | |
| 799 | // firstBuild returns true if this is the first build of the workspace, i.e. there are no prior builds. |
| 800 | func (b *Builder) firstBuild() (bool, error) { |
no test coverage detected