19

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)?

Sachin Joseph
  • 18,928
  • 4
  • 42
  • 62

1 Answers1

9

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.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • 1
    Are you aware of any feature requests to add this to GitHub? I haven't been able to find any for GH. Bitbucket: https://jira.atlassian.com/browse/BSERV-4566 GitLab: https://gitlab.com/gitlab-org/gitlab/-/issues/18830 – Andrew Oct 31 '22 at 15:30
  • No, and I'm pretty sure that won't happen, because as I explained that would involve executing arbitrary code on behalf of users, which GitHub almost certainly does not want to do when merging. It would also be very slow. – bk2204 Oct 31 '22 at 21:34