From 1c33d1c10139eace5e739fc7a1f2560874d8fd9f Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 5 Dec 2019 10:45:28 +0100 Subject: [PATCH] fix: drop appSlug configurability (#4930) --- lib/config/app-strings.ts | 2 -- lib/config/definitions.ts | 4 ++-- lib/platform/azure/index.ts | 3 +-- lib/platform/bitbucket/index.ts | 3 +-- lib/platform/github/index.ts | 4 ++-- lib/workers/branch/index.ts | 6 +++--- lib/workers/branch/parent.ts | 3 +-- lib/workers/branch/status-checks.ts | 5 ++--- lib/workers/pr/body/controls.js | 4 +--- lib/workers/repository/finalise/validate.js | 6 +++--- lib/workers/repository/onboarding/branch/check.ts | 8 ++------ lib/workers/repository/onboarding/branch/config.ts | 7 ++++--- test/platform/bitbucket-server/index.spec.ts | 2 +- .../utils/__snapshots__/pr-body.spec.ts.snap | 4 ++-- test/platform/utils/_fixtures/pr-body.txt | 2 +- test/workers/branch/index.spec.js | 7 +++---- test/workers/branch/parent.spec.js | 2 +- test/workers/pr/__snapshots__/index.spec.ts.snap | 12 ++++++------ 18 files changed, 36 insertions(+), 48 deletions(-) diff --git a/lib/config/app-strings.ts b/lib/config/app-strings.ts index bc3fb3f0c9..8c3758d402 100644 --- a/lib/config/app-strings.ts +++ b/lib/config/app-strings.ts @@ -1,7 +1,5 @@ export const appName = 'Renovate'; -export const appSlug = 'renovate'; - export const configFileNames = [ 'renovate.json', 'renovate.json5', diff --git a/lib/config/definitions.ts b/lib/config/definitions.ts index 3ea310b5dd..64622fea1f 100644 --- a/lib/config/definitions.ts +++ b/lib/config/definitions.ts @@ -1,4 +1,4 @@ -import { appName, appSlug } from './app-strings'; +import { appName } from './app-strings'; import { RenovateConfigStage } from './common'; export interface RenovateOptionBase { @@ -906,7 +906,7 @@ const options: RenovateOptions[] = [ description: 'Prefix to use for all branch names', stage: 'branch', type: 'string', - default: `${appSlug}/`, + default: `renovate/`, }, { name: 'bumpVersion', diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 57f6226219..8c8c70cde3 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -3,7 +3,6 @@ import { GitPullRequestMergeStrategy } from 'azure-devops-node-api/interfaces/Gi import * as azureHelper from './azure-helper'; import * as azureApi from './azure-got-wrapper'; import * as hostRules from '../../util/host-rules'; -import { appSlug } from '../../config/app-strings'; import GitStorage, { StatusResult, File } from '../git/storage'; import { logger } from '../../logger'; import { @@ -519,7 +518,7 @@ export async function mergePr(pr: number): Promise<void> { export function getPrBody(input: string): string { // Remove any HTML we use return smartTruncate(input, 4000) - .replace(new RegExp(`\n---\n\n.*?<!-- ${appSlug}-rebase -->.*?\n`), '') + .replace(new RegExp(`\n---\n\n.*?<!-- rebase-check -->.*?\n`), '') .replace('<summary>', '**') .replace('</summary>', '**') .replace('<details>', '') diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index c99f5bbf5b..c1491ca773 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -6,7 +6,6 @@ import * as hostRules from '../../util/host-rules'; import { logger } from '../../logger'; import GitStorage, { StatusResult, File } from '../git/storage'; import { readOnlyIssueBody } from '../utils/read-only-issue-body'; -import { appSlug } from '../../config/app-strings'; import * as comments from './comments'; import { PlatformConfig, @@ -517,7 +516,7 @@ export function getPrBody(input: string): string { return smartTruncate(input, 50000) .replace(/<\/?summary>/g, '**') .replace(/<\/?details>/g, '') - .replace(new RegExp(`\n---\n\n.*?<!-- ${appSlug}-rebase -->.*?\n`), '') + .replace(new RegExp(`\n---\n\n.*?<!-- rebase-check -->.*?\n`), '') .replace(/\]\(\.\.\/pull\//g, '](../../pull-requests/'); } diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 8ccb406abb..80e2055d01 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -15,7 +15,7 @@ import { VulnerabilityAlert, } from '../common'; -import { appName, appSlug, configFileNames } from '../../config/app-strings'; +import { appName, configFileNames } from '../../config/app-strings'; import { sanitize } from '../../util/sanitize'; import { smartTruncate } from '../utils/pr-body'; @@ -1640,7 +1640,7 @@ export async function createPr( logger.debug('Setting statusCheckVerify'); await setBranchStatus( branchName, - `${appSlug}/verify`, + `renovate/verify`, `${appName} verified pull request`, 'success', 'https://github.com/renovatebot/renovate' diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts index b4dcdc07a8..48144399bd 100644 --- a/lib/workers/branch/index.ts +++ b/lib/workers/branch/index.ts @@ -18,7 +18,7 @@ import { } from './status-checks'; import { prAlreadyExisted } from './check-existing'; import { ensurePr, checkAutoMerge } from '../pr'; -import { appName, appSlug } from '../../config/app-strings'; +import { appName } from '../../config/app-strings'; import { RenovateConfig } from '../../config'; import { platform } from '../../platform'; import { emojify } from '../../util/emoji'; @@ -48,7 +48,7 @@ function rebaseCheck(config: RenovateConfig, branchPr: any): boolean { const labelRebase = branchPr.labels && branchPr.labels.includes(config.rebaseLabel); const prRebaseChecked = - branchPr.body && branchPr.body.includes(`- [x] <!-- ${appSlug}-rebase -->`); + branchPr.body && branchPr.body.includes(`- [x] <!-- rebase-check -->`); return titleRebase || labelRebase || prRebaseChecked; } @@ -507,7 +507,7 @@ export async function processBranch( ); } } - const context = `${appSlug}/artifacts`; + const context = `renovate/artifacts`; const description = 'Artifact file update failure'; const state = 'failure'; const existingState = await platform.getBranchStatusCheck( diff --git a/lib/workers/branch/parent.ts b/lib/workers/branch/parent.ts index 4ca6e2a0d3..7c1a4ea331 100644 --- a/lib/workers/branch/parent.ts +++ b/lib/workers/branch/parent.ts @@ -1,5 +1,4 @@ import { logger } from '../../logger'; -import { appSlug } from '../../config/app-strings'; import { RenovateConfig } from '../../config'; import { platform } from '../../platform'; @@ -25,7 +24,7 @@ export async function getParentBranch( logger.info('Manual rebase requested via PR title for #' + pr.number); return { parentBranch: undefined }; } - if (pr.body && pr.body.includes(`- [x] <!-- ${appSlug}-rebase -->`)) { + if (pr.body && pr.body.includes(`- [x] <!-- rebase-check -->`)) { logger.info('Manual rebase requested via PR checkbox for #' + pr.number); return { parentBranch: undefined }; } diff --git a/lib/workers/branch/status-checks.ts b/lib/workers/branch/status-checks.ts index c96e15c54b..c0d780b292 100644 --- a/lib/workers/branch/status-checks.ts +++ b/lib/workers/branch/status-checks.ts @@ -1,5 +1,4 @@ import { logger } from '../../logger'; -import { appSlug } from '../../config/app-strings'; import { RenovateConfig } from '../../config'; import { platform } from '../../platform'; @@ -38,7 +37,7 @@ export async function setStability(config: StabilityConfig): Promise<void> { if (!config.stabilityStatus) { return; } - const context = `${appSlug}/stability-days`; + const context = `renovate/stability-days`; const description = config.stabilityStatus === 'success' ? 'Updates have met stability days requirement' @@ -64,7 +63,7 @@ export async function setUnpublishable( if (!config.unpublishSafe) { return; } - const context = `${appSlug}/unpublish-safe`; + const context = `renovate/unpublish-safe`; // Set canBeUnpublished status check const state = config.canBeUnpublished ? 'pending' : 'success'; const description = config.canBeUnpublished diff --git a/lib/workers/pr/body/controls.js b/lib/workers/pr/body/controls.js index d57fdec8bd..a3cb70e121 100644 --- a/lib/workers/pr/body/controls.js +++ b/lib/workers/pr/body/controls.js @@ -1,5 +1,3 @@ -const { appSlug } = require('../../../config/app-strings'); - export function getControls() { - return `\n\n---\n\n - [ ] <!-- ${appSlug}-rebase -->If you want to rebase/retry this PR, check this box\n\n`; + return `\n\n---\n\n - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box\n\n`; } diff --git a/lib/workers/repository/finalise/validate.js b/lib/workers/repository/finalise/validate.js index 099f558582..d43405036d 100644 --- a/lib/workers/repository/finalise/validate.js +++ b/lib/workers/repository/finalise/validate.js @@ -2,14 +2,14 @@ const JSON5 = require('json5'); const { logger, setMeta } = require('../../../logger'); const { migrateAndValidate } = require('../../../config/migrate-validate'); const { configFileNames } = require('../../../config/app-strings'); -const { appName, appSlug } = require('../../../config/app-strings'); +const { appName } = require('../../../config/app-strings'); const { platform } = require('../../../platform'); async function getRenovatePrs(branchPrefix) { return (await platform.getPrList()) .filter(pr => pr.state === 'open') .filter(pr => pr.branchName && !pr.branchName.startsWith(branchPrefix)) - .filter(pr => pr.title && pr.title.match(new RegExp(appSlug, 'i'))); + .filter(pr => pr.title && pr.title.match(new RegExp('renovate', 'i'))); } async function getRenovateFiles(prNo) { @@ -100,7 +100,7 @@ async function validatePrs(config) { // istanbul ignore else if (pr.sourceRepo === config.repository) { logger.info({ status, description }, 'Setting PR validation status'); - const context = `${appSlug}/validate`; + const context = `renovate/validate`; await platform.setBranchStatus( pr.branchName, context, diff --git a/lib/workers/repository/onboarding/branch/check.ts b/lib/workers/repository/onboarding/branch/check.ts index fe3e535264..06daee9724 100644 --- a/lib/workers/repository/onboarding/branch/check.ts +++ b/lib/workers/repository/onboarding/branch/check.ts @@ -1,10 +1,6 @@ import { logger } from '../../../../logger'; import { platform } from '../../../../platform'; -import { - appName, - appSlug, - configFileNames, -} from '../../../../config/app-strings'; +import { appName, configFileNames } from '../../../../config/app-strings'; import { RenovateConfig } from '../../../../config'; const findFile = async (fileName: string): Promise<boolean> => { @@ -25,7 +21,7 @@ const configFileExists = async (): Promise<boolean> => { const packageJsonConfigExists = async (): Promise<boolean> => { try { const pJson = JSON.parse(await platform.getFile('package.json')); - if (pJson[appSlug]) { + if (pJson.renovate) { return true; } } catch (err) { diff --git a/lib/workers/repository/onboarding/branch/config.ts b/lib/workers/repository/onboarding/branch/config.ts index 659011ae01..3366477f47 100644 --- a/lib/workers/repository/onboarding/branch/config.ts +++ b/lib/workers/repository/onboarding/branch/config.ts @@ -2,7 +2,6 @@ import is from '@sindresorhus/is'; import { clone } from '../../../../util/clone'; import { platform } from '../../../../platform'; import { logger } from '../../../../logger'; -import { appSlug } from '../../../../config/app-strings'; import { RenovateConfig } from '../../../../config'; export async function getOnboardingConfig( @@ -20,13 +19,15 @@ export async function getOnboardingConfig( const { label, branchName, ignore } = greenkeeperConfig; if (label) { logger.info({ label }, 'Migrating Greenkeeper label'); - onboardingConfig.labels = [String(label).replace('greenkeeper', appSlug)]; + onboardingConfig.labels = [ + String(label).replace('greenkeeper', 'renovate'), + ]; } if (branchName) { logger.info({ branch: branchName }, 'Migrating Greenkeeper branchName'); onboardingConfig.branchName = String(branchName).replace( 'greenkeeper', - appSlug + 'renovate' ); } if (is.nonEmptyArray(ignore)) { diff --git a/test/platform/bitbucket-server/index.spec.ts b/test/platform/bitbucket-server/index.spec.ts index 75dfed7b14..bd062a4105 100644 --- a/test/platform/bitbucket-server/index.spec.ts +++ b/test/platform/bitbucket-server/index.spec.ts @@ -693,7 +693,7 @@ describe('platform/bitbucket-server', () => { it('sanitizes HTML comments in the body', () => { const prBody = bitbucket.getPrBody(`--- -- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box +- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box - [ ] <!-- recreate-branch=renovate/docker-renovate-renovate-16.x --><a href="/some/link">Update renovate/renovate to 16.1.2</a> --- diff --git a/test/platform/utils/__snapshots__/pr-body.spec.ts.snap b/test/platform/utils/__snapshots__/pr-body.spec.ts.snap index e96d6b3a90..862190f2dc 100644 --- a/test/platform/utils/__snapshots__/pr-body.spec.ts.snap +++ b/test/platform/utils/__snapshots__/pr-body.spec.ts.snap @@ -35,7 +35,7 @@ exports[`platform/utils/pr-body .smartTruncate truncates to 1000 1`] = ` ##### Features -- **docker:** AWS ECR authentication support ([#​4497](https://togi</details> +- **docker:** AWS ECR authentication support ([#​4497](https://togithu</details> --- @@ -51,7 +51,7 @@ exports[`platform/utils/pr-body .smartTruncate truncates to 1000 1`] = ` --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- diff --git a/test/platform/utils/_fixtures/pr-body.txt b/test/platform/utils/_fixtures/pr-body.txt index 44c2bdc3e0..a31ef54312 100644 --- a/test/platform/utils/_fixtures/pr-body.txt +++ b/test/platform/utils/_fixtures/pr-body.txt @@ -94,7 +94,7 @@ This PR contains the following updates: --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- diff --git a/test/workers/branch/index.spec.js b/test/workers/branch/index.spec.js index 1ae2cfa5b4..aeb6123a3e 100644 --- a/test/workers/branch/index.spec.js +++ b/test/workers/branch/index.spec.js @@ -18,7 +18,6 @@ const automerge = require('../../../lib/workers/branch/automerge'); const prWorker = require('../../../lib/workers/pr'); /** @type any */ const getUpdated = require('../../../lib/workers/branch/get-updated'); -const { appSlug } = require('../../../lib/config/app-strings'); /** @type any */ const { platform } = require('../../../lib/platform'); @@ -425,7 +424,7 @@ describe('workers/branch', () => { platform.getBranchPr.mockResolvedValueOnce({ title: 'rebase!', state: 'open', - body: `- [x] <!-- ${appSlug}-rebase -->`, + body: `- [x] <!-- rebase-check -->`, isModified: true, }); @@ -456,7 +455,7 @@ describe('workers/branch', () => { platform.getBranchPr.mockResolvedValueOnce({ title: 'rebase!', state: 'open', - body: `- [x] <!-- ${appSlug}-rebase -->`, + body: `- [x] <!-- rebase-check -->`, isModified: true, }); @@ -484,7 +483,7 @@ describe('workers/branch', () => { platform.getBranchPr.mockResolvedValueOnce({ title: 'rebase!', state: 'open', - body: `- [x] <!-- ${appSlug}-rebase -->`, + body: `- [x] <!-- rebase-check -->`, isModified: true, }); diff --git a/test/workers/branch/parent.spec.js b/test/workers/branch/parent.spec.js index b5bbfd0238..b87d969d3b 100644 --- a/test/workers/branch/parent.spec.js +++ b/test/workers/branch/parent.spec.js @@ -65,7 +65,7 @@ describe('workers/branch/parent', () => { platform.branchExists.mockReturnValue(true); platform.getBranchPr.mockReturnValue({ title: 'Update foo to v4', - body: 'blah\nblah\n- [x] <!-- renovate-rebase -->foo\n', + body: 'blah\nblah\n- [x] <!-- rebase-check -->foo\n', }); const res = await getParentBranch(config); expect(res.parentBranch).toBeUndefined(); diff --git a/test/workers/pr/__snapshots__/index.spec.ts.snap b/test/workers/pr/__snapshots__/index.spec.ts.snap index b243516b65..24e043961c 100644 --- a/test/workers/pr/__snapshots__/index.spec.ts.snap +++ b/test/workers/pr/__snapshots__/index.spec.ts.snap @@ -63,7 +63,7 @@ Array [ --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box", + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box", Array [], false, Object { @@ -111,7 +111,7 @@ Array [ --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box", + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box", Array [], false, Object { @@ -176,7 +176,7 @@ note 2 --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box", + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box", Array [], false, Object { @@ -224,7 +224,7 @@ Array [ --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box", + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box", Array [], false, Object { @@ -270,7 +270,7 @@ Object { --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box", + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box", "displayNumber": "Existing PR", "isModified": false, "title": "Update dependency dummy to v1.1.0", @@ -312,7 +312,7 @@ Object { --- - - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box", + - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box", "displayNumber": "Existing PR", "isModified": false, "title": "wrong", -- GitLab