invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.07k stars 193 forks source link

fix: `melos version` creates wrong workspace CHANGELOG.md entry on Windows due to CRLF #710

Open Gustl22 opened 2 months ago

Gustl22 commented 2 months ago

Is there an existing issue for this?

Version

6.0.0

Description

melos version produces a new entry

# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

if the CHANGELOG.md is formatted in CRLF (like in Windows), although it's already existing.

Steps to reproduce

  1. Use a melos project.
  2. Open it up on Windows
  3. Make sure the CHANGELOG.md file is formatted as CRLF and not as LF in your preffered editor. This should be the standard behavior in Windows (at least for IntelliJ).
  4. run melos version

Expected behavior

Not have a dupe entry for

# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

Screenshots

No response

Additional context and comments

E.g. see https://github.com/bluefireteam/audioplayers/blob/main/CHANGELOG.md , see change.

spydon commented 1 month ago

This only happens if you re-save the changelog file under windows right?

Gustl22 commented 1 month ago

It more depends on the git config The default is: git config core.autocrlf which means, on windows, code is automatically converted to CRLF, to provide compatibility with the system. On a commit, it is then converted to LF: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings?platform=windows#global-settings-for-line-endings

So with the default git config, melos version is not working correctly due to the comparison. It should be a simple fix by replacing all the \r\n with \n before comparing, but I haven't gotten to it yet. I can post a PR when I have a free moment.