Skip to content
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

[Projects] Fix prebuild association #5054

Merged
merged 1 commit into from
Aug 5, 2021
Merged

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.

@AlexTugarev
Copy link
Member Author

/approve no-issue

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
Member

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
Member

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

@@ -329,11 +334,11 @@ export class GithubApp {
return this.env.hostUrl.with({ pathname: '/button/open-in-gitpod.svg' }).toString();
}

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
Member

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

@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.

Git 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

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
4 participants