Skip to content

Commit d3ee726

Browse files
committed
Scope config lookup to org
1 parent 9bd532b commit d3ee726

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

components/gitpod-db/src/project-db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TransactionalDB } from "./typeorm/transactional-db-impl";
1010
export const ProjectDB = Symbol("ProjectDB");
1111
export interface ProjectDB extends TransactionalDB<ProjectDB> {
1212
findProjectById(projectId: string): Promise<Project | undefined>;
13-
findProjectsByCloneUrl(cloneUrl: string): Promise<Project[]>;
13+
findProjectsByCloneUrl(cloneUrl: string, organizationId?: string): Promise<Project[]>;
1414
findProjects(orgID: string): Promise<Project[]>;
1515
findProjectsBySearchTerm(args: FindProjectsBySearchTermArgs): Promise<{ total: number; rows: Project[] }>;
1616
storeProject(project: Project): Promise<Project>;

components/gitpod-db/src/typeorm/project-db-impl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export class ProjectDBImpl extends TransactionalDBImpl<ProjectDB> implements Pro
6060
return repo.findOne({ id: projectId, markedDeleted: false });
6161
}
6262

63-
public async findProjectsByCloneUrl(cloneUrl: string): Promise<Project[]> {
63+
public async findProjectsByCloneUrl(cloneUrl: string, organizationId?: string): Promise<Project[]> {
6464
const repo = await this.getRepo();
65-
const conditions: FindConditions<DBProject> = { cloneUrl, markedDeleted: false };
65+
const conditions: FindConditions<DBProject> = { cloneUrl, markedDeleted: false, teamId: organizationId };
6666
return repo.find(conditions);
6767
}
6868

components/server/src/projects/projects-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ export class ProjectsService {
114114
return filteredProjects;
115115
}
116116

117-
async findProjectsByCloneUrl(userId: string, cloneUrl: string): Promise<Project[]> {
118-
const projects = await this.projectDB.findProjectsByCloneUrl(cloneUrl);
117+
async findProjectsByCloneUrl(userId: string, cloneUrl: string, organizationId?: string): Promise<Project[]> {
118+
const projects = await this.projectDB.findProjectsByCloneUrl(cloneUrl, organizationId);
119119
const result: Project[] = [];
120120
for (const project of projects) {
121121
if (await this.auth.hasPermissionOnProject(userId, "read_info", project.id)) {

components/server/src/workspace/context-service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ export class ContextService {
120120
if (options?.projectId) {
121121
project = await this.projectsService.getProject(user.id, options.projectId);
122122
} else if (CommitContext.is(context)) {
123-
const projects = await this.projectsService.findProjectsByCloneUrl(user.id, context.repository.cloneUrl);
123+
const projects = await this.projectsService.findProjectsByCloneUrl(
124+
user.id,
125+
context.repository.cloneUrl,
126+
options?.organizationId,
127+
);
124128
if (projects.length > 1) {
125129
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "Multiple projects found for clone URL.");
126130
}

0 commit comments

Comments
 (0)