@@ -57,23 +57,32 @@ export class WorkspaceFactoryEE extends WorkspaceFactory {
57
57
}
58
58
59
59
let ws ;
60
- let parentPrebuild ;
61
60
62
61
// Find an older full prebuild to start an incremental prebuild
63
62
for ( const parent of ( context . commitHistory || [ ] ) ) {
64
- parentPrebuild = await this . db . trace ( { span} ) . findPrebuiltWorkspaceByCommit ( commitContext . repository . cloneUrl , parent ) ;
65
- if ( ! ! parentPrebuild ) {
66
- log . debug ( `Found parent prebuild for ${ commitContext . revision } ` , parentPrebuild ) ;
67
- if ( parentPrebuild . state === 'available' ) {
68
- const incrementalPrebuildContext : PrebuiltWorkspaceContext = {
69
- title : `Incremental prebuild of "${ commitContext . title } "` ,
70
- originalContext : commitContext ,
71
- prebuiltWorkspace : parentPrebuild ,
72
- }
73
- ws = await this . createForPrebuiltWorkspace ( { span} , user , incrementalPrebuildContext , normalizedContextURL ) ;
74
- break ;
75
- }
63
+ const parentPrebuild = await this . db . trace ( { span} ) . findPrebuiltWorkspaceByCommit ( commitContext . repository . cloneUrl , parent ) ;
64
+ if ( ! parentPrebuild ) {
65
+ continue ;
76
66
}
67
+ log . debug ( `Considering parent prebuild for ${ commitContext . revision } ` , parentPrebuild ) ;
68
+ if ( parentPrebuild . state !== 'available' ) {
69
+ continue ;
70
+ }
71
+ const buildWorkspace = await this . db . trace ( { span} ) . findById ( parentPrebuild . buildWorkspaceId ) ;
72
+ if ( ! buildWorkspace ) {
73
+ continue ;
74
+ }
75
+ if ( ! ! buildWorkspace . basedOnPrebuildId ) {
76
+ continue ;
77
+ }
78
+ // FIXME: If the workspace image (ref or dockerfile commit) has changed, or if the prebuild tasks have changed, the prebuild is no longer relevant
79
+ const incrementalPrebuildContext : PrebuiltWorkspaceContext = {
80
+ title : `Incremental prebuild of "${ commitContext . title } "` ,
81
+ originalContext : commitContext ,
82
+ prebuiltWorkspace : parentPrebuild ,
83
+ }
84
+ ws = await this . createForPrebuiltWorkspace ( { span} , user , incrementalPrebuildContext , normalizedContextURL ) ;
85
+ break ;
77
86
}
78
87
79
88
if ( ! ws ) {
0 commit comments