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

Template commit subjects have added linebreaks (Markdown + LF line breaks) #84

Closed
Kissaki opened this issue Sep 26, 2022 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@Kissaki
Copy link

Kissaki commented Sep 26, 2022

Using a --template template.hbs, commit title seems to have newlines added (with \n markdown + unix newline) on width excedding 86(?) characters.

For a template with \r\n (CR LF) newlines, the added \n newlines lead to mixed EOL of the text document.

Adding the Markdown two-space-line-break prevents template customization from being potentially useful for alternative output formats.

Writing the template file I would not have expected newlines to be added.

Reading the changelog as text, the broken line continuing without indentation makes it subjectively harder to read - even if/while rendered Markdown renders it indented.

Git commit summaries are supposed to be short when creating them. If they are designed and written by the author in a narrowed environment, it seems unnecessary to impose own, potentially different length rules that lead to different output.


I adjusted the template to be a list of commit summaries. It may be more obvious in this case over the default template with additional information.

* commit 1
* commit 2 aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaaaaaaa 
aaaaaaaaa (Ticket)
* commit 3

I suggest filling commits subject without adding line breaks to them. I see no downsides in rendering as-is. But as argued, I see various downsides of different degrees in adding newlines.

@Kissaki Kissaki added the bug Something isn't working label Sep 26, 2022
@hdevalke
Copy link
Collaborator

Word wrap has been added here 3338cf2.

You can probably play with the line length config. Maybe it is better to remove this wrapping, but enforce a max length in the commit and check subcommands.

# file: .versionrc
lineLength: 999

@Kissaki
Copy link
Author

Kissaki commented Sep 26, 2022

The .versionrc setting lineLength: 999 indeed resolves my immediate issue.

Feel free to close this ticket or keep it open if you plan to do something on this or not.

@hdevalke
Copy link
Collaborator

I think it would be better to move the word wrap logic to a handlebars helper.
Such that:

  • it can wrap type(scope): description instead of only taking description into account.
  • it can also be used to wrap the body

The word wrap could be applied when doing convco commit too. I'll keep the ticket open for now

hdevalke added a commit that referenced this issue Oct 4, 2022
Currently lines are wrapped based on the description only but not on the scope.
Now the word-wrap is part of the template and takes the full line into account.

```hbs
{{#word-wrap}}
..
{{/word-wrap}}
```

This also add control for word wrap and line length as flags.

`--no-wrap` to disable wrapping.
`--line-length <LINE_LENGTH>` to set the line length.

Refs: #84
hdevalke added a commit that referenced this issue Oct 4, 2022
Currently lines are wrapped based on the description only but not on the scope.
Now the word-wrap is part of the template and takes the full line into account.

```hbs
{{#word-wrap}}
..
{{/word-wrap}}
```

This also add control for word wrap and line length as flags.

`--no-wrap` to disable wrapping.
`--line-length <LINE_LENGTH>` to set the line length.

Refs: #84
hdevalke added a commit that referenced this issue Oct 4, 2022
Currently lines are wrapped based on the description only but not on the scope.
Now the word-wrap is part of the template and takes the full line into account.

```hbs
{{#word-wrap}}
..
{{/word-wrap}}
```

This also add control for word wrap and line length as flags.

`--no-wrap` to disable wrapping.
`--line-length <LINE_LENGTH>` to set the line length.

Refs: #84
@hdevalke
Copy link
Collaborator

hdevalke commented Oct 4, 2022

I added the option to disable word wrap for the default template, or if you use a custom template, the word-wrap will not be done if you do not use the {{#word-wrap}}..{{/word-wrap}} handlebars block.

For the newlines I think one solution could be to pass in convco changelog | unix2dos > CHANGELOG.md should work. Or maybe with a .gitattributes file, git can fix the line ending issues (see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings).

If you think i should do something more for this ticket please tell, otherwise i will close it soon.

@Kissaki
Copy link
Author

Kissaki commented Oct 5, 2022

You say it defaults to no word wrapping, but looking at commit 0fa3ea4 I see --no-wrap is introduced to disable wrapping, and the default value wrap_disabled: false, (1,2) seems to indicate that it defaults to wrapping? Could you clarify that?

@hdevalke
Copy link
Collaborator

hdevalke commented Oct 5, 2022

You say it defaults to no word wrapping

In case you use a default template and do not use a word-wrap block (see commit.hbs:1) no wrapping will be performed.

@Kissaki
Copy link
Author

Kissaki commented Oct 5, 2022

Ah, so if the template does not have the word-wrap block neither the config nor --no-wrap will have any effect?

Awesome, thank you. I will be using the new default behavior - of no line wrapping/breaking at all.

Regarding line endings unix2dos may not be available on Windows, and a .gitattributes approach will only be able to fix to consistent line endings after file commit and modified file checkout, but for me personally that is of no practical concern rn (given that I am not using wrapping). Feel free to close.

@hdevalke hdevalke closed this as completed Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants