[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jgit-dev] how to enable hooks on a repo?
|
On Thu, Jan 17, 2013 at 1:10 AM, André Dietisheim <adietish@xxxxxxxxxx> wrote:
> I'm writing some test that checks that the messages from the server are
> written to the outputstream, one would pass to the PushOperation (a patch
> I'm writing that allows push-messages to get written to the Eclipse console
> while the push is executed).
> In my test, I therefore try to install a hook on a repository that would
> produce some output when I push to this repository. Unfortunately my hook's
> not called and I wonder what I'm missing:
>
> <snip>
>
> Repository repo = repository1.getRepository();
> ReceivePack receivePack = new ReceivePack(repo);
> receivePack.setPostReceiveHook(new PostReceiveHook() {
>
> public void onPostReceive(ReceivePack rp,
> Collection<ReceiveCommand> commands) {
> ...
> }
> });
> receivePack.setPreReceiveHook(new PreReceiveHook() {
>
> public void onPreReceive(ReceivePack rp,
> Collection<ReceiveCommand> commands) {
> ...
> }
> });
> </snip>
This is correct code. But the hooks are only invoked if there is
actually a change to be made to the repository. The client end of the
push needs to for example create a new branch on the server side. Or
have a newer commit that is not yet at the server, and push that to a
branch on the server. Hooks don't run if the client and server are at
the same state.