Add url to insights commit

This commit is contained in:
Sam Becker 2025-02-14 09:55:21 -06:00
parent 1cf2bc8dba
commit 6884be7039
3 changed files with 34 additions and 18 deletions

View File

@ -5,7 +5,7 @@ import {
VERCEL_GIT_REPO_SLUG,
VERCEL_GIT_COMMIT_SHA,
} from '@/app-core/config';
import { getGitHubMetaWithFallback, getGitHubRepoUrl } from '.';
import { getGitHubMetaWithFallback, getGitHubUrlRepo } from '.';
export default async function GitHubForkStatusBadgeServer() {
const owner = VERCEL_GIT_REPO_OWNER;
@ -24,7 +24,7 @@ export default async function GitHubForkStatusBadgeServer() {
const repoLink = (text: string) =>
<a
href={getGitHubRepoUrl({ owner, repo })}
href={getGitHubUrlRepo({ owner, repo })}
target="_blank"
className="underline hover:no-underline hover:text-main"
>

View File

@ -22,31 +22,40 @@ interface RepoParams {
// Website urls
export const getGitHubOwnerUrl = ({
export const getGitHubUrlOwner = ({
owner = TEMPLATE_REPO_OWNER,
}: RepoParams = {}) =>
`https://github.com/${owner}`;
export const getGitHubRepoUrl = ({
export const getGitHubUrlRepo = ({
owner = TEMPLATE_REPO_OWNER,
repo = TEMPLATE_REPO_NAME,
}: RepoParams = {}) =>
`${getGitHubOwnerUrl({ owner })}/${repo}`;
`${getGitHubUrlOwner({ owner })}/${repo}`;
export const getGitHubBranchUrl = ({
export const getGitHubUrlBranch = ({
owner = TEMPLATE_REPO_OWNER,
repo = TEMPLATE_REPO_NAME,
branch = DEFAULT_BRANCH,
}: RepoParams = {}) =>
`${getGitHubRepoUrl({ owner, repo })}/tree/${branch}`;
`${getGitHubUrlRepo({ owner, repo })}/tree/${branch}`;
export const getGitHubCompareUrl = ({
export const getGitHubUrlCommit = ({
owner = TEMPLATE_REPO_OWNER,
repo = TEMPLATE_REPO_NAME,
commit,
}: RepoParams = {}) =>
commit
? `${getGitHubUrlRepo({ owner, repo })}/commit/${commit}`
: undefined;
export const getGitHubUrlCompare = ({
owner,
repo,
branch = DEFAULT_BRANCH,
}: RepoParams = {}) =>
// eslint-disable-next-line max-len
`${getGitHubRepoUrl({ owner, repo })}/compare/${branch}...${TEMPLATE_REPO_OWNER}:${TEMPLATE_REPO_NAME}:${TEMPLATE_REPO_BRANCH}`;
`${getGitHubUrlRepo({ owner, repo })}/compare/${branch}...${TEMPLATE_REPO_OWNER}:${TEMPLATE_REPO_NAME}:${TEMPLATE_REPO_BRANCH}`;
// API urls
@ -124,9 +133,10 @@ export const getGitHubPublicFork = async (
};
const getGitHubMeta = async (params: RepoParams) => {
const urlOwner = getGitHubOwnerUrl(params);
const urlRepo = getGitHubRepoUrl(params);
const urlBranch = getGitHubBranchUrl(params);
const urlOwner = getGitHubUrlOwner(params);
const urlRepo = getGitHubUrlRepo(params);
const urlBranch = getGitHubUrlBranch(params);
const urlCommit = getGitHubUrlCommit(params);
const isBaseRepo = isRepoBaseRepo(params);
@ -163,6 +173,7 @@ const getGitHubMeta = async (params: RepoParams) => {
urlOwner,
urlRepo,
urlBranch,
urlCommit,
isForkedFromBase,
isBaseRepo,
behindBy,
@ -183,6 +194,7 @@ export const getGitHubMetaWithFallback = (params: RepoParams) =>
urlOwner: undefined,
urlRepo: undefined,
urlBranch: undefined,
urlCommit: undefined,
isForkedFromBase: false,
isBaseRepo: undefined,
behindBy: undefined,

View File

@ -134,14 +134,18 @@ export default function AdminAppInsightsClient({
/>
<ScoreCardRow
icon={<BiGitCommit size={18} className="translate-y-[0px]" />}
content={<div className="flex items-center gap-2">
<div className="text-medium">
content={<a
href={codeMeta?.urlCommit}
target="blank"
className="flex items-center gap-2"
>
<span className="text-medium">
{VERCEL_GIT_COMMIT_SHA_SHORT ?? DEBUG_COMMIT_SHA}
</div>
<div className="truncate">
</span>
<span className="truncate">
{VERCEL_GIT_COMMIT_MESSAGE ?? DEBUG_COMMIT_MESSAGE}
</div>
</div>}
</span>
</a>}
/>
</ScoreCard>
</>}