Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve branch support logic #301

Merged
merged 1 commit into from
Aug 22, 2024
Merged

Conversation

codebytere
Copy link
Member

Secondary to #300

Cleans up some comment-initiated backport logic

@codebytere codebytere requested a review from a team as a code owner August 19, 2024 08:17
src/index.ts Outdated
);

if (!branch.trim()) continue;
Copy link
Member

@ckerr ckerr Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that the trim() call is redundant after map ((b) => b.trim()), but do we need to still check whether branch is empty? Or add a .filter() after .map() to remove empty strings?

Copy link
Member

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I am missing something here, but it looks like this change moves the check for branch existence to only fire when NO_EOL_SUPPORT is set?

Comment on lines +569 to +583
try {
await context.octokit.repos.getBranch(context.repo({ branch }));
} catch (err) {
robot.log(
`${branch} does not exist - no backport will be initiated`,
);
await context.octokit.issues.createComment(
context.repo({
body: `Provided branch \`${branch}\` does not appear to exist.`,
issue_number: issue.number,
}),
);
continue;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this block moved under the section flagged by NO_EOL_SUPPORT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getSupportedBranches itself checks branch existence - so in moving it down we save a redundant check in the case the variable is set.

@codebytere
Copy link
Member Author

@jkleinsc

check for branch existence to only fire when NO_EOL_SUPPORT is set?

it moves the conditional down, but not inside the check - if NO_EOL_SUPPORT the check still runs.

@codebytere codebytere merged commit c8c9cf4 into main Aug 22, 2024
3 checks passed
@codebytere codebytere deleted the cleanup-supported-logic branch August 22, 2024 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants