mirage / irmin

Irmin is a distributed database that follows the same design principles as Git
https://irmin.org
ISC License
1.81k stars 154 forks source link

Built-in "Hooks" support akin to Git Hooks #603

Open marcoonroad opened 5 years ago

marcoonroad commented 5 years ago

Hi, folks! First and foremost, thanks by this amazing library!

I'm here to ask for a desirable feature, and if I'm allowed as well, to implement a PR for that.

Git Hooks are executable scripts called by the Git CLI. There are many tools which generate such scripts, such as Node's Husky package. Git hook scripts are often used for CI/CD & third-party webhook notifications, and they can be triggered on either developer's machine or on the hosted Git repository itself (see https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks).

The major rationale/argument for such kind of feature is to enforce custom invariants on the Irmin's performed operations (such as read, write, merge, pull and push). For instance, it could be used to check for GPG signed commits (as suggested on #555), or even to verify commits carrying proof-of-work nonces. If the commits aren't valid following written invariants described by some OCaml modules here and there, the Irmin storage functor instance would reject/refuse them.

I'm looking forward for further discussion. Thanks in advance. :wave:

marcoonroad commented 5 years ago

(The default hooks, if not provided during functor application, could be no-op hooks.)

zshipko commented 5 years ago

This sounds like it could be interesting -- as far as I know, this idea has not been banned from Irmin, so you should go ahead and work on a PR if you'd like to :smiley:

I don't have anything else to add to the discussion at this point, but I'm curious to see what you come up with!