From 6884be70390a83104c5b2ea3d6b079b51eb69d7b Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 14 Feb 2025 09:55:21 -0600 Subject: [PATCH] Add url to insights commit --- .../github/GitHubForkStatusBadgeServer.tsx | 4 +-- src/admin/github/index.ts | 32 +++++++++++++------ src/admin/insights/AdminAppInsightsClient.tsx | 16 ++++++---- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/admin/github/GitHubForkStatusBadgeServer.tsx b/src/admin/github/GitHubForkStatusBadgeServer.tsx index a9959144..ab49eaca 100644 --- a/src/admin/github/GitHubForkStatusBadgeServer.tsx +++ b/src/admin/github/GitHubForkStatusBadgeServer.tsx @@ -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) => diff --git a/src/admin/github/index.ts b/src/admin/github/index.ts index 077405ef..58208bbc 100644 --- a/src/admin/github/index.ts +++ b/src/admin/github/index.ts @@ -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, diff --git a/src/admin/insights/AdminAppInsightsClient.tsx b/src/admin/insights/AdminAppInsightsClient.tsx index 32fce23c..fe197943 100644 --- a/src/admin/insights/AdminAppInsightsClient.tsx +++ b/src/admin/insights/AdminAppInsightsClient.tsx @@ -134,14 +134,18 @@ export default function AdminAppInsightsClient({ /> } - content={
-
+ content={ + {VERCEL_GIT_COMMIT_SHA_SHORT ?? DEBUG_COMMIT_SHA} -
-
+ + {VERCEL_GIT_COMMIT_MESSAGE ?? DEBUG_COMMIT_MESSAGE} -
-
} + + } /> }