Skip to content

Commit

Permalink
Add commit hash to URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Woody4618 committed Nov 22, 2024
1 parent a39fbe9 commit d773264
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/utils/verified-builds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ export function useVerifiedProgramRegistry({
verifiedData.verify_command += ` ${argsString}`;
}
}
verifiedData.repo_url = pdaData.gitUrl;

if (!verifiedData.repo_url) {
verifiedData.repo_url = pdaData.gitUrl;
if (pdaData.commit) {
verifiedData.repo_url = addCommitHashToUrl(verifiedData.repo_url, pdaData.commit);
}
}

if (registryData.verification_status === VerificationStatus.NotVerified) {
verifiedData.message = 'Verify command was provided by the program authority.';
verifiedData.verification_status = VerificationStatus.PdaUploaded;
Expand All @@ -146,6 +153,15 @@ export function useVerifiedProgramRegistry({
return { data: null, isLoading };
}

function addCommitHashToUrl(repoUrl: string, commitHash: string): string {
// Ensure the URL doesn't already include a branch or tree reference
const cleanUrl = repoUrl.replace(/\/tree\/[^/]+$/, '').replace(/\/$/, '');

// Append the commit hash with the "tree" path
const urlWithCommit = `${cleanUrl}/tree/${commitHash}`;
return urlWithCommit;
}

function isMainnet(currentCluster: Cluster): boolean {
return currentCluster == Cluster.MainnetBeta;
}
Expand Down

0 comments on commit d773264

Please sign in to comment.