Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server-side custom git merge driver on GitHub/Azure Repos

I have a custom merge driver for git that helps merge lockfiles in a large monorepo shared by hundreds of engineers. Because lockfiles churn quite frequently, it's not uncommon for these files to result in merge conflicts while a PR is being reviewed (because master progresses). This means the PR branch should be updated manually after resolving conflicts on these lockfiles locally using this merge driver.

Question: Is there a way to configure this merge driver on GitHub (or Azure Repos) on the server-side such that this driver would be used for merging PR branches (as opposed to the default automerge)?

like image 505
Sachin Joseph Avatar asked Jun 24 '19 05:06

Sachin Joseph


People also ask

How do I fix Azure merge conflict?

Select the Conflicts link to start resolve file conflicts. This will bring up a list of files with conflicts. Selecting a file lets you accept the changes in the source branch you're merging from with the Take Source button or accept the changes in the branch you're merging into using Keep Target.

How do I merge two branches in Azure repository?

Create a PR from the Pull requests pageOn the Repos > Pull requests page, select New pull request at upper right. Select the branch with the changes and the branch you want to merge the changes into, such as the main branch. Enter your PR details and create the PR.

What is the difference between merge and squash and merge?

Squash merging is a merge option that allows you to condense the Git history of topic branches when you complete a pull request. Instead of each commit on the topic branch being added to the history of the default branch, a squash merge adds all the file changes to a single new commit on the default branch.

How do you merge conflicts in Azure Devops pull request?

Once the extension is installed, you can navigate to the Pull Request and you can view a new tab called Conflicts as shown below. Clicking on the Conflicts button you can see a new page where you can view the conflicts between the source and Target branches as shown below.


1 Answers

GitHub doesn't provide the ability to use custom merge drivers, and I'm not aware of any platform that does. Part of the reason for this is that custom merge drivers can execute arbitrary code and most hosting platforms are not interested in executing arbitrary code on behalf of users.

In addition, merges on GitHub are done with libgit2, which is designed to be fast and efficient when computing the merge and to abort early if the merge is not possible, and custom Git merge drivers wouldn't provide those features.

You could find some way to automerge pull requests that are approved to your satisfaction using a custom GitHub Actions operation that uses your custom merge driver and then pushes it to the repo. GitHub will show the branch as merged and close the pull request accordingly in that case. That's the closest you're likely going to be able to get, though.

like image 58
bk2204 Avatar answered Oct 19 '22 01:10

bk2204