mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-03-09 21:50:36 +00:00
fix: git clone modal to work with non main as default branch (#1428)
This commit is contained in:
parent
f9436d4929
commit
73a0f3ae24
@ -292,11 +292,24 @@ export function RepositorySelectionDialog({ isOpen, onClose, onSelect }: Reposit
|
|||||||
|
|
||||||
const connection = getLocalStorage('github_connection');
|
const connection = getLocalStorage('github_connection');
|
||||||
const headers: HeadersInit = connection?.token ? { Authorization: `Bearer ${connection.token}` } : {};
|
const headers: HeadersInit = connection?.token ? { Authorization: `Bearer ${connection.token}` } : {};
|
||||||
|
const repoObjResponse = await fetch(`https://api.github.com/repos/${owner}/${repo}`, {
|
||||||
// Fetch repository tree
|
|
||||||
const treeResponse = await fetch(`https://api.github.com/repos/${owner}/${repo}/git/trees/main?recursive=1`, {
|
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
|
const repoObjData = (await repoObjResponse.json()) as any;
|
||||||
|
|
||||||
|
if (!repoObjData.default_branch) {
|
||||||
|
throw new Error('Failed to fetch repository branch');
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultBranch = repoObjData.default_branch;
|
||||||
|
|
||||||
|
// Fetch repository tree
|
||||||
|
const treeResponse = await fetch(
|
||||||
|
`https://api.github.com/repos/${owner}/${repo}/git/trees/${defaultBranch}?recursive=1`,
|
||||||
|
{
|
||||||
|
headers,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (!treeResponse.ok) {
|
if (!treeResponse.ok) {
|
||||||
throw new Error('Failed to fetch repository structure');
|
throw new Error('Failed to fetch repository structure');
|
||||||
|
Loading…
Reference in New Issue
Block a user