Skip to content

Commit 8feae0b

Browse files
committed
style: format code and fix indentation in PR and branch utilities
1 parent 8941bf3 commit 8feae0b

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

src/utils/contribute-utils/branch-utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function checkoutExistingBranch(
4949
logger.info(
5050
`Checking out existing branch ${branchName} in forked repository`
5151
);
52-
52+
5353
try {
5454
// Try to checkout local branch first
5555
execSync(`git checkout ${escapeShellArg(branchName)}`, {
@@ -60,14 +60,14 @@ export function checkoutExistingBranch(
6060
} catch (localCheckoutError) {
6161
// If local checkout fails, try to checkout from remote
6262
logger.info(`Local branch not found, trying to checkout from remote`);
63-
63+
6464
try {
6565
// Fetch the branch from remote
6666
execSync(`git fetch origin ${escapeShellArg(branchName)}`, {
6767
stdio: "inherit",
6868
cwd: tempDir,
6969
});
70-
70+
7171
// Create a tracking branch
7272
execSync(
7373
`git checkout -b ${escapeShellArg(branchName)} --track origin/${escapeShellArg(branchName)}`,
@@ -110,7 +110,7 @@ export function pushBranch(tempDir: string, branchName: string): boolean {
110110
logger.warn(
111111
`Push failed, remote branch exists and is different. Using force push to avoid conflicts.`
112112
);
113-
113+
114114
// Instead of trying to merge (which can cause conflicts),
115115
// we'll use force push since this is a contribution workflow
116116
// where we want our local changes to take precedence

src/utils/contribute-utils/pr-utils.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ export function createPullRequest(
4242
prTitle: string,
4343
prBody: string,
4444
dryRun: boolean = false
45-
): { success: boolean; prNumber?: number; prUrl?: string; alreadyExists?: boolean } {
45+
): {
46+
success: boolean;
47+
prNumber?: number;
48+
prUrl?: string;
49+
alreadyExists?: boolean;
50+
} {
4651
try {
4752
// If in dry run mode, just log what would happen and return success
4853
if (dryRun) {
@@ -70,9 +75,9 @@ export function createPullRequest(
7075
cwd: tempDir,
7176
encoding: "utf8",
7277
});
73-
78+
7479
const prList = JSON.parse(prListOutput);
75-
80+
7681
if (prList.length > 0) {
7782
// PR already exists
7883
const existingPr = prList[0];
@@ -86,7 +91,9 @@ export function createPullRequest(
8691
}
8792
} catch (checkError) {
8893
// Ignore errors checking for existing PRs
89-
logger.warn(`Error checking for existing PRs: ${(checkError as Error).message}`);
94+
logger.warn(
95+
`Error checking for existing PRs: ${(checkError as Error).message}`
96+
);
9097
}
9198

9299
// Create PR using GitHub CLI
@@ -122,11 +129,13 @@ export function createPullRequest(
122129
const errorMessage = (prError as Error).message;
123130
if (errorMessage.includes("already exists")) {
124131
// Extract the PR URL from the error message
125-
const urlMatch = errorMessage.match(/https:\/\/github\.com\/[^\/]+\/[^\/]+\/pull\/\d+/);
132+
const urlMatch = errorMessage.match(
133+
/https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/\d+/
134+
);
126135
if (urlMatch) {
127136
const prUrl = urlMatch[0];
128137
const prNumber = prUrl.split("/").pop();
129-
138+
130139
logger.info(`Pull request already exists: ${prUrl}`);
131140
return {
132141
success: true,
@@ -136,7 +145,7 @@ export function createPullRequest(
136145
};
137146
}
138147
}
139-
148+
140149
// Re-throw if we couldn't handle the error
141150
throw prError;
142151
}

0 commit comments

Comments
 (0)