mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-12 21:02:17 +02:00
fix(apps): take bootstrap commit sha from the PUT response
Re-reading refs/heads/main immediately after the bootstrap commit can 409 on a stale replica (GitHub eventual consistency) — the Contents API response already carries the commit sha, so use it directly.
This commit is contained in:
parent
1ed9cced59
commit
8e4f234d69
1 changed files with 4 additions and 3 deletions
|
|
@ -174,13 +174,14 @@ async function pushSource(token: string, login: string, repoName: string, folder
|
|||
const ref = await gh<{ object: { sha: string } }>(token, 'GET', `/repos/${login}/${repoName}/git/ref/heads/main`);
|
||||
parents = [ref.object.sha];
|
||||
} catch {
|
||||
await gh(token, 'PUT', `/repos/${login}/${repoName}/contents/README.md`, {
|
||||
// Use the PUT response's own commit sha — re-reading the ref right
|
||||
// after the first commit can 409 on a stale replica.
|
||||
const put = await gh<{ commit: { sha: string } }>(token, 'PUT', `/repos/${login}/${repoName}/contents/README.md`, {
|
||||
message: 'bootstrap',
|
||||
content: Buffer.from(generatedReadme(manifest)).toString('base64'),
|
||||
branch: 'main',
|
||||
});
|
||||
const ref = await gh<{ object: { sha: string } }>(token, 'GET', `/repos/${login}/${repoName}/git/ref/heads/main`);
|
||||
parents = [ref.object.sha];
|
||||
parents = [put.commit.sha];
|
||||
}
|
||||
|
||||
type TreeEntry = { path: string; mode: '100644'; type: 'blob'; sha: string };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue