gogs / gogs

Gogs is a painless self-hosted Git service
https://gogs.io
MIT License
45.06k stars 4.87k forks source link

Add possibility to define standard hooks for a newly created repository #2238

Open mfechner opened 8 years ago

mfechner commented 8 years ago

It would be a nice feature if you can define hooks that should be used by default for a newly created repository, e.g. a post-receive hook with content:

#!/bin/sh
git-commit-notifier /path/mailing_config.yml
stroucki commented 8 years ago

I've done this via an init/templatedir in ~/.gitconfig. But: #3753 .

biji commented 5 years ago

@stroucki would you share documentation how to do that? previously I create /usr/share/git-core/templates/hooks/post-receive and it work, but after some gogs updates it doesn't work anymore

stroucki commented 5 years ago

Here is my .gitconfig.

[user]
        email = gogs@fake.local
        name = Gogs
[core]
        quotepath = false

[init]
        templatedir = /home/git/git-template

The git-template directory has the initial contents for a new git repository:

/home/git/git-template/
/home/git/git-template/branches
/home/git/git-template/hooks
/home/git/git-template/hooks/prepare-commit-msg.sample
/home/git/git-template/hooks/applypatch-msg.sample
/home/git/git-template/hooks/post-update.sample
/home/git/git-template/hooks/commit-msg.sample
/home/git/git-template/hooks/pre-rebase.sample
/home/git/git-template/hooks/pre-applypatch.sample
/home/git/git-template/hooks/pre-push.sample
/home/git/git-template/hooks/update.sample
/home/git/git-template/hooks/pre-receive
/home/git/git-template/hooks/pre-commit.sample
/home/git/git-template/info
/home/git/git-template/info/exclude
/home/git/git-template/description

I apparently used pre-receive to call up my policy script.

stroucki commented 5 years ago

@biji see above