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

--prepend cannot reliably identify the previous header #712

Open
1 task done
Cyclonit opened this issue Jun 17, 2024 · 2 comments
Open
1 task done

--prepend cannot reliably identify the previous header #712

Cyclonit opened this issue Jun 17, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Cyclonit
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

The CLI argument --prepend is supposed to result in git-cliff injecting the changelog for recent releases into an existing changelog.

  1. Remove the old header.
  2. Prepend the new releases' bodies.
  3. Prepend the new header.

Step 1 relied on the header being static between runs of git-cliff. It performed a simple string comparison between the existing CHANGELOG.md and the current value in the changelog.header variable. Since #697, changelog.header contains a template. Thus its value might change between runs and thus prevent detecting the old header.

Steps To Reproduce

  1. Set changelog.header to a template such that the output after rendering changes between releases.
  2. Create a new release.
  3. Run git-cliff with the --prepend flag.

Expected behavior

git-cliff should properly detect and replace the old header.

Screenshots / Logs

No response

Software information

Additional context

No response

@Cyclonit Cyclonit added the bug Something isn't working label Jun 17, 2024
@Cyclonit
Copy link
Contributor Author

@orhun suggested to simply render the header template prior to running the old logic. However, this is likely insufficient. In cases where the header templating feature is used, the header is likely to change between releases. Thus rendering it will not help in detecting the old header.

If we want --prepend to work reliably, I propose to inject markers using html comments into the markdown instead:

# Changelog

This is the changelog header.
<!-- END OF HEADER -->

## Release 2

- Lorem Ipsum

## Release 1

- Lorem Ipsum
<!-- END OF BODY -->

## Footer

This is the changelog footer.

@orhun orhun removed their assignment Jun 18, 2024
@orhun
Copy link
Owner

orhun commented Jun 18, 2024

If we want --prepend to work reliably, I propose to inject markers using html comments into the markdown instead:

Yes, I think that would be the best option.

Also see #433 - we might also parse the entire markdown and inject the new header. But your suggestion definitely sounds less painful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants