You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PR_FROM_MAIN_ERROR = 'Pull requests from `main` branch of a fork cannot be accepted. Please reopen this contribution from another branch on your fork. For more information, see https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md#step-4-pull-request.';
/**
* Types of exemption labels in aws-cdk project.
*/
Expand DownExpand Up
@@ -268,6 +270,16 @@ export class PullRequestLinter {
body,
});
// Commenting this code to first test that linter rule works
// since this can lead to other PRs closing if not setup correctly
// // Closing the PR if it is opened from main branch of author's fork
// if (failureMessages.includes(PR_FROM_MAIN_ERROR)) {
// await this.client.pulls.update({
// ...this.prParams,
// state: 'closed',
// });
// }
throw new LinterError(body);
}
Expand DownExpand Up
@@ -508,6 +520,9 @@ export class PullRequestLinter {
validationCollector.validateRuleSet({
testRuleSet: [{ test: validateTitleScope }],
});
validationCollector.validateRuleSet({
testRuleSet: [{ test: validateBranch }],
})
validationCollector.validateRuleSet({
exemption: shouldExemptBreakingChange,
Expand DownExpand Up
@@ -687,6 +702,22 @@ function validateTitleScope(pr: GitHubPr): TestResult {
return result;
}
/**
* Check that the PR is not opened from main branch of author's fork
*
* @param pr github pr
* @returns test result
*/
function validateBranch(pr: GitHubPr): TestResult {
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await expect(prLinter.validatePullRequestTarget(SHA)).rejects.toThrow(/Pull requests from `main` branch of a fork cannot be accepted. Please reopen this contribution from another branch on your fork./);
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
chore(prlint): add rule to reject pr contribution from main branch #27617
chore(prlint): add rule to reject pr contribution from main branch #27617
Changes from all commits
b29d5c2
bc082d0
724af53
41063ac
2500543
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing