simplify createBranchUrl
This commit is contained in:
parent
7904dcc331
commit
e5ee232989
@ -81,9 +81,7 @@ export async function checkAndCommitOrDeleteBranch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Set branch link since we now have commits
|
// Set branch link since we now have commits
|
||||||
const branchUrl = USE_GITEA_API
|
const branchUrl = createBranchUrl(owner, repo, claudeBranch);
|
||||||
? createBranchUrl(owner, repo, claudeBranch)
|
|
||||||
: `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
|
||||||
branchLink = `\n[View branch](${branchUrl})`;
|
branchLink = `\n[View branch](${branchUrl})`;
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
@ -94,9 +92,7 @@ export async function checkAndCommitOrDeleteBranch(
|
|||||||
} catch (gitError) {
|
} catch (gitError) {
|
||||||
console.error("Error checking/committing changes:", gitError);
|
console.error("Error checking/committing changes:", gitError);
|
||||||
// If we can't check git status, assume the branch might have changes
|
// If we can't check git status, assume the branch might have changes
|
||||||
const branchUrl = USE_GITEA_API
|
const branchUrl = createBranchUrl(owner, repo, claudeBranch);
|
||||||
? createBranchUrl(owner, repo, claudeBranch)
|
|
||||||
: `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
|
||||||
branchLink = `\n[View branch](${branchUrl})`;
|
branchLink = `\n[View branch](${branchUrl})`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -107,17 +103,13 @@ export async function checkAndCommitOrDeleteBranch(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Only add branch link if there are commits
|
// Only add branch link if there are commits
|
||||||
const branchUrl = USE_GITEA_API
|
const branchUrl = createBranchUrl(owner, repo, claudeBranch);
|
||||||
? createBranchUrl(owner, repo, claudeBranch)
|
|
||||||
: `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
|
||||||
branchLink = `\n[View branch](${branchUrl})`;
|
branchLink = `\n[View branch](${branchUrl})`;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error comparing commits on Claude branch:", error);
|
console.error("Error comparing commits on Claude branch:", error);
|
||||||
// If we can't compare but the branch exists remotely, include the branch link
|
// If we can't compare but the branch exists remotely, include the branch link
|
||||||
const branchUrl = USE_GITEA_API
|
const branchUrl = createBranchUrl(owner, repo, claudeBranch);
|
||||||
? createBranchUrl(owner, repo, claudeBranch)
|
|
||||||
: `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
|
||||||
branchLink = `\n[View branch](${branchUrl})`;
|
branchLink = `\n[View branch](${branchUrl})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,9 +163,7 @@ export function updateCommentBody(input: CommentUpdateInput): string {
|
|||||||
? jobUrl.match(/\/([^\/]+)\/([^\/]+)\/(?:actions|tree|src)/)
|
? jobUrl.match(/\/([^\/]+)\/([^\/]+)\/(?:actions|tree|src)/)
|
||||||
: jobUrl.match(/github\.com\/([^\/]+)\/([^\/]+)\//);
|
: jobUrl.match(/github\.com\/([^\/]+)\/([^\/]+)\//);
|
||||||
if (repoMatch) {
|
if (repoMatch) {
|
||||||
branchUrl = USE_GITEA_API
|
branchUrl = createBranchUrl(repoMatch[1], repoMatch[2], finalBranchName);
|
||||||
? createBranchUrl(repoMatch[1], repoMatch[2], finalBranchName)
|
|
||||||
: `${GITHUB_SERVER_URL}/${repoMatch[1]}/${repoMatch[2]}/tree/${finalBranchName}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,20 +17,10 @@ export function createBranchLink(
|
|||||||
repo: string,
|
repo: string,
|
||||||
branchName: string,
|
branchName: string,
|
||||||
): string {
|
): string {
|
||||||
const branchUrl = USE_GITEA_API
|
const branchUrl = createBranchUrl(owner, repo, branchName);
|
||||||
? createBranchUrl(owner, repo, branchName)
|
|
||||||
: `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${branchName}`;
|
|
||||||
return `\n[View branch](${branchUrl})`;
|
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
|
* Create a branch URL for the current platform
|
||||||
*/
|
*/
|
||||||
@ -39,7 +29,9 @@ export function createBranchUrl(
|
|||||||
repo: string,
|
repo: string,
|
||||||
branchName: string,
|
branchName: string,
|
||||||
): 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(
|
export function createCommentBody(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user