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

[release notes] extract "dev docs" comment too #79351

Merged
merged 4 commits into from
Oct 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/developer/contributing/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The Release Notes summarize what the PRs accomplish in language that is meaningf

The text that appears in the Release Notes is pulled directly from your PR title, or a single paragraph of text that you specify in the PR description.

To use a single paragraph of text, enter `Release note:` or a `## Release note` header in the PR description, followed by your text. For example, refer to this https://github.com/elastic/kibana/pull/65796[PR] that uses the `## Release note` header.
To use a single paragraph of text, enter a `Release note:` or `## Release note` header in the PR description ("dev docs" works too), followed by your text. For example, refer to this https://github.com/elastic/kibana/pull/65796[PR] that uses the `## Release note` header.

When you create the Release Notes text, use the following best practices:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ it('extracts expected components from html', () => {
## Release Note:

Checkout this feature
`)
`),
'release note'
)
).toMatchInlineSnapshot(`"Checkout this feature"`);

Expand All @@ -46,10 +47,11 @@ it('extracts expected components from html', () => {

Fixes: #1234

#### Release Note:
#### Dev docs:

We fixed an issue
`)
`),
'dev docs'
)
).toMatchInlineSnapshot(`"We fixed an issue"`);

Expand All @@ -60,8 +62,9 @@ it('extracts expected components from html', () => {

Fixes: #1234

Release note: Checkout feature foo
`)
OTHER TITLE: Checkout feature foo
`),
'other title'
)
).toMatchInlineSnapshot(`"Checkout feature foo"`);

Expand All @@ -73,7 +76,8 @@ it('extracts expected components from html', () => {
My PR description

release note : bar
`)
`),
'release note'
)
).toMatchInlineSnapshot(`"bar"`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

import cheerio from 'cheerio';

export function getNoteFromDescription(descriptionHtml: string) {
export function getNoteFromDescription(descriptionHtml: string, header: string) {
const re = new RegExp(`^(\\s*${header.toLowerCase()}(?:s)?\\s*:?\\s*)`, 'i');
const $ = cheerio.load(descriptionHtml);
for (const el of $('p,h1,h2,h3,h4,h5').toArray()) {
const text = $(el).text();
const match = text.match(/^(\s*release note(?:s)?\s*:?\s*)/i);
const match = text.match(re);

if (!match) {
continue;
Expand Down
4 changes: 3 additions & 1 deletion packages/kbn-release-notes/src/lib/pr_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ export class PrApi {
versions: labels
.map((l) => Version.fromLabel(l))
.filter((v): v is Version => v instanceof Version),
note: getNoteFromDescription(node.bodyHTML),
note:
getNoteFromDescription(node.bodyHTML, 'release note') ||
getNoteFromDescription(node.bodyHTML, 'dev docs'),
};
}

Expand Down