Skip to content

Commit

Permalink
fixing converters to account for non-optional (undefined) fields
Browse files Browse the repository at this point in the history
  • Loading branch information
selfcontained committed Nov 8, 2023
1 parent 2673380 commit 1a608c3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions components/gitpod-protocol/src/public-api-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,16 @@ export class PublicAPIConverter {
toPrebuildSettings(prebuilds?: PrebuildSettingsProtocol): PrebuildSettings {
const result = new PrebuildSettings();
if (prebuilds) {
result.enabled = prebuilds.enable;
result.branchMatchingPattern = prebuilds.branchMatchingPattern;
result.enabled = !!prebuilds.enable;
result.branchMatchingPattern = prebuilds.branchMatchingPattern ?? "";
result.branchStrategy = this.toBranchMatchingStrategy(prebuilds.branchStrategy);
result.prebuildInterval = prebuilds.prebuildInterval;
result.workspaceClass = prebuilds.workspaceClass;
result.prebuildInterval = prebuilds.prebuildInterval ?? 20;
result.workspaceClass = prebuilds.workspaceClass ?? "";
}
return result;
}

toBranchMatchingStrategy(
branchStrategy?: PrebuildSettingsProtocol.BranchStrategy,
): BranchMatchingStrategy | undefined {
toBranchMatchingStrategy(branchStrategy?: PrebuildSettingsProtocol.BranchStrategy): BranchMatchingStrategy {
switch (branchStrategy) {
case "default-branch":
return BranchMatchingStrategy.DEFAULT_BRANCH;
Expand All @@ -419,7 +417,7 @@ export class PublicAPIConverter {
case "matched-branches":
return BranchMatchingStrategy.MATCHED_BRANCHES;
}
return undefined;
return BranchMatchingStrategy.DEFAULT_BRANCH;
}

toWorkspaceSettings(workspaceClass?: string): WorkspaceSettings {
Expand Down

0 comments on commit 1a608c3

Please sign in to comment.