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

fix: remove greenkeeper migration #6685

Merged
merged 1 commit into from Jul 6, 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,21 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`workers/repository/onboarding/branch checkOnboardingBranch creates onboarding branch with greenkeeper migration 1`] = `
"{
\\"$schema\\": \\"https://docs.renovatebot.com/renovate-schema.json\\",
\\"statusCheckVerify\\": true,
\\"labels\\": [
\\"renovate\\"
],
\\"branchName\\": \\"renovate--\\",
\\"ignoreDeps\\": [
\\"foo\\",
\\"bar\\"
]
}
"
`;

exports[`workers/repository/onboarding/branch checkOnboardingBranch has default onboarding config 1`] = `
"{
\\"$schema\\": \\"https://docs.renovatebot.com/renovate-schema.json\\"
Expand Down
36 changes: 1 addition & 35 deletions lib/workers/repository/onboarding/branch/config.ts
@@ -1,43 +1,9 @@
import is from '@sindresorhus/is';
import { RenovateConfig } from '../../../../config';
import { logger } from '../../../../logger';
import { clone } from '../../../../util/clone';
import { readLocalFile } from '../../../../util/fs';

export async function getOnboardingConfig(
config: RenovateConfig
): Promise<string> {
export function getOnboardingConfig(config: RenovateConfig): string {
const onboardingConfig = clone(config.onboardingConfig);
try {
logger.debug('Checking for greenkeeper config');

const greenkeeperConfig = JSON.parse(
await readLocalFile('package.json', 'utf8')
).greenkeeper;
if (greenkeeperConfig) {
onboardingConfig.statusCheckVerify = true;
}
const { label, branchName, ignore } = greenkeeperConfig;
if (label) {
logger.debug({ label }, 'Migrating Greenkeeper label');
onboardingConfig.labels = [
String(label).replace('greenkeeper', 'renovate'),
];
}
if (branchName) {
logger.debug({ branch: branchName }, 'Migrating Greenkeeper branchName');
onboardingConfig.branchName = String(branchName).replace(
'greenkeeper',
'renovate'
);
}
if (is.nonEmptyArray(ignore)) {
logger.debug({ ignore }, 'Migrating Greenkeeper ignore');
onboardingConfig.ignoreDeps = ignore.map(String);
}
} catch (err) {
logger.debug('No greenkeeper config migration');
}
logger.debug({ config: onboardingConfig }, 'onboarding config');
return JSON.stringify(onboardingConfig, null, 2) + '\n';
}
2 changes: 1 addition & 1 deletion lib/workers/repository/onboarding/branch/create.ts
Expand Up @@ -10,7 +10,7 @@ export async function createOnboardingBranch(
config: Partial<RenovateConfig>
): Promise<string | null> {
logger.debug('createOnboardingBranch()');
const contents = await getOnboardingConfig(config);
const contents = getOnboardingConfig(config);
logger.debug('Creating onboarding branch');
let commitMessage;
// istanbul ignore if
Expand Down
18 changes: 0 additions & 18 deletions lib/workers/repository/onboarding/branch/index.spec.ts
Expand Up @@ -90,24 +90,6 @@ describe('workers/repository/onboarding/branch', () => {
]);
await expect(checkOnboardingBranch(config)).rejects.toThrow();
});
it('creates onboarding branch with greenkeeper migration', async () => {
git.getFileList.mockResolvedValue(['package.json']);
const pJsonContent = JSON.stringify({
name: 'some-name',
version: '0.0.1',
greenkeeper: {
label: 'greenkeeper',
branchName: 'greenkeeper--',
ignore: ['foo', 'bar'],
},
});
fs.readLocalFile.mockResolvedValue(pJsonContent);
platform.commitFiles.mockResolvedValueOnce('abc123');
await checkOnboardingBranch(config);
expect(
platform.commitFiles.mock.calls[0][0].files[0].contents
).toMatchSnapshot();
});
it('updates onboarding branch', async () => {
git.getFileList.mockResolvedValue(['package.json']);
platform.findPr.mockResolvedValue(null);
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/onboarding/branch/index.ts
Expand Up @@ -40,6 +40,7 @@ export async function checkOnboardingBranch(
}
logger.debug('Need to create onboarding PR');
const commit = await createOnboardingBranch(config);
// istanbul ignore if
Copy link
Member

Choose a reason for hiding this comment

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

We should add a test later

if (commit) {
logger.info(
{ branch: config.onboardingBranch, commit, onboarding: true },
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/onboarding/branch/rebase.ts
Expand Up @@ -36,7 +36,7 @@ export async function rebaseOnboardingBranch(
defaultConfigFile,
config.onboardingBranch
);
const contents = await getOnboardingConfig(config);
const contents = getOnboardingConfig(config);
if (contents === existingContents && !pr.isStale) {
logger.debug('Onboarding branch is up to date');
return null;
Expand Down