[llvm-dev] [monorepo] Pre-push hook to prevent pushing merge commits

Zachary Turner via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 9 18:36:33 PST 2018


On Fri, Nov 9, 2018 at 11:41 AM Roman Lebedev via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> On Fri, Nov 9, 2018 at 10:33 PM Louis Dionne via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> >
> > Hi,
> >
> > At the LLVM dev meeting, some people discussed the possibility of having
> pre-push and/or pre-commit hooks to avoid messing up the history when we
> move on to the monorepo. One of the concerns was about people starting to
> push merge commits and unsquashed commits upstream, resulting in a messy
> history.
> >
> > I had volunteered to write a hook that would check for the absence of
> merge commits in the set of commits being pushed upstream, which I did. The
> hook is available here:
> https://gist.github.com/ldionne/2c260ce2081db74206e074e09cff71d0.
> >
> > If there is any interest for something like this, the code’s there.
> I would like to note that it is a client-side hook. So every one would
> need to install it.
> To be actually able to prevent such things, it needs to be
> centralized, server-side hook.
> (I don't think you can have server-side hooks on github, so if that is
> required,
> the master (as in, not a mirror, but the one you commit things into)
> git monorepo can't be located on github..)
>

Github has the notion of protected branches.  This is the same way you
disable the ability to force push to a branch, which I dare say is absolute
mandatory that we enable for master, and probably every other branch as
well, except for perhaps 1-2 admins.

I haven't studied the API in detail, but I believe it should be possible to
create a required check that a commit is not a merge commit (among other
things), and reject it if it is.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181109/43918995/attachment.html>


More information about the llvm-dev mailing list