Skip to content

Conversation

@AlexTugarev
Copy link
Member

This fixes a serious bug in the association of projects to prebuilds which are triggered on push events. Replacing all findProjectByInstallationId by findProjectByCloneUrl, because an installation can be used to create multiple projects this cannot be unambiguous.

@roboquat roboquat added the size/M label Aug 4, 2021
@AlexTugarev AlexTugarev removed the request for review from JanKoehnlein August 4, 2021 13:04
@AlexTugarev
Copy link
Member Author

/approve no-issue

@AlexTugarev AlexTugarev force-pushed the at/fix-project-prebuilds branch from e4f5b78 to d721e40 Compare August 4, 2021 13:05
@roboquat roboquat added size/S and removed size/M labels Aug 4, 2021
if (project) {
project.cloneUrl = repository.clone_url;
await this.projectDB.storeProject(project);
const oldName = (ctx.payload as any)?.changes?.repository?.name?.from;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is undocumented stuff, I'm afraid. The event payload contains:

"changes": { "repository": { "name": { "from": "test-repo-123" } } }

To implement this in a robust way, we'd need to store repository.id to the project. next to the cloneUrl.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. maybe put this as a TODO into the code

@gitpod-io gitpod-io deleted a comment from codecov bot Aug 4, 2021
@AlexTugarev AlexTugarev changed the title at/fix-project-prebuilds [Projects] Fix prebuild association Aug 5, 2021
@gtsiolis
Copy link
Contributor

gtsiolis commented Aug 5, 2021

@AlexTugarev This will probably resolve #5065, right?

if (project) {
project.cloneUrl = repository.clone_url;
await this.projectDB.storeProject(project);
const oldName = (ctx.payload as any)?.changes?.repository?.name?.from;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. maybe put this as a TODO into the code

}

protected async findInstallationOwner(installationId: number): Promise<{user: User, project?: Project} | undefined> {
protected async findInstallationOwner(installationId: number, cloneURL: string): Promise<{user: User, project?: Project} | undefined> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this rather be two methods? (findUser(installationId) and findPRoject(cloneUrl))
Maybe at least name the method findInstallationOwnerAndProject

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both make sense. will do!

@AlexTugarev
Copy link
Member Author

/hold

@AlexTugarev AlexTugarev force-pushed the at/fix-project-prebuilds branch from d721e40 to e4d4917 Compare August 5, 2021 15:37
@roboquat roboquat added size/M and removed size/S labels Aug 5, 2021
@gitpod-io gitpod-io deleted a comment from codecov bot Aug 5, 2021
@roboquat
Copy link
Contributor

roboquat commented Aug 5, 2021

LGTM label has been added.

DetailsGit tree hash: c635928c608ca7b8e977fd7c129cd12805dc860c

@roboquat
Copy link
Contributor

roboquat commented Aug 5, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AlexTugarev, svenefftinge

Associated issue requirement bypassed by: AlexTugarev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@AlexTugarev
Copy link
Member Author

/hold cancel

@roboquat roboquat merged commit 8448f30 into main Aug 5, 2021
@roboquat roboquat deleted the at/fix-project-prebuilds branch August 5, 2021 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prebuilds are not always associated with the correct project

5 participants