Skip to content

Commit

Permalink
feat: add ignored tag option (#102)
Browse files Browse the repository at this point in the history
* feat: add ignore tag

* docs: update docs

* chore: update pull request template
  • Loading branch information
adrianiy committed Nov 4, 2021
1 parent 88cd014 commit dbf2ca6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
### Changes
<!-- Specify changes you've done in your PR, be as specific as you can! :) -->

<!--release-notes-ignore-->
### Issues
<!-- Link related issue after close using # notation. `Close #123`-->

Close
<!--release-notes-ignore-->


1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ A **complete markdown** file will be created using your pull request description
- [filter](/src/configuration#filter)
- [snapshot](/src/configuration#snapshot)
- [labels](/src/configuration#labels)
- [ignoreTag](/src/configuration#ignore-tag)
- [title](/src/configuration#title)
- [decoration](/src/configuration#decoration)
- [preview](/src/configuration#preview)
Expand Down
23 changes: 23 additions & 0 deletions src/configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [filter](#filter)
- [snapshot](#snapshot)
- [labels](#labels)
- [ignoreTag](#ignore-tag)
- [title](#title)
- [decoration](#decoration)
- [preview](#preview)
Expand Down Expand Up @@ -39,6 +40,7 @@ We support `.yml` and `.json` formats with these options:
| [filter](#filter) | `is:closed` | Filter applied on pull request query |
| [snapshot](#snapshot) | `false` | Generates snapshot release notes using Pull Request since latest release |
| [labels](#labels) | `[ 'release-note' ]` | Only PRs with these labels will be used in generation process |
| [ignoreTag](#ignore-tag) | `<!--release-notes-ignore-->` | Text inside this comment tag will be ignored in RELEASE NOTES |
| [title](#title) | `RELEASE NOTES` | Title used in output markdown |
| [decoration](#decoration) | [Decoration object](#decoration-object) | Icon decoration for each issue type |
| [preview](#preview) | [Preview object](#preview-object) | Customize preview comment |
Expand Down Expand Up @@ -146,6 +148,27 @@ labels:
end: in-release-note
```

### IGNORE TAG
##### Default value `<!--release-notes-ignore-->`

You can surround with this comment tag any text you want to ignore in release notes

```markdown
## Feat

Text in release notes

<!--release-notes--ignore-->
Text ignore in release notes
<!--release-notes-ignore-->
```

You can customize this tag in your `.releasenotesrc.yml`

```yml
ignoreTag: '<!--custom-ignore-tag-->'
```

---

### TITLE
Expand Down
3 changes: 3 additions & 0 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface Configuration {
filter?: string;
// Start date in pull request filter query
since?: string;
// Ignore text inside this tag
ignoreTag?: string;
// Generates snapshot release notes (from latest release)
snapshot?: boolean;
// Split Release-Notes on file per Relase
Expand Down Expand Up @@ -96,6 +98,7 @@ const defaultConfiguration: Configuration = {
message: 'chore: update RELEASE-NOTES',
branch: 'main',
filter: 'is:closed',
ignoreTag: '<!--release-notes-ignore-->',
assets: [],
webhooks: {},
title: 'RELEASE NOTES',
Expand Down
1 change: 1 addition & 0 deletions src/generator/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export abstract class Generator {

if (this._configuration.snapshot) {
this.publishPreview(markdown);
this._storeMarkdown(markdown);
} else {
this._storeMarkdown(markdown);
}
Expand Down
5 changes: 4 additions & 1 deletion src/generator/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ export class GithubGenerator extends Generator {

private _composeText = (pr: PullRequest) => {
const decoration = this._configuration.decoration!;
const ignoredText = this._configuration.ignoreTag;
const ignoredRegexp = new RegExp(`${ignoredText}(\\r\\n*.*)*${ignoredText}`, 'g');
const decorationMatch = pr.labels.find((label: string) => decoration[label]) || '';
const date = new Date(pr.createdAt).toISOString().split('T')[0];
const body = pr.body?.replace(ignoredRegexp, '').replace(/\n\s*\n\s*\n/g, '\n') || '';

return `${decoration[decorationMatch] || ''}${pr.title} \n###### ${date}\n\n${pr.body}\n`;
return `${decoration[decorationMatch] || ''}${pr.title} \n###### ${date}\n\n${body}\n`;
};
}

0 comments on commit dbf2ca6

Please sign in to comment.