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
Allow providing a list of characters to escape in PR titles #611
Conversation
This comment has been minimized.
This comment has been minimized.
You have not updated the schema. To do so run |
README.md
Outdated
| Variable | Description | | ||
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `$NUMBER` | The number of the pull request, e.g. `42`. | | ||
| `$TITLE` | The title of the pull request, e.g. `Add alien technology`. Any characters matching `change-title-escapes` will be prepended with a backslash so that they will appear verbatim instead of being interpreted as markdown format characters. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about escaping @
There are two options according to github/markup#1168
One using zero-width space
or html comment <!-- -->
. I think the html comment is better as it is easier to "recreate" not everybody knows how to type a zero-width space.
@jetersen
@jetersen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the zero-width space better as it doesn't clutter reading as much. We are auto-generating these lines anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if user accidentally deletes the line and does not know how to type a zero-width space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jetersen @ jetersen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops it's a nbsp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jetersen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe using comments is the way to go then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also do this:
@​jetersen
@jetersen
@ jetersen
@ jetersen
is not a good option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<!---->
@jetersen
⁠
@jetersen

@jetersen
Comments seem to be the most obvious and short option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same trick can be used for #s.
I have no idea how to create a test with special PR titles... |
I think you can simply write tests that test the function directly. Instead of relying on indirect test workflow. |
@jetersen PR is ready |
test/releases.test.js
Outdated
const changelog = generateChangeLog(pullRequests, baseConfig) | ||
expect(changelog).toEqual('* A1 (#1) @ghost\n* B2 (#2) @ghost\n* Adds missing <example> (#3) @jetersen\n* `#code_block` (#4) @jetersen\n* Fixes #4 (#5) @Happypig375\n* 2*2 should equal to 4*1 (#6) @jetersen\n* Rename __confgs\\confg.yml to __configs\\config.yml (#7) @ghost\n* Adds @nullable annotations to the 1*1+2*4 test in `tests.java` (#0) @Happypig375') | ||
}) | ||
it('escapes titles with \\s correctly', () => { | ||
const config = { | ||
...baseConfig, | ||
'change-title-escapes': '\\' | ||
} | ||
const changelog = generateChangeLog(pullRequests, config) | ||
expect(changelog).toEqual('* A1 (#1) @ghost\n* B2 (#2) @ghost\n* Adds missing <example> (#3) @jetersen\n* `#code_block` (#4) @jetersen\n* Fixes #4 (#5) @Happypig375\n* 2*2 should equal to 4*1 (#6) @jetersen\n* Rename __confgs\\\\confg.yml to __configs\\\\config.yml (#7) @ghost\n* Adds @nullable annotations to the 1*1+2*4 test in `tests.java` (#0) @Happypig375') | ||
}) | ||
it('escapes titles with \\<*_& correctly', () => { | ||
const config = { | ||
...baseConfig, | ||
'change-title-escapes': '\\<*_&' | ||
} | ||
const changelog = generateChangeLog(pullRequests, config) | ||
expect(changelog).toEqual('* A1 (#1) @ghost\n* B2 (#2) @ghost\n* Adds missing \\<example> (#3) @jetersen\n* `#code_block` (#4) @jetersen\n* Fixes #4 (#5) @Happypig375\n* 2\\*2 should equal to 4\\*1 (#6) @jetersen\n* Rename \\_\\_confgs\\\\confg.yml to \\_\\_configs\\\\config.yml (#7) @ghost\n* Adds @nullable annotations to the 1\\*1+2\\*4 test in `tests.java` (#0) @Happypig375') | ||
}) | ||
it('escapes titles with @s correctly', () => { | ||
const config = { | ||
...baseConfig, | ||
'change-title-escapes': '@' | ||
} | ||
const changelog = generateChangeLog(pullRequests, config) | ||
expect(changelog).toEqual('* A1 (#1) @ghost\n* B2 (#2) @ghost\n* Adds missing <example> (#3) @jetersen\n* `#code_block` (#4) @jetersen\n* Fixes #4 (#5) @Happypig375\n* 2*2 should equal to 4*1 (#6) @jetersen\n* Rename __confgs\\confg.yml to __configs\\config.yml (#7) @ghost\n* Adds @<!---->nullable annotations to the 1*1+2*4 test in `tests.java` (#0) @Happypig375') | ||
}) | ||
it('escapes titles with @s and #s correctly', () => { | ||
const config = { | ||
...baseConfig, | ||
'change-title-escapes': '@#' | ||
} | ||
const changelog = generateChangeLog(pullRequests, config) | ||
expect(changelog).toEqual('* A1 (#1) @ghost\n* B2 (#2) @ghost\n* Adds missing <example> (#3) @jetersen\n* `#code_block` (#4) @jetersen\n* Fixes #<!---->4 (#5) @Happypig375\n* 2*2 should equal to 4*1 (#6) @jetersen\n* Rename __confgs\\confg.yml to __configs\\config.yml (#7) @ghost\n* Adds @<!---->nullable annotations to the 1*1+2*4 test in `tests.java` (#0) @Happypig375') | ||
}) | ||
it('escapes titles with \\<@*_&`# correctly', () => { | ||
const config = { | ||
...baseConfig, | ||
'change-title-escapes': '\\<@*_&`#' | ||
} | ||
const changelog = generateChangeLog(pullRequests, config) | ||
expect(changelog).toEqual('* A1 (#1) @ghost\n* B2 (#2) @ghost\n* Adds missing \\<example> (#3) @jetersen\n* \\`#<!---->code\\_block\\` (#4) @jetersen\n* Fixes #<!---->4 (#5) @Happypig375\n* 2\\*2 should equal to 4\\*1 (#6) @jetersen\n* Rename \\_\\_confgs\\\\confg.yml to \\_\\_configs\\\\config.yml (#7) @ghost\n* Adds @<!---->nullable annotations to the 1\\*1+2\\*4 test in \\`tests.java\\` (#0) @Happypig375') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace toEqual
with toMatchInlineSnapshot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does toMatchInlineSnapshot
allow indentation? There is
release-drafter/test/index.test.js
Lines 187 to 202 in 842a9a8
expect(body).toMatchInlineSnapshot(` | |
Object { | |
"body": "# What's Changed | |
* Add documentation (#5) @TimonVS | |
* Update dependencies (#4) @TimonVS | |
* Bug fixes (#3) @TimonVS | |
* Add big feature (#2) @TimonVS | |
* 👽 Add alien technology (#1) @TimonVS | |
", | |
"draft": true, | |
"name": "", | |
"prerelease": false, | |
"tag_name": "", | |
} | |
`) |
but this PR's tests seem to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is inside a object :)
When you use toMatchInlineSnapshot
on a string, it cannot tolerate it 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use toMatchSnapshot
which will create a file where indentation shouldn't be an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will wrap it in an object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Snapshot - 13
+ Received + 10
-
- Object {
- "log": "
- * A1 (#1) @ghost
- * B2 (#2) @ghost
- * Adds missing \<example> (#3) @jetersen
- * \`\#code\_block\` (#4) @jetersen
- * Fixes #<!--->4 (#5) @Happypig375
- * 2\*2 should equal to 4\*1 (#6) @jetersen
- * Rename \_\_confgs\\confg.yml to \_\_configs\\config.yml (#7) @ghost
- * Adds @<!--->nullable annotations to the 1\*1+2\*4 test in `tests.java` (#0) @Happypig375
- ",
- }
+ Object {
+ "log": "* A1 (#1) @ghost
+ * B2 (#2) @ghost
+ * Adds missing \\<example> (#3) @jetersen
+ * \\`#<!---->code\\_block\\` (#4) @jetersen
+ * Fixes #<!---->4 (#5) @Happypig375
+ * 2\\*2 should equal to 4\\*1 (#6) @jetersen
+ * Rename \\_\\_confgs\\\\confg.yml to \\_\\_configs\\\\config.yml (#7) @ghost
+ * Adds @<!---->nullable annotations to the 1\\*1+2\\*4 test in \\`tests.java\\` (#0) @Happypig375",
+ }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll throw away indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Snapshot - 0
+ Received + 0
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to use toMatchInlineSnapshot
is literally a waste of time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jetersen Any suggestions?
I simply did |
@jetersen Are there any more issues to resolve with this PR? |
ping |
Fixes #609