Eliminate merge conflicts on ChangeLog.md
The merge conflicts on the Changelog file are trivial but very often. They occur on almost every MR. Solving them requires local rebasing and pushing the changes. It triggers the pipelines to re-run.
Adding a new entry to Changelog shouldn't cause conflict. It would allow us to merge with just one click (as long as there are no changes overlapping with the previous one), save time, and reduce the number of context switching and interruptions.
It isn't a problem if there is a single ticket to merge. But merging a few issues one by one takes more time and attention than it should. After each merge, you must stash your current work, switch a branch, fetch changes, rebase, solve a trivial conflict, push, go to the Gitlab page, and schedule a merge. And repeat the whole procedure after 40 minutes for the next MR.
And it is only if you are merging only your own issues. If somebody else is doing their merges at the same time, you interrupt each other and waste your time.
This problem just slows down and interrupts me a bit. It is taking me a whole day to merge 4 issues.
I propose two solutions on how to solve the problem:
Solution 1: Put Changelog entries in separate files
In this case, we don't maintain one conflict-prone Changelog file. Instead of it, the Changelog entries are stored in separate files. The entries are merged into a single Changelog file by a script running by CI or on demand. The file will contain the current Changelog entry content (i.e., bug/func/build label, nick of the author, description, and Gitlab number) except a number of the entry (the script will fill it up). The filenames must follow a naming convention to avoid conflicts (e.g., they must include the issue number).
The changelog entries will be placed in a dedicated directory (e.g., changelog/
).
The question is how to split the changelog entries by release date. We can use the git tags and analyze the git history or group the entries in the directories for specific milestones.
union
merge strategy for the Changelog file
Solution 2: Use the This solution should be much simpler. Git has a dedicated merge strategy for similar cases named union
. GitLab supports it.
Due to the merging being automatic, it cannot change the entry number. We should drop it from the committed content and fill it up using a script on CI.
A question is if Gitlab will allow merging the Changelog without a previous rebase. If not, the solution doesn't solve the main issue.
Another problem is the union
strategy don't work well for conflicts on similar changes. It may cause unexpected results. We need some experiments to check if the strategy is applicable in our case.