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:
Gagan 2026-07-06 20:07:09 +05:30
parent 1ed9cced59
commit 8e4f234d69

View file

@ -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 };