Skip to content

Commit

Permalink
use getPrebuildBranchStrategy in PrebuildManager
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTugarev committed Sep 19, 2023
1 parent c8ce920 commit cd5e720
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions components/server/src/prebuilds/prebuild-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,26 @@ export class PrebuildManager {
return false;
}

if (!project.settings?.prebuildDefaultBranchOnly) {
const strategy = Project.getPrebuildBranchStrategy(project);
if (strategy === "allBranches") {
return true;
}

const defaultBranch = context.repository.defaultBranch;
if (!defaultBranch) {
log.debug("CommitContext is missing the default branch.", { context });
return true;
if (strategy === "defaultBranch") {
const defaultBranch = context.repository.defaultBranch;
if (!defaultBranch) {
log.debug("CommitContext is missing the default branch. Ignoring request.", { context });
return false;
}
return context.ref === defaultBranch;
}

if (strategy === "selectedBranches") {
// TODO support "selectedBranches" next
}
return context.ref === defaultBranch;

log.debug("Unknown prebuild branch strategy. Ignoring request.", { context, config });
return false;
}

protected shouldPrebuildIncrementally(cloneUrl: string, project: Project): boolean {
Expand Down

0 comments on commit cd5e720

Please sign in to comment.