|
116 | 116 | } |
117 | 117 |
|
118 | 118 | async function connect(selectedInstallationId: string, selectedRepository: string) { |
| 119 | + let nextBranch = site?.providerBranch ?? 'main'; |
119 | 120 | 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. |
162 | 135 | } |
| 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); |
163 | 159 | } |
164 | 160 |
|
165 | 161 | $: if (site?.installationId && site?.providerRepositoryId) { |
|
0 commit comments