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

feat(pr): pr edited body not comment #6695

Merged
merged 3 commits into from Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/config/__snapshots__/migration.spec.ts.snap
Expand Up @@ -149,6 +149,7 @@ Object {
"separateMajorReleases": true,
"separateMinorPatch": true,
"suppressNotifications": Array [
"lockFileErrors",
"deprecationWarningIssues",
],
"travis": Object {
Expand Down
1 change: 0 additions & 1 deletion lib/config/definitions.ts
Expand Up @@ -1694,7 +1694,6 @@ const options: RenovateOptions[] = [
default: ['deprecationWarningIssues'],
allowedValues: [
'prIgnoreNotification',
'prEditNotification',
'branchAutomergeFailure',
'lockFileErrors',
'artifactErrors',
Expand Down
1 change: 1 addition & 0 deletions lib/config/migration.spec.ts
Expand Up @@ -32,6 +32,7 @@ describe('config/migration', () => {
gitFs: false,
separateMajorReleases: true,
separatePatchReleases: true,
suppressNotifications: ['lockFileErrors', 'prEditNotification'],
automerge: 'none' as never,
automergeMajor: false,
automergeMinor: true,
Expand Down
7 changes: 7 additions & 0 deletions lib/config/migration.ts
Expand Up @@ -76,6 +76,13 @@ export function migrateConfig(
);
}
delete migratedConfig.pathRules;
} else if (key === 'suppressNotifications') {
if (is.nonEmptyArray(val) && val.includes('prEditNotification')) {
isMigrated = true;
migratedConfig.suppressNotifications = migratedConfig.suppressNotifications.filter(
(item) => item !== 'prEditNotification'
);
}
rarkins marked this conversation as resolved.
Show resolved Hide resolved
} else if (key === 'gomodTidy') {
isMigrated = true;
if (val) {
Expand Down
1 change: 1 addition & 0 deletions lib/workers/branch/index.spec.ts
Expand Up @@ -190,6 +190,7 @@ describe('workers/branch', () => {
platform.getBranchPr.mockResolvedValueOnce({
state: PR_STATE_OPEN,
isModified: true,
body: '**Rebasing**: something',
} as never);
const res = await branchWorker.processBranch(config);
expect(res).toEqual('pr-edited');
Expand Down
40 changes: 11 additions & 29 deletions lib/workers/branch/index.ts
Expand Up @@ -48,6 +48,8 @@ function rebaseCheck(config: RenovateConfig, branchPr: any): boolean {
return titleRebase || labelRebase || prRebaseChecked;
}

const rebasingRegex = /\*\*Rebasing\*\*: .*/;

export async function processBranch(
branchConfig: BranchConfig,
prHourlyLimitReached?: boolean
Expand Down Expand Up @@ -158,44 +160,24 @@ export async function processBranch(
);
throw new Error(REPOSITORY_CHANGED);
}
const topic = 'PR has been edited';
if (
branchPr.isModified ||
(branchPr.targetBranch &&
branchPr.targetBranch !== branchConfig.baseBranch)
) {
logger.debug({ prNo: branchPr.number }, 'PR has been edited');
if (masterIssueCheck || config.rebaseRequested) {
if (config.dryRun) {
logger.info(
'DRY-RUN: Would ensure PR edited comment removal in PR #' +
branchPr.number
);
} else {
// Remove any "PR has been edited" comment only when rebasing
await platform.ensureCommentRemoval({
number: branchPr.number,
topic,
});
}
logger.debug('Manual rebase has been requested for PR');
} else {
let content = emojify(
`:construction_worker: This PR has received other commits, so Renovate will stop updating it to avoid conflicts or other problems.`
const newBody = branchPr.body?.replace(
rebasingRegex,
'**Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.'
);
content += ` If you wish to abandon your changes and have Renovate start over you may click the "rebase" checkbox in the PR body/description.`;
content += `\n\nIf you think this comment is in error and the branch is *not* modified, try deleting this comment. If it comes back again the next time Renovate runs, please submit an issue or seek config help.`;
if (!config.suppressNotifications.includes('prEditNotification')) {
if (config.dryRun) {
logger.info(
'DRY-RUN: ensure comment in PR #' + branchPr.number
);
} else {
await platform.ensureComment({
number: branchPr.number,
topic,
content,
});
}
if (newBody !== branchPr.body) {
logger.debug(
'Updating existing PR to indicate that rebasing is not possible'
);
await platform.updatePr(branchPr.number, branchPr.title, newBody);
}
return 'pr-edited';
}
Expand Down