Skip to content

[bitbucket] make less requests and fail on error #11651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions components/server/src/workspace/config-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,12 @@ export class ConfigProvider {
}
const services = hostContext.services;
const contextRepoConfig = services.fileProvider.getGitpodFileContent(commit, user);
const projectDBConfig = this.projectDB
.findProjectByCloneUrl(commit.repository.cloneUrl)
.then((project) => project?.config);
const definitelyGpConfig = this.fetchExternalGitpodFileContent({ span }, commit.repository);
const inferredConfig = this.configurationService.guessRepositoryConfiguration({ span }, user, commit);

customConfigString = await contextRepoConfig;
let origin: WorkspaceConfig["_origin"] = "repo";
if (!customConfigString) {
const projectDBConfig = this.projectDB
.findProjectByCloneUrl(commit.repository.cloneUrl)
.then((project) => project?.config);
// We haven't found a Gitpod configuration file in the context repo - check the "Project" in the DB.
const config = await projectDBConfig;
if (config) {
Expand All @@ -206,6 +203,7 @@ export class ConfigProvider {
* While all those checks will be in vain, they should not leak memory either as they'll simply
* be resolved and garbage collected.
*/
const definitelyGpConfig = this.fetchExternalGitpodFileContent({ span }, commit.repository);
const { content, basePath } = await definitelyGpConfig;
customConfigString = content;
// We do not only care about the config itself but also where we got it from
Expand All @@ -214,6 +212,11 @@ export class ConfigProvider {
}

if (!customConfigString) {
const inferredConfig = this.configurationService.guessRepositoryConfiguration(
{ span },
user,
commit,
);
// if there's still no configuration, let's infer one
customConfigString = await inferredConfig;
origin = "derived";
Expand Down