update by branch

This commit is contained in:
Dustin Loring 2024-12-15 11:06:33 -05:00
parent a698fba1c7
commit b160d23b48

View File

@ -36,7 +36,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', commitJson: (branch: string) => `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/app/commit.json`,
}; };
function getSystemInfo(): SystemInfo { function getSystemInfo(): SystemInfo {
@ -260,8 +260,11 @@ export default function DebugTab() {
setIsCheckingUpdate(true); setIsCheckingUpdate(true);
setUpdateMessage('Checking for updates...'); setUpdateMessage('Checking for updates...');
// Fetch the commit data from the specified URL // Get current branch from commit.json
const localCommitResponse = await fetch(GITHUB_URLS.commitJson); const currentBranch = commit.branch || 'main';
// Fetch the commit data from the specified URL for the current branch
const localCommitResponse = await fetch(GITHUB_URLS.commitJson(currentBranch));
if (!localCommitResponse.ok) { if (!localCommitResponse.ok) {
throw new Error('Failed to fetch repository information'); throw new Error('Failed to fetch repository information');
} }
@ -269,21 +272,22 @@ export default function DebugTab() {
// Define the expected structure of the commit data // Define the expected structure of the commit data
interface CommitData { interface CommitData {
commit: string; commit: string;
branch: string;
} }
const localCommitData: CommitData = await localCommitResponse.json(); // Explicitly define the type here const localCommitData: CommitData = await localCommitResponse.json();
const originalCommitHash = localCommitData.commit; // Use the fetched commit hash const originalCommitHash = localCommitData.commit;
const currentLocalCommitHash = commit.commit; // Your current local commit hash const currentLocalCommitHash = commit.commit;
if (originalCommitHash !== currentLocalCommitHash) { if (originalCommitHash !== currentLocalCommitHash) {
setUpdateMessage( setUpdateMessage(
`Update available from original repository!\n` + `Update available from original repository (${currentBranch} branch)!\n` +
`Current: ${currentLocalCommitHash.slice(0, 7)}\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 (${currentBranch} branch)`);
} }
} catch (error) { } catch (error) {
setUpdateMessage('Failed to check for updates'); setUpdateMessage('Failed to check for updates');