black icon indicating copy to clipboard operation
black copied to clipboard

Replace CHANGES.md with something less prone to merge conflicts

Open JelleZijlstra opened this issue 3 years ago • 10 comments

As @Shivansh-007 noted in https://github.com/psf/black/issues/2238#issuecomment-1010922392, our current CHANGES.md mechanism for the changelog is very prone to merge conflicts. Another problem is that when a release happens between the time a PR is opened and when it is merged, it's possible to have the changelog entry go into the wrong section.

I haven't looked in detail in this space, but I know that possibilities include:

  • towncrier
  • blurb, which is used by CPython
  • writing our own; I'd like to avoid that unless we really have unusual needs that existing tools can't support

JelleZijlstra avatar Jan 12 '22 12:01 JelleZijlstra

towncrier only supports rst, afaik. I haven't been able to make it work with an md template.

onerandomusername avatar Jan 12 '22 13:01 onerandomusername

I've never really liked towncrier, blurb or their ilk. The dumb solution is to just add a bunch of bullet points with a note saying "please fill in a random bullet point". When you release, remove the empty ones.

hauntsaninja avatar Jan 13 '22 03:01 hauntsaninja

I think the simplicity of what we have to ensure we get change log entries far outweighs the complexity of all alternatives and make release time much easier on the releaser.

To be fair too, these have to be the easiest merge conflicts in the universe to fix and deal with compared to source code. It’s a list of sentences.

cooperlees avatar Jan 13 '22 04:01 cooperlees

I'm open to using towncrier assuming if I can get it to handle Markdown reasonably well and the amount of code necessary to integrate it isn't that high. Note if I do bring over towncrier I'd probably also bring over the changelog update automation that pip (I consider its changelog to be very nice and I'd like to model it if we do choose a more advanced changelog solution).

Except! ... @hauntsaninja's solution is also pretty appealing to me as well, though I'd make the modification to introduce some more sectioning of our entries grouping bug fixes, enhancements, etc. separately. Adding sections would also have the nice side-effect of making merge conflicts less likely as all of the changelog additions aren't concentrated at the end of the list causing all of these conflicts.

I am indeed a bit wary of adding more complexity to this domain.

ichard26 avatar Jan 13 '22 04:01 ichard26

Cooper's right about the conflict difficulty, and that might tip the scale if we're thinking about complex changes. At least our only problem now is conflicts, instead of some tool not working as intended. And while I dislike the messiness of filling in random bullet points, sections could indeed ease the pain. Now that we're going stable, would it be reasonable to introduce something like "fixed", "added", "changed" etc? Or would topical be better: "cli", "style", "integrations", "preview"...? Anyways, instead of adding them as needed, they could be removed on release if empty.

felix-hilden avatar Jan 13 '22 07:01 felix-hilden

I've never really liked towncrier, blurb or their ilk

I agree with this here, and I have reason to say so, towncrier is a great tool but has some unusual specifics:

  • No markdown support, only .rst files
  • Fragment type is the file extension
  • Creates new changelogs for every release, there is no way to maintain a single main changelog containing all version release changelogs
  • You can't have two changelogs for a single PR (according to their naming method)
  • It is somewhat dead, last https://github.com/twisted/towncrier/commit/0e6a4793bb786053c491fde52ea2667c73807f75 was in September, since then, there has not been commits/responses on newly created issues.

Blurb is built for CPython development, specific to their workflow: issue numbers from bugs.python.org, only .rst files, so we can't use it anyways.

I think the simplicity of what we have to ensure we get change log entries far outweighs the complexity of all alternatives and make release time much easier on the release.

I don't understand this, introducing something like towncrier/changelog feature I am building at discord-modmail (like discussed on discord) would make the process much simpler. The basic changelog creation process would be:

  • Running a changelog create command, say changelog add.
  • It would prompt you for the change category and the GitHub PR number (validate them).
  • Then it would open your desired editor (you have configured) and ask you to write your changelog.

For release, you just need to run one command changelog release 1.0.0 and boom, there you go.

To be fair too, these have to be the easiest merge conflicts in the universe to fix and deal with compared to source code. It’s a list of sentences.

Yes, you are right, but on every push? It becomes annoying. And I don't think GitHub has ever been kind enough and fixed those merge conflicts for me.

Shivansh-007 avatar Jan 14 '22 14:01 Shivansh-007

I suspect what Cooper is mentioning is that currently the release process can be fully done through the web interface. Unless we add even more complexity to the release workflows to automatically run this tool, this will require the use of the command line. This personally doesn't bother me but some people do like very lightweight release procesees.

ichard26 avatar Jan 14 '22 15:01 ichard26

My goal is not necessarily to prioritize releasing from the web interface, but to have as little manual human tool running as possible for a release. This reduces the room for human error. Today we have 1 commit and a GitHub release cut (which can be done via API, CLI or Web).

I feel all the other Change Log "automation and tooling" introduces more room for human error, compared to what we have today. A releaser today should proof read and cleanup change logs if needed as well.

I do agree tho, if a really old PR is merged it could be inserted into an old release. This I do not have a good answer other than we need to do better code review as maintainers and should check for this on each PR fixing it at merge time. Then this becomes a noop ...

Edit: I wonder how hard it would be to write something to check if the change is being added into a released version section of the change log (i.e. parse CHANGES.md)?

cooperlees avatar Jan 15 '22 20:01 cooperlees

My goal is not necessarily to prioritize releasing from the web interface, but to have as little manual human tool running as possible for a release. This reduces the room for human error.

Making a release workflow that is run after a release is published could possibly be a solution to this. Basically, enhancing the current pypi_upload workflow to also handle changelog releases.

I feel all the other Change Log "automation and tooling" introduces more room for human error, compared to what we have today. A releaser today should proof read and cleanup change logs if needed as well.

I am not sure why you say so, but wouldn't the changelog automation be less prone to error? You don't have changelogs been placed in the wrong release, you don't have to fix any conflicts - you don't remove a changelog line by mistake, the changelog format is maintained...

Edit: I wonder how hard it would be to write something to check if the change is being added into a released version section of the change log (i.e. parse CHANGES.md)?

That would be fairly easy to implement, but it doesn't mention the original point of this issue.

Shivansh-007 avatar Jan 16 '22 05:01 Shivansh-007

I don't know if you are looking for such a tool, but you can check out https://logchange.dev/tools/logchange/getting-started/

Jinja templates should meet your needs.

Apache Solr using it exactly because of wasting time for pull requests conflicts

https://lists.apache.org/thread/4dotf4qx4ss3qr3xonv2y63v7wdg40nt

marwin1991 avatar Nov 01 '25 08:11 marwin1991