diff --git a/src/github/operations/branch-cleanup.ts b/src/github/operations/branch-cleanup.ts index 2d06335..fa6e659 100644 --- a/src/github/operations/branch-cleanup.ts +++ b/src/github/operations/branch-cleanup.ts @@ -81,9 +81,7 @@ export async function checkAndCommitOrDeleteBranch( ); // Set branch link since we now have commits - const branchUrl = USE_GITEA_API - ? createBranchUrl(owner, repo, claudeBranch) - : `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`; + const branchUrl = createBranchUrl(owner, repo, claudeBranch); branchLink = `\n[View branch](${branchUrl})`; } else { console.log( @@ -94,9 +92,7 @@ export async function checkAndCommitOrDeleteBranch( } catch (gitError) { console.error("Error checking/committing changes:", gitError); // If we can't check git status, assume the branch might have changes - const branchUrl = USE_GITEA_API - ? createBranchUrl(owner, repo, claudeBranch) - : `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`; + const branchUrl = createBranchUrl(owner, repo, claudeBranch); branchLink = `\n[View branch](${branchUrl})`; } } else { @@ -107,17 +103,13 @@ export async function checkAndCommitOrDeleteBranch( } } else { // Only add branch link if there are commits - const branchUrl = USE_GITEA_API - ? createBranchUrl(owner, repo, claudeBranch) - : `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`; + const branchUrl = createBranchUrl(owner, repo, claudeBranch); branchLink = `\n[View branch](${branchUrl})`; } } catch (error) { console.error("Error comparing commits on Claude branch:", error); // If we can't compare but the branch exists remotely, include the branch link - const branchUrl = USE_GITEA_API - ? createBranchUrl(owner, repo, claudeBranch) - : `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`; + const branchUrl = createBranchUrl(owner, repo, claudeBranch); branchLink = `\n[View branch](${branchUrl})`; } } diff --git a/src/github/operations/comment-logic.ts b/src/github/operations/comment-logic.ts index 79240b1..3f2bb7a 100644 --- a/src/github/operations/comment-logic.ts +++ b/src/github/operations/comment-logic.ts @@ -163,9 +163,7 @@ export function updateCommentBody(input: CommentUpdateInput): string { ? jobUrl.match(/\/([^\/]+)\/([^\/]+)\/(?:actions|tree|src)/) : jobUrl.match(/github\.com\/([^\/]+)\/([^\/]+)\//); if (repoMatch) { - branchUrl = USE_GITEA_API - ? createBranchUrl(repoMatch[1], repoMatch[2], finalBranchName) - : `${GITHUB_SERVER_URL}/${repoMatch[1]}/${repoMatch[2]}/tree/${finalBranchName}`; + branchUrl = createBranchUrl(repoMatch[1], repoMatch[2], finalBranchName); } } diff --git a/src/github/operations/comments/common.ts b/src/github/operations/comments/common.ts index a31f818..67a595f 100644 --- a/src/github/operations/comments/common.ts +++ b/src/github/operations/comments/common.ts @@ -17,20 +17,10 @@ export function createBranchLink( repo: string, branchName: string, ): string { - const branchUrl = USE_GITEA_API - ? createBranchUrl(owner, repo, branchName) - : `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${branchName}`; + const branchUrl = createBranchUrl(owner, repo, branchName); return `\n[View branch](${branchUrl})`; } -/** - * Get the branch URL path segment for the current platform - * Gitea uses /src/branch/ while GitHub uses /tree/ - */ -export function getBranchPath(): string { - return USE_GITEA_API ? "src/branch" : "tree"; -} - /** * Create a branch URL for the current platform */ @@ -39,7 +29,9 @@ export function createBranchUrl( repo: string, branchName: string, ): string { - return `${GITHUB_SERVER_URL}/${owner}/${repo}/${getBranchPath()}/${branchName}`; + return USE_GITEA_API + ? `${GITHUB_SERVER_URL}/${owner}/${repo}/src/branch/${branchName}` + : `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${branchName}`; } export function createCommentBody(