Skip to content

.githooks for bare repositories #159

@mjk-gh

Description

@mjk-gh

I have to admit I do not fully understand how githooks on the server are supposed to work.

After installation of githooks on the server with

sh -c "$(curl -fsSL https://raw.githubusercontent.com/rycus86/githooks/master/install.sh)" -- --only-server-hooks

and automatic or manual installation of githooks in all repositories on the server, I see that each repository's hook directory contains the appropriate template hooks.

Question is: How do I use these hooks?

I created a hook/.githooks/pre-receive hook script in one of the bare repositories on the server, similar to a script in the .githooks directory of a work tree in a user's local (obviously non-bare) repository, but it did not get called upon a user's "git push".

My use case is that for each repository on the server, I want the individual choice of running multiple server-side hooks each time a user does a "git push". These hooks should enforce various policies (some of them different for each repository) without a user having a chance of getting around them (e.g. by manipulating them in a local repository's .githooks directory). So my requirements are:

  • The server-side hooks should reside only on the server (which should already work, as the server-side bare-repo hooks directory will never get transferred to a user's local repository).
  • The server-side hooks should be specific for a repository. I have no idea where to put my hook scripts, maybe I overlooked something in the documentation.
  • Optionally, for specified repositories, there should be centrally stored hook scripts. This is probably already possible via "shared hooks" (not yet tested, because I do not know where to put the actual hook scripts or a .shared file).
  • There should be the possibility for multiple hook scripts for each event, just like with .githooks in a local repository.

If githooks is not "the right tool for the job", please let me know, but now that I got your wonderful hammer, every git problem looks like a nail. :-}

Also let me know if I missed the whole thing in the documentation by pointing me to the right location and sending me a cone of shame. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions