Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commit hash to URL #419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading