Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Add git-merge-changelog support (custom merge driver in .gitattributes) #560

Open
Envek opened this issue Jan 21, 2016 · 8 comments
Open

Comments

@Envek
Copy link

Envek commented Jan 21, 2016

I'm somewhat frequently send pull requests to open source projects. And I've noticed one inconvenience while sending PRs to big and actively developed repos in GitHub like Ruby on Rails' one, maintainers of which merges several pull requests every day (and GitHub is big and actively developed too). Also in RoR contribution guide written that for every change there should be an entry in ChangeLog file.

Because of that every pull requests become unmergeable in hours because of merge conflict in single text file! And to make it merged in you need to rebase and push several times just to allow collaborator to “catch” a moment when he can click “Merge” button. That's hurts and kills all the passion for contribution.

But if think for the moment, there is really no merge conflict at all as CHANGELOG files are prepend-only! I searched a bit more and found ready solution: a git-merge-changelog utility and blog post about configuring it: https://gnu.wildebeest.org/blog/mjw/2012/03/16/automagically-merging-changelog-files-with-mercurial-or-git/

I installed it (it is already available in Debian/Ubuntu repos) and played a bit with one of my old pull requests (approx. 1 year old) in Rails. Results are very good. I was able to merge it without conflicts and my entry to Ruby on Rails' ActiveSupport CHANGELOG was correctly prepended to the beginning of file.

I'm actively using GitHub and will be very happy if it can handle such situations.

Please, consider adding git-merge-changelog support in GitHub in such a way, that everyone can add a .gitattributes file to root of any repository with a line like this:

CHANGELOG.md merge=merge-changelog

and make most of their merge requests mergeable again! And everyone will know, that if PR is not mergeable it means that it is something really serious.

With best regards, Andrey Novikov.


Sent to support@github.com at 2016-01-06

Received reply from Francis Batac (GitHub Staff) support@github.com 2016-01-07

Hey Andrey -

Also in RoR contribution guide written that for every change there should be an entry in ChangeLog file.

Because of that every pull requests becomes unmergeable in hours because of merge conflict in single text file! And to make it merged in you need to rebase and push several times just to allow collaborator to “catch” a moment when he can click “Merge” button. That's hurts and kills all the passion for contribution.

At GitHub, we host a ton of awesome projects that each have their own contributing guidelines. Perhaps raising this within the rails/rails issue tracker would be the best way to go here.

So, please, add this to GitHub in such a way, that everyone can add a .gitattributes file to root of any repository with a line like this:

CHANGELOG.md merge=merge-changelog

and make most of their pull requests mergeable again! And everyone will know, that if PR is not mergeable it means that it is something really serious.

Andrey, thanks so much for your improvement proposal. We're always working to improve GitHub where we can.

I've added your idea about including an option to include a .gitattributes file to the root of any directory with a single line directive to our internal Feature Request List.

Let us know if you need help with anything else!

All the best,
Francis

Replied to Francis Batac (GitHub Staff) support@github.com 2016-01-07

Hello Francis.

Just want to clarify that CHANGELOGs are very popular in Open Source projects, so many developers suffer from changelog merging. Rails is just an example. Actually changelogs are good thing that allows to see (and search for) all recent changes as they are received, I don't think that anyone will abandon it.

Actually commit log in GitHub is not convenient for searching who and when made something. There is no search or filtering. But this is another problem.

For example try to find who and when added support for specifying database comments in https://github.com/rsim/oracle-enhanced . I used blame for CHANGELOG, found entry, and it was added later on. So I have tried to find a commit from beginning of 2009 with word «comment» in the message. So I just started switching pages in commit log and searching on page with Ctrl+F, but got tired quickly (pagination without ability to switch to arbitrary page sucks) and start to edit page number in URL. And found it on page 30! And this is not so big project anyway. Do you know better approach with GitHub UI? And yes, there is git log --grep exists, I know.

Thank you for reply and placing my proposal in feature request list.

With best wishes, Andrey.


Also posted same issue to GitLab issue tracker: https://gitlab.com/gitlab-org/gitlab-ce/issues/5902

@arenaq
Copy link

arenaq commented Jan 30, 2017

Will it work on all kinds of changelogs? I can see that is supports only GNU style changelogs. Have you tried different ones?

@Envek
Copy link
Author

Envek commented Jan 31, 2017

I have tested it on Ruby on Rails's ActiveRecord and ActiveSupport changelogs while constantly rebasing my pull requests and it always worked well.

As long as you will add lines strictly to the most top of the file, it will work.

@waldyrious
Copy link

FYI, this issue is closely related to (if not a duplicate of) #487.

@Envek
Copy link
Author

Envek commented Sep 13, 2017

It's closely related but not duplicate as merge=union is different and not so good for changelogs as git-merge-changelog.

I've tested merge=union too. Unfortunately CHANGELOG parts were merged in wrong order (all the existed parts from master branch went before my single entry). Also Git gitattributes docs recommends against using union strategy:

union

Run 3-way file level merge for text files, but take lines from both versions, instead of leaving conflict markers. This tends to leave the added lines in the resulting file in random order and the user should verify the result. Do not use this if you do not understand the implications.

So, it is required to be thoroughly tested both the union and merge-changelog approaches on real CHANGELOGs. Most probably adding of external git-merge-changelog tool is worth it.

@waldyrious
Copy link

Thanks for the clarification @Envek 👍

@roryokane
Copy link

GitHub uses the libgit2 library for its Git operations. libgit2 added support for custom merge drivers in March 2016, but GitHub still needs to change their code to use that feature.

@emartynov
Copy link

People, any update here?

@pawelngei
Copy link

We have a similar issue with netlify.toml that is changed in almost every single feature PR. This causes tons of merge conflicts and we'd like it to use ours merge strategy, similarly set in a .gitattributes.

It would be a huge help for our org if Github allows multiple merge drivers, as bypassing this with Github Actions or bots is pretty cumbersome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants