Skip to content

Commit

Permalink
fix: validate commit SHA before displaying link in WorkloadDeploy com…
Browse files Browse the repository at this point in the history
…ponent
  • Loading branch information
rbjornstad committed Feb 10, 2025
1 parent 1c57136 commit 88aa272
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/lib/components/WorkloadDeploy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
)
);
//let workloadName = $derived($data.name);
//let workloadType = $derived($data.__typename === 'Application' ? 'app' : 'job');
let deploymentInfo = $derived(
$data.deployments.nodes.length > 0 ? $data.deployments.nodes[0] : null
);
//const githubOrganization = get(page).data.githubOrganization;
function isValidSha(sha: string): boolean {
return /^[0-9a-f]{40}$/i.test(sha);
}
</script>

<div>
Expand All @@ -54,15 +53,13 @@
<div><a href={deploymentInfo.triggerUrl}>Github action <ExternalLinkIcon /></a></div>
{/if}

<!-- TODO: Put back when commitSha is available from API -->
<!--{#if deploymentInfo?.commitSha}
<div>
<a
href="https://github.com/{githubOrganization}/{deploymentInfo?.repository}/commit/{deploymentInfo?.repository}"
>Commit {deploymentInfo?.commitSha.slice(0, 7)} <ExternalLinkIcon /></a
>
</div>
{/if}-->
{#if deploymentInfo?.commitSha && isValidSha(deploymentInfo?.commitSha)}
<div>
<a href="https://github.com/{deploymentInfo?.repository}/commit/{deploymentInfo?.commitSha}"
>Commit {deploymentInfo?.commitSha.slice(0, 7)} <ExternalLinkIcon /></a
>
</div>
{/if}
{:else}
No deployments
{/if}

0 comments on commit 88aa272

Please sign in to comment.