Skip to content

Commit 90912c3

Browse files
committed
fix
1 parent 80a8f25 commit 90912c3

2 files changed

Lines changed: 75 additions & 83 deletions

File tree

src/routes/(console)/project-[region]-[project]/sites/site-[site]/deployments/+page.svelte

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,49 +41,45 @@
4141
});
4242
4343
async function connect(selectedInstallationId: string, selectedRepository: string) {
44+
let nextBranch = data.site?.providerBranch ?? 'main';
4445
try {
45-
let nextBranch = data.site?.providerBranch ?? 'main';
46-
try {
47-
const branchList = await sdk
48-
.forProject(page.params.region, page.params.project)
49-
.vcs.listRepositoryBranches({
50-
installationId: selectedInstallationId,
51-
providerRepositoryId: selectedRepository
52-
});
53-
const sorted = sortBranches(branchList.branches);
54-
nextBranch =
55-
sorted.find((branch) => branch.name === data.site?.providerBranch)?.name ??
56-
sorted.find((branch) => branch.name === 'main' || branch.name === 'master')
57-
?.name ??
58-
sorted[0]?.name ??
59-
nextBranch;
60-
} catch {
61-
// Ignore branch lookup failures; fallback to default.
62-
}
63-
await sdk.forProject(page.params.region, page.params.project).sites.update({
64-
siteId: data.site.$id,
65-
name: data.site.name,
66-
framework: data.site.framework as Framework,
67-
enabled: data.site.enabled,
68-
logging: data.site.logging || undefined,
69-
timeout: data.site.timeout,
70-
installCommand: data.site.installCommand,
71-
buildCommand: data.site.buildCommand,
72-
outputDirectory: data.site.outputDirectory,
73-
buildRuntime: data.site.buildRuntime as BuildRuntime,
74-
adapter: data.site.adapter as Adapter,
75-
fallbackFile: data.site.fallbackFile,
76-
installationId: selectedInstallationId,
77-
providerRepositoryId: selectedRepository,
78-
providerBranch: nextBranch,
79-
providerSilentMode: data.site?.providerSilentMode ?? undefined,
80-
providerRootDirectory: data.site?.providerRootDirectory ?? undefined,
81-
specification: data.site?.specification || undefined
82-
});
83-
invalidate(Dependencies.SITE);
84-
} catch (error) {
85-
throw error;
46+
const branchList = await sdk
47+
.forProject(page.params.region, page.params.project)
48+
.vcs.listRepositoryBranches({
49+
installationId: selectedInstallationId,
50+
providerRepositoryId: selectedRepository
51+
});
52+
const sorted = sortBranches(branchList.branches);
53+
nextBranch =
54+
sorted.find((branch) => branch.name === data.site?.providerBranch)?.name ??
55+
sorted.find((branch) => branch.name === 'main' || branch.name === 'master')?.name ??
56+
sorted[0]?.name ??
57+
nextBranch;
58+
} catch {
59+
// Ignore branch lookup failures; fallback to default.
8660
}
61+
62+
await sdk.forProject(page.params.region, page.params.project).sites.update({
63+
siteId: data.site.$id,
64+
name: data.site.name,
65+
framework: data.site.framework as Framework,
66+
enabled: data.site.enabled,
67+
logging: data.site.logging || undefined,
68+
timeout: data.site.timeout,
69+
installCommand: data.site.installCommand,
70+
buildCommand: data.site.buildCommand,
71+
outputDirectory: data.site.outputDirectory,
72+
buildRuntime: data.site.buildRuntime as BuildRuntime,
73+
adapter: data.site.adapter as Adapter,
74+
fallbackFile: data.site.fallbackFile,
75+
installationId: selectedInstallationId,
76+
providerRepositoryId: selectedRepository,
77+
providerBranch: nextBranch,
78+
providerSilentMode: data.site?.providerSilentMode ?? undefined,
79+
providerRootDirectory: data.site?.providerRootDirectory ?? undefined,
80+
specification: data.site?.specification || undefined
81+
});
82+
invalidate(Dependencies.SITE);
8783
}
8884
</script>
8985

src/routes/(console)/project-[region]-[project]/sites/site-[site]/settings/updateRepository.svelte

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -116,50 +116,46 @@
116116
}
117117
118118
async function connect(selectedInstallationId: string, selectedRepository: string) {
119+
let nextBranch = site?.providerBranch ?? 'main';
119120
try {
120-
let nextBranch = site?.providerBranch ?? 'main';
121-
try {
122-
const branchList = await sdk
123-
.forProject(page.params.region, page.params.project)
124-
.vcs.listRepositoryBranches({
125-
installationId: selectedInstallationId,
126-
providerRepositoryId: selectedRepository
127-
});
128-
const sorted = sortBranches(branchList.branches);
129-
nextBranch =
130-
sorted.find((branch) => branch.name === site?.providerBranch)?.name ??
131-
sorted.find((branch) => branch.name === 'main' || branch.name === 'master')
132-
?.name ??
133-
sorted[0]?.name ??
134-
nextBranch;
135-
} catch {
136-
// Ignore branch lookup failures; fallback to default.
137-
}
138-
await sdk.forProject(page.params.region, page.params.project).sites.update({
139-
siteId: site.$id,
140-
name: site.name,
141-
framework: site.framework as Framework,
142-
enabled: site?.enabled,
143-
logging: site?.logging || undefined,
144-
timeout: site?.timeout,
145-
installCommand: site?.installCommand,
146-
buildCommand: site?.buildCommand,
147-
outputDirectory: site?.outputDirectory,
148-
buildRuntime: site?.buildRuntime as BuildRuntime,
149-
adapter: site.adapter as Adapter,
150-
fallbackFile: site?.fallbackFile,
151-
installationId: selectedInstallationId,
152-
providerRepositoryId: selectedRepository,
153-
providerBranch: nextBranch,
154-
providerSilentMode: site?.providerSilentMode ?? undefined,
155-
providerRootDirectory: site?.providerRootDirectory ?? undefined,
156-
specification: site?.specification || undefined
157-
});
158-
159-
invalidate(Dependencies.SITE);
160-
} catch (error) {
161-
throw error;
121+
const branchList = await sdk
122+
.forProject(page.params.region, page.params.project)
123+
.vcs.listRepositoryBranches({
124+
installationId: selectedInstallationId,
125+
providerRepositoryId: selectedRepository
126+
});
127+
const sorted = sortBranches(branchList.branches);
128+
nextBranch =
129+
sorted.find((branch) => branch.name === site?.providerBranch)?.name ??
130+
sorted.find((branch) => branch.name === 'main' || branch.name === 'master')?.name ??
131+
sorted[0]?.name ??
132+
nextBranch;
133+
} catch {
134+
// Ignore branch lookup failures; fallback to default.
162135
}
136+
137+
await sdk.forProject(page.params.region, page.params.project).sites.update({
138+
siteId: site.$id,
139+
name: site.name,
140+
framework: site.framework as Framework,
141+
enabled: site?.enabled,
142+
logging: site?.logging || undefined,
143+
timeout: site?.timeout,
144+
installCommand: site?.installCommand,
145+
buildCommand: site?.buildCommand,
146+
outputDirectory: site?.outputDirectory,
147+
buildRuntime: site?.buildRuntime as BuildRuntime,
148+
adapter: site.adapter as Adapter,
149+
fallbackFile: site?.fallbackFile,
150+
installationId: selectedInstallationId,
151+
providerRepositoryId: selectedRepository,
152+
providerBranch: nextBranch,
153+
providerSilentMode: site?.providerSilentMode ?? undefined,
154+
providerRootDirectory: site?.providerRootDirectory ?? undefined,
155+
specification: site?.specification || undefined
156+
});
157+
158+
invalidate(Dependencies.SITE);
163159
}
164160
165161
$: if (site?.installationId && site?.providerRepositoryId) {

0 commit comments

Comments
 (0)