mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
fix: Revert "fix(config): Migrate semantic commit option to enum type (#7170)"
This reverts commit d2a5b7167b
.
This commit is contained in:
parent
d2a5b7167b
commit
d1d7901a0a
15 changed files with 25 additions and 57 deletions
|
@ -52,7 +52,7 @@ export interface RenovateSharedConfig {
|
||||||
repositoryCache?: RepositoryCacheConfig;
|
repositoryCache?: RepositoryCacheConfig;
|
||||||
requiredStatusChecks?: string[];
|
requiredStatusChecks?: string[];
|
||||||
schedule?: string[];
|
schedule?: string[];
|
||||||
semanticCommits?: 'auto' | 'enabled' | 'disabled';
|
semanticCommits?: boolean;
|
||||||
semanticCommitScope?: string;
|
semanticCommitScope?: string;
|
||||||
semanticCommitType?: string;
|
semanticCommitType?: string;
|
||||||
suppressNotifications?: string[];
|
suppressNotifications?: string[];
|
||||||
|
|
|
@ -1084,9 +1084,8 @@ const options: RenovateOptions[] = [
|
||||||
{
|
{
|
||||||
name: 'semanticCommits',
|
name: 'semanticCommits',
|
||||||
description: 'Enable semantic commit prefixes for commits and PR titles',
|
description: 'Enable semantic commit prefixes for commits and PR titles',
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
allowedValues: ['auto', 'enabled', 'disabled'],
|
default: null,
|
||||||
default: 'auto',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'semanticCommitType',
|
name: 'semanticCommitType',
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { PLATFORM_TYPE_GITHUB } from '../constants/platforms';
|
import { PLATFORM_TYPE_GITHUB } from '../constants/platforms';
|
||||||
import { getConfig } from './defaults';
|
import { getConfig } from './defaults';
|
||||||
import * as configMigration from './migration';
|
import * as configMigration from './migration';
|
||||||
import { MigratedConfig } from './migration';
|
|
||||||
import { RenovateSharedConfig, RenovateConfig as _RenovateConfig } from '.';
|
import { RenovateSharedConfig, RenovateConfig as _RenovateConfig } from '.';
|
||||||
|
|
||||||
const defaultConfig = getConfig();
|
const defaultConfig = getConfig();
|
||||||
|
@ -130,7 +129,7 @@ describe('config/migration', () => {
|
||||||
],
|
],
|
||||||
raiseDeprecationWarnings: false,
|
raiseDeprecationWarnings: false,
|
||||||
};
|
};
|
||||||
const parentConfig = { ...defaultConfig, semanticCommits: 'disabled' };
|
const parentConfig = { ...defaultConfig, semanticCommits: false };
|
||||||
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
|
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
|
||||||
config,
|
config,
|
||||||
parentConfig
|
parentConfig
|
||||||
|
@ -270,6 +269,7 @@ describe('config/migration', () => {
|
||||||
it('does not migrate config', () => {
|
it('does not migrate config', () => {
|
||||||
const config: RenovateConfig = {
|
const config: RenovateConfig = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
semanticCommits: true,
|
||||||
separateMinorPatch: true,
|
separateMinorPatch: true,
|
||||||
};
|
};
|
||||||
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
|
const { isMigrated, migratedConfig } = configMigration.migrateConfig(
|
||||||
|
@ -403,24 +403,5 @@ describe('config/migration', () => {
|
||||||
expect(migratedConfig).toMatchSnapshot();
|
expect(migratedConfig).toMatchSnapshot();
|
||||||
expect(isMigrated).toBe(true);
|
expect(isMigrated).toBe(true);
|
||||||
});
|
});
|
||||||
it('it migrates semanticCommits', () => {
|
|
||||||
let config: RenovateConfig;
|
|
||||||
let res: MigratedConfig;
|
|
||||||
|
|
||||||
config = { semanticCommits: true as never };
|
|
||||||
res = configMigration.migrateConfig(config);
|
|
||||||
expect(res.isMigrated).toBe(true);
|
|
||||||
expect(res.migratedConfig).toMatchObject({ semanticCommits: 'enabled' });
|
|
||||||
|
|
||||||
config = { semanticCommits: false as never };
|
|
||||||
res = configMigration.migrateConfig(config);
|
|
||||||
expect(res.isMigrated).toBe(true);
|
|
||||||
expect(res.migratedConfig).toMatchObject({ semanticCommits: 'disabled' });
|
|
||||||
|
|
||||||
config = { semanticCommits: null as never };
|
|
||||||
res = configMigration.migrateConfig(config);
|
|
||||||
expect(res.isMigrated).toBe(true);
|
|
||||||
expect(res.migratedConfig).toMatchObject({ semanticCommits: 'auto' });
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -101,15 +101,6 @@ export function migrateConfig(
|
||||||
migratedConfig.postUpdateOptions.push('gomodTidy');
|
migratedConfig.postUpdateOptions.push('gomodTidy');
|
||||||
}
|
}
|
||||||
delete migratedConfig.gomodTidy;
|
delete migratedConfig.gomodTidy;
|
||||||
} else if (key === 'semanticCommits') {
|
|
||||||
isMigrated = true;
|
|
||||||
if (val === true) {
|
|
||||||
migratedConfig.semanticCommits = 'enabled';
|
|
||||||
} else if (val === false) {
|
|
||||||
migratedConfig.semanticCommits = 'disabled';
|
|
||||||
} else {
|
|
||||||
migratedConfig.semanticCommits = 'auto';
|
|
||||||
}
|
|
||||||
} else if (parentKey === 'hostRules' && key === 'platform') {
|
} else if (parentKey === 'hostRules' && key === 'platform') {
|
||||||
isMigrated = true;
|
isMigrated = true;
|
||||||
migratedConfig.hostType = val;
|
migratedConfig.hostType = val;
|
||||||
|
|
|
@ -393,7 +393,7 @@ Object {
|
||||||
"schedule": Array [
|
"schedule": Array [
|
||||||
"before 8am",
|
"before 8am",
|
||||||
],
|
],
|
||||||
"semanticCommits": "enabled",
|
"semanticCommits": true,
|
||||||
"separateMajorMinor": true,
|
"separateMajorMinor": true,
|
||||||
"separateMinorPatch": false,
|
"separateMinorPatch": false,
|
||||||
"timezone": "Asia/Taipei",
|
"timezone": "Asia/Taipei",
|
||||||
|
|
|
@ -510,11 +510,11 @@ export const presets: Record<string, Preset> = {
|
||||||
},
|
},
|
||||||
semanticCommits: {
|
semanticCommits: {
|
||||||
description: 'Use semantic prefixes for commit messages and PR titles',
|
description: 'Use semantic prefixes for commit messages and PR titles',
|
||||||
semanticCommits: 'enabled',
|
semanticCommits: true,
|
||||||
},
|
},
|
||||||
semanticCommitsDisabled: {
|
semanticCommitsDisabled: {
|
||||||
description: 'Disable semantic prefixes for commit messages and PR titles',
|
description: 'Disable semantic prefixes for commit messages and PR titles',
|
||||||
semanticCommits: 'disabled',
|
semanticCommits: false,
|
||||||
},
|
},
|
||||||
disableLockFiles: {
|
disableLockFiles: {
|
||||||
description: 'Disable lock file updates',
|
description: 'Disable lock file updates',
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe('workers/branch/automerge', () => {
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
branchName: 'renovate/some-branch',
|
branchName: 'renovate/some-branch',
|
||||||
commitMessage: 'some commit message',
|
commitMessage: 'some commit message',
|
||||||
semanticCommits: 'disabled',
|
semanticCommits: false,
|
||||||
semanticCommitType: 'a',
|
semanticCommitType: 'a',
|
||||||
semanticCommitScope: 'b',
|
semanticCommitScope: 'b',
|
||||||
updatedPackageFiles: [],
|
updatedPackageFiles: [],
|
||||||
|
|
|
@ -222,8 +222,7 @@ export async function getRepoConfig(
|
||||||
config.baseBranch = config.defaultBranch;
|
config.baseBranch = config.defaultBranch;
|
||||||
config = await checkOnboardingBranch(config);
|
config = await checkOnboardingBranch(config);
|
||||||
config = await mergeRenovateConfig(config);
|
config = await mergeRenovateConfig(config);
|
||||||
if (config.semanticCommits === 'auto') {
|
config.semanticCommits =
|
||||||
config.semanticCommits = await detectSemanticCommits();
|
config.semanticCommits ?? (await detectSemanticCommits());
|
||||||
}
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@ describe('workers/repository/init/semantic', () => {
|
||||||
config.semanticCommits = null;
|
config.semanticCommits = null;
|
||||||
git.getCommitMessages.mockResolvedValue(['foo', 'bar']);
|
git.getCommitMessages.mockResolvedValue(['foo', 'bar']);
|
||||||
const res = await detectSemanticCommits();
|
const res = await detectSemanticCommits();
|
||||||
expect(res).toBe('disabled');
|
expect(res).toBe(false);
|
||||||
});
|
});
|
||||||
it('detects true if known', async () => {
|
it('detects true if known', async () => {
|
||||||
config.semanticCommits = null;
|
config.semanticCommits = null;
|
||||||
git.getCommitMessages.mockResolvedValue(['fix: foo', 'refactor: bar']);
|
git.getCommitMessages.mockResolvedValue(['fix: foo', 'refactor: bar']);
|
||||||
const res = await detectSemanticCommits();
|
const res = await detectSemanticCommits();
|
||||||
expect(res).toBe('enabled');
|
expect(res).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,9 +2,7 @@ import conventionalCommitsDetector from 'conventional-commits-detector';
|
||||||
import { logger } from '../../../logger';
|
import { logger } from '../../../logger';
|
||||||
import { getCommitMessages } from '../../../util/git';
|
import { getCommitMessages } from '../../../util/git';
|
||||||
|
|
||||||
type DetectedSemanticCommit = 'enabled' | 'disabled';
|
export async function detectSemanticCommits(): Promise<boolean> {
|
||||||
|
|
||||||
export async function detectSemanticCommits(): Promise<DetectedSemanticCommit> {
|
|
||||||
logger.debug('detectSemanticCommits()');
|
logger.debug('detectSemanticCommits()');
|
||||||
const commitMessages = await getCommitMessages();
|
const commitMessages = await getCommitMessages();
|
||||||
logger.trace(`commitMessages=${JSON.stringify(commitMessages)}`);
|
logger.trace(`commitMessages=${JSON.stringify(commitMessages)}`);
|
||||||
|
@ -12,8 +10,8 @@ export async function detectSemanticCommits(): Promise<DetectedSemanticCommit> {
|
||||||
logger.debug('Semantic commits detection: ' + type);
|
logger.debug('Semantic commits detection: ' + type);
|
||||||
if (type === 'angular') {
|
if (type === 'angular') {
|
||||||
logger.debug('angular semantic commits detected');
|
logger.debug('angular semantic commits detected');
|
||||||
return 'enabled';
|
return true;
|
||||||
}
|
}
|
||||||
logger.debug('No semantic commits detected');
|
logger.debug('No semantic commits detected');
|
||||||
return 'disabled';
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ describe('workers/repository/onboarding/branch', () => {
|
||||||
describe('applies semanticCommit prefix', () => {
|
describe('applies semanticCommit prefix', () => {
|
||||||
it('to the default commit message', async () => {
|
it('to the default commit message', async () => {
|
||||||
const prefix = 'chore(deps)';
|
const prefix = 'chore(deps)';
|
||||||
config.semanticCommits = 'enabled';
|
config.semanticCommits = true;
|
||||||
await createOnboardingBranch(config);
|
await createOnboardingBranch(config);
|
||||||
expect(commitFiles).toHaveBeenCalledWith(
|
expect(commitFiles).toHaveBeenCalledWith(
|
||||||
buildExpectedCommitFilesArgument(
|
buildExpectedCommitFilesArgument(
|
||||||
|
@ -84,7 +84,7 @@ describe('workers/repository/onboarding/branch', () => {
|
||||||
const prefix = 'chore(deps)';
|
const prefix = 'chore(deps)';
|
||||||
const message =
|
const message =
|
||||||
'I say, we can update when we want to, a commit they will never mind';
|
'I say, we can update when we want to, a commit they will never mind';
|
||||||
config.semanticCommits = 'enabled';
|
config.semanticCommits = true;
|
||||||
config.onboardingCommitMessage = message;
|
config.onboardingCommitMessage = message;
|
||||||
await createOnboardingBranch(config);
|
await createOnboardingBranch(config);
|
||||||
expect(commitFiles).toHaveBeenCalledWith(
|
expect(commitFiles).toHaveBeenCalledWith(
|
||||||
|
|
|
@ -17,7 +17,7 @@ export function createOnboardingBranch(
|
||||||
let commitMessagePrefix = '';
|
let commitMessagePrefix = '';
|
||||||
if (config.commitMessagePrefix) {
|
if (config.commitMessagePrefix) {
|
||||||
commitMessagePrefix = config.commitMessagePrefix;
|
commitMessagePrefix = config.commitMessagePrefix;
|
||||||
} else if (config.semanticCommits === 'enabled') {
|
} else if (config.semanticCommits) {
|
||||||
commitMessagePrefix = config.semanticCommitType;
|
commitMessagePrefix = config.semanticCommitType;
|
||||||
if (config.semanticCommitScope) {
|
if (config.semanticCommitScope) {
|
||||||
commitMessagePrefix += `(${config.semanticCommitScope})`;
|
commitMessagePrefix += `(${config.semanticCommitScope})`;
|
||||||
|
|
|
@ -14,7 +14,7 @@ const defaultConfigFile = configFileNames[0];
|
||||||
function getCommitMessage(config: RenovateConfig): string {
|
function getCommitMessage(config: RenovateConfig): string {
|
||||||
let commitMessage: string;
|
let commitMessage: string;
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (config.semanticCommits === 'enabled') {
|
if (config.semanticCommits) {
|
||||||
commitMessage = config.semanticCommitType;
|
commitMessage = config.semanticCommitType;
|
||||||
if (config.semanticCommitScope) {
|
if (config.semanticCommitScope) {
|
||||||
commitMessage += `(${config.semanticCommitScope})`;
|
commitMessage += `(${config.semanticCommitScope})`;
|
||||||
|
|
|
@ -219,7 +219,7 @@ describe('workers/repository/updates/generate', () => {
|
||||||
partial<BranchUpgradeConfig>({
|
partial<BranchUpgradeConfig>({
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
depName: 'some-dep',
|
depName: 'some-dep',
|
||||||
semanticCommits: 'enabled',
|
semanticCommits: true,
|
||||||
semanticCommitType: 'chore',
|
semanticCommitType: 'chore',
|
||||||
semanticCommitScope: 'package',
|
semanticCommitScope: 'package',
|
||||||
newValue: '1.2.0',
|
newValue: '1.2.0',
|
||||||
|
@ -243,7 +243,7 @@ describe('workers/repository/updates/generate', () => {
|
||||||
depName: 'some-dep',
|
depName: 'some-dep',
|
||||||
packageFile: 'package.json',
|
packageFile: 'package.json',
|
||||||
baseDir: '',
|
baseDir: '',
|
||||||
semanticCommits: 'enabled',
|
semanticCommits: true,
|
||||||
semanticCommitType: 'chore',
|
semanticCommitType: 'chore',
|
||||||
semanticCommitScope: '{{baseDir}}',
|
semanticCommitScope: '{{baseDir}}',
|
||||||
newValue: '1.2.0',
|
newValue: '1.2.0',
|
||||||
|
@ -268,7 +268,7 @@ describe('workers/repository/updates/generate', () => {
|
||||||
depName: 'some-dep',
|
depName: 'some-dep',
|
||||||
packageFile: 'foo/bar/package.json',
|
packageFile: 'foo/bar/package.json',
|
||||||
parentDir: 'bar',
|
parentDir: 'bar',
|
||||||
semanticCommits: 'enabled',
|
semanticCommits: true,
|
||||||
semanticCommitType: 'chore',
|
semanticCommitType: 'chore',
|
||||||
semanticCommitScope: '{{parentDir}}',
|
semanticCommitScope: '{{parentDir}}',
|
||||||
newValue: '1.2.0',
|
newValue: '1.2.0',
|
||||||
|
@ -292,7 +292,7 @@ describe('workers/repository/updates/generate', () => {
|
||||||
depName: 'some-dep',
|
depName: 'some-dep',
|
||||||
packageFile: 'foo/bar/package.json',
|
packageFile: 'foo/bar/package.json',
|
||||||
baseDir: 'foo/bar',
|
baseDir: 'foo/bar',
|
||||||
semanticCommits: 'enabled',
|
semanticCommits: true,
|
||||||
semanticCommitType: 'chore',
|
semanticCommitType: 'chore',
|
||||||
semanticCommitScope: '{{baseDir}}',
|
semanticCommitScope: '{{baseDir}}',
|
||||||
newValue: '1.2.0',
|
newValue: '1.2.0',
|
||||||
|
|
|
@ -173,7 +173,7 @@ export function generateBranchConfig(
|
||||||
upgrade.isRange = false;
|
upgrade.isRange = false;
|
||||||
}
|
}
|
||||||
// Use templates to generate strings
|
// Use templates to generate strings
|
||||||
if (upgrade.semanticCommits === 'enabled' && !upgrade.commitMessagePrefix) {
|
if (upgrade.semanticCommits && !upgrade.commitMessagePrefix) {
|
||||||
logger.trace('Upgrade has semantic commits enabled');
|
logger.trace('Upgrade has semantic commits enabled');
|
||||||
let semanticPrefix = upgrade.semanticCommitType;
|
let semanticPrefix = upgrade.semanticCommitType;
|
||||||
if (upgrade.semanticCommitScope) {
|
if (upgrade.semanticCommitScope) {
|
||||||
|
|
Loading…
Reference in a new issue