Skip to content

Commit

Permalink
Fix bug where fetching linkable repos for a connection uses location …
Browse files Browse the repository at this point in the history
…associated with the backend instead of the resource itself. (#6612)

The existing implementation includes a bug where it will only look for connection in the region of the backend.
  • Loading branch information
taeold authored Dec 14, 2023
1 parent 916fc34 commit f35a365
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/init/features/apphosting/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ export async function linkGitHubRepository(
existingConns.push(refreshedConn);
}

let { remoteUri, connection } = await promptRepositoryUri(projectId, location, existingConns);
let { remoteUri, connection } = await promptRepositoryUri(projectId, existingConns);
while (remoteUri === "") {
await utils.openInBrowser("https://github.com/apps/google-cloud-build/installations/new");
await promptOnce({
type: "input",
message:
"Press ENTER once you have finished configuring your installation's access settings.",
});
const selection = await promptRepositoryUri(projectId, location, existingConns);
const selection = await promptRepositoryUri(projectId, existingConns);
remoteUri = selection.remoteUri;
connection = selection.connection;
}
Expand All @@ -130,12 +130,11 @@ export async function linkGitHubRepository(

async function promptRepositoryUri(
projectId: string,
location: string,
connections: gcb.Connection[]
): Promise<{ remoteUri: string; connection: gcb.Connection }> {
const remoteUriToConnection: Record<string, gcb.Connection> = {};
for (const conn of connections) {
const { id } = parseConnectionName(conn.name)!;
const { location, id } = parseConnectionName(conn.name)!;
const resp = await gcb.fetchLinkableRepositories(projectId, location, id);
if (resp.repositories && resp.repositories.length > 0) {
for (const repo of resp.repositories) {
Expand Down

0 comments on commit f35a365

Please sign in to comment.