Update DebugTab.tsx

Fixed Check for Update not getting the correct commit
This commit is contained in:
Dustin Loring 2024-12-14 20:09:25 -05:00
parent 9efc709782
commit bb03c30ddd

View File

@ -35,6 +35,7 @@ const versionHash = commit.commit;
const GITHUB_URLS = { const GITHUB_URLS = {
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main', original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main',
fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main', fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
commitJson: 'https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/main/app/commit.json',
}; };
function getSystemInfo(): SystemInfo { function getSystemInfo(): SystemInfo {
@ -257,29 +258,22 @@ export default function DebugTab() {
setIsCheckingUpdate(true); setIsCheckingUpdate(true);
setUpdateMessage('Checking for updates...'); setUpdateMessage('Checking for updates...');
const [originalResponse, forkResponse] = await Promise.all([ // Fetch the commit data from the specified URL
fetch(GITHUB_URLS.original), const localCommitResponse = await fetch(GITHUB_URLS.commitJson);
fetch(GITHUB_URLS.fork), if (!localCommitResponse.ok) {
]);
if (!originalResponse.ok || !forkResponse.ok) {
throw new Error('Failed to fetch repository information'); throw new Error('Failed to fetch repository information');
} }
const [originalData, forkData] = await Promise.all([ const localCommitData = await localCommitResponse.json();
originalResponse.json() as Promise<{ sha: string }>, const originalCommitHash = localCommitData.commit; // Use the fetched commit hash
forkResponse.json() as Promise<{ sha: string }>,
]);
const originalCommitHash = originalData.sha; const currentLocalCommitHash = commit.commit; // Your current local commit hash
const forkCommitHash = forkData.sha;
const isForked = versionHash === forkCommitHash && forkCommitHash !== originalCommitHash;
if (originalCommitHash !== versionHash) { if (originalCommitHash !== currentLocalCommitHash) {
setUpdateMessage( setUpdateMessage(
`Update available from original repository!\n` + `Update available from original repository!\n` +
`Current: ${versionHash.slice(0, 7)}${isForked ? ' (forked)' : ''}\n` + `Current: ${currentLocalCommitHash.slice(0, 7)}\n` +
`Latest: ${originalCommitHash.slice(0, 7)}`, `Latest: ${originalCommitHash.slice(0, 7)}`
); );
} else { } else {
setUpdateMessage('You are on the latest version from the original repository'); setUpdateMessage('You are on the latest version from the original repository');