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

ensure deep merge of config #1012

Merged
merged 3 commits into from Jan 15, 2022
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
4 changes: 3 additions & 1 deletion dist/index.js
Expand Up @@ -133767,6 +133767,7 @@ const Joi = __nccwpck_require__(44010)
const { SORT_BY, SORT_DIRECTIONS } = __nccwpck_require__(11940)
const { DEFAULT_CONFIG } = __nccwpck_require__(85869)
const { validateReplacers, validateAutolabeler } = __nccwpck_require__(47282)
const merge = __nccwpck_require__(56323)

const schema = (context) => {
const defaultBranch = _.get(
Expand Down Expand Up @@ -133906,7 +133907,8 @@ const schema = (context) => {
}

const validateSchema = (context, repoConfig) => {
const { error, value: config } = schema(context).validate(repoConfig, {
const mergedRepoConfig = merge.all([DEFAULT_CONFIG, repoConfig])
const { error, value: config } = schema(context).validate(mergedRepoConfig, {
abortEarly: false,
allowUnknown: true,
})
Expand Down
4 changes: 3 additions & 1 deletion lib/schema.js
Expand Up @@ -3,6 +3,7 @@ const Joi = require('@hapi/joi')
const { SORT_BY, SORT_DIRECTIONS } = require('./sort-pull-requests')
const { DEFAULT_CONFIG } = require('./default-config')
const { validateReplacers, validateAutolabeler } = require('./template')
const merge = require('deepmerge')

const schema = (context) => {
const defaultBranch = _.get(
Expand Down Expand Up @@ -142,7 +143,8 @@ const schema = (context) => {
}

const validateSchema = (context, repoConfig) => {
const { error, value: config } = schema(context).validate(repoConfig, {
const mergedRepoConfig = merge.all([DEFAULT_CONFIG, repoConfig])
const { error, value: config } = schema(context).validate(mergedRepoConfig, {
abortEarly: false,
allowUnknown: true,
})
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -27,6 +27,7 @@
"@probot/adapter-github-actions": "3.1.0",
"cli-table3": "0.6.1",
"compare-versions": "4.1.3",
"deepmerge": "4.2.2",
"escape-string-regexp": "4.0.0",
"ignore": "5.2.0",
"lodash": "4.17.21",
Expand Down
@@ -0,0 +1,22 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
branches:
- master
categories:
- title: '🚀 Features'
label: 'feature'
- title: '🐛 Bug fixes'
label: 'bug'
- title: '📄 Documentation'
label: 'documentation'
- title: '🧰 Maintenance'
label: 'maintenance'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: dummy
version-resolver:
major:
labels:
- 'major'
default: minor
exclude-labels:
- skip-changelog
42 changes: 42 additions & 0 deletions test/index.test.js
Expand Up @@ -2567,6 +2567,48 @@ describe('release-drafter', () => {

expect.assertions(1)
})

it('major beats others partial config', async () => {
getConfigMock('config-with-custom-version-resolver-partial.yml')

nock('https://api.github.com')
.get(
'/repos/toolmantim/release-drafter-test-project/releases?per_page=100'
)
.reply(200, [releasePayload])

nock('https://api.github.com')
.post('/graphql', (body) =>
body.query.includes('query findCommitsWithAssociatedPullRequests')
)
.reply(200, graphqlCommitsForking)

nock('https://api.github.com')
.post(
'/repos/toolmantim/release-drafter-test-project/releases',
(body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"body": "dummy",
"draft": true,
"name": "v3.0.0",
"prerelease": false,
"tag_name": "v3.0.0",
"target_commitish": "",
}
`)
return true
}
)
.reply(200, releasePayload)

await probot.receive({
name: 'push',
payload: pushPayload,
})

expect.assertions(1)
})
})

describe('with commitish', () => {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -2195,7 +2195,7 @@ deep-is@^0.1.3, deep-is@~0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=

deepmerge@^4.2.2:
deepmerge@4.2.2, deepmerge@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955"
integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==
Expand Down