mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
implement new hook api for git repositories
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package org.eclipse.jgit.transport;
|
package org.eclipse.jgit.transport;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
@@ -46,7 +47,7 @@ import org.eclipse.jgit.lib.Repository;
|
|||||||
import org.eclipse.jgit.lib.RepositoryCache;
|
import org.eclipse.jgit.lib.RepositoryCache;
|
||||||
|
|
||||||
import sonia.scm.repository.GitRepositoryHandler;
|
import sonia.scm.repository.GitRepositoryHandler;
|
||||||
import sonia.scm.repository.RepositoryManager;
|
import sonia.scm.repository.spi.HookEventFacade;
|
||||||
import sonia.scm.web.GitReceiveHook;
|
import sonia.scm.web.GitReceiveHook;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -80,18 +81,17 @@ public class ScmTransportProtocol extends TransportProtocol
|
|||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param repositoryManager
|
|
||||||
* @param handler
|
|
||||||
*
|
*
|
||||||
* @param repositoryManagerProvider
|
* @param hookEventFacadeProvider
|
||||||
|
*
|
||||||
* @param repositoryHandlerProvider
|
* @param repositoryHandlerProvider
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public ScmTransportProtocol(
|
public ScmTransportProtocol(
|
||||||
Provider<RepositoryManager> repositoryManagerProvider,
|
Provider<HookEventFacade> hookEventFacadeProvider,
|
||||||
Provider<GitRepositoryHandler> repositoryHandlerProvider)
|
Provider<GitRepositoryHandler> repositoryHandlerProvider)
|
||||||
{
|
{
|
||||||
this.repositoryManagerProvider = repositoryManagerProvider;
|
this.hookEventFacadeProvider = hookEventFacadeProvider;
|
||||||
this.repositoryHandlerProvider = repositoryHandlerProvider;
|
this.repositoryHandlerProvider = repositoryHandlerProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ public class ScmTransportProtocol extends TransportProtocol
|
|||||||
|
|
||||||
//J-
|
//J-
|
||||||
return new TransportLocalWithHooks(
|
return new TransportLocalWithHooks(
|
||||||
repositoryManagerProvider.get(),
|
hookEventFacadeProvider.get(),
|
||||||
repositoryHandlerProvider.get(),
|
repositoryHandlerProvider.get(),
|
||||||
local, uri, gitDir
|
local, uri, gitDir
|
||||||
);
|
);
|
||||||
@@ -198,17 +198,18 @@ public class ScmTransportProtocol extends TransportProtocol
|
|||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param repositoryManager
|
*
|
||||||
|
* @param hookEventFacade
|
||||||
* @param handler
|
* @param handler
|
||||||
* @param local
|
* @param local
|
||||||
* @param uri
|
* @param uri
|
||||||
* @param gitDir
|
* @param gitDir
|
||||||
*/
|
*/
|
||||||
public TransportLocalWithHooks(RepositoryManager repositoryManager,
|
public TransportLocalWithHooks(HookEventFacade hookEventFacade,
|
||||||
GitRepositoryHandler handler, Repository local, URIish uri, File gitDir)
|
GitRepositoryHandler handler, Repository local, URIish uri, File gitDir)
|
||||||
{
|
{
|
||||||
super(local, uri, gitDir);
|
super(local, uri, gitDir);
|
||||||
this.repositoryManager = repositoryManager;
|
this.hookEventFacade = hookEventFacade;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,9 +228,9 @@ public class ScmTransportProtocol extends TransportProtocol
|
|||||||
{
|
{
|
||||||
ReceivePack pack = new ReceivePack(dst);
|
ReceivePack pack = new ReceivePack(dst);
|
||||||
|
|
||||||
if ((repositoryManager != null) && (handler != null))
|
if ((hookEventFacade != null) && (handler != null))
|
||||||
{
|
{
|
||||||
GitReceiveHook hook = new GitReceiveHook(repositoryManager, handler);
|
GitReceiveHook hook = new GitReceiveHook(hookEventFacade, handler);
|
||||||
|
|
||||||
pack.setPreReceiveHook(hook);
|
pack.setPreReceiveHook(hook);
|
||||||
pack.setPostReceiveHook(hook);
|
pack.setPostReceiveHook(hook);
|
||||||
@@ -244,15 +245,15 @@ public class ScmTransportProtocol extends TransportProtocol
|
|||||||
private GitRepositoryHandler handler;
|
private GitRepositoryHandler handler;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private RepositoryManager repositoryManager;
|
private HookEventFacade hookEventFacade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private Provider<GitRepositoryHandler> repositoryHandlerProvider;
|
private Provider<HookEventFacade> hookEventFacadeProvider;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private Provider<RepositoryManager> repositoryManagerProvider;
|
private Provider<GitRepositoryHandler> repositoryHandlerProvider;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
|
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
|
||||||
|
* nor the names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.repository.api;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import org.eclipse.jgit.transport.ReceivePack;
|
||||||
|
|
||||||
|
import sonia.scm.web.GitHooks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public final class GitHookMessageProvider implements HookMessageProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param receivePack
|
||||||
|
*/
|
||||||
|
public GitHookMessageProvider(ReceivePack receivePack)
|
||||||
|
{
|
||||||
|
this.receivePack = receivePack;
|
||||||
|
}
|
||||||
|
|
||||||
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendError(String message)
|
||||||
|
{
|
||||||
|
GitHooks.sendPrefixedError(receivePack, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void sendMessage(String message)
|
||||||
|
{
|
||||||
|
GitHooks.sendPrefixedMessage(receivePack, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private ReceivePack receivePack;
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
|
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
|
||||||
|
* nor the names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
|
import org.eclipse.jgit.transport.ReceivePack;
|
||||||
|
|
||||||
|
import sonia.scm.repository.GitHookChangesetCollector;
|
||||||
|
import sonia.scm.repository.RepositoryHookType;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class GitHookChangesetProvider implements HookChangesetProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param receivePack
|
||||||
|
* @param receiveCommands
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
public GitHookChangesetProvider(ReceivePack receivePack,
|
||||||
|
List<ReceiveCommand> receiveCommands, RepositoryHookType type)
|
||||||
|
{
|
||||||
|
this.receivePack = receivePack;
|
||||||
|
this.receiveCommands = receiveCommands;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public HookChangesetResponse handleRequest(HookChangesetRequest request)
|
||||||
|
{
|
||||||
|
if (response == null)
|
||||||
|
{
|
||||||
|
GitHookChangesetCollector collector =
|
||||||
|
new GitHookChangesetCollector(receivePack, receiveCommands);
|
||||||
|
|
||||||
|
response = new HookChangesetResponse(collector.collectChangesets());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private List<ReceiveCommand> receiveCommands;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private ReceivePack receivePack;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private HookChangesetResponse response;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private RepositoryHookType type;
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer. 2. Redistributions in
|
||||||
|
* binary form must reproduce the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer in the documentation and/or other
|
||||||
|
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
|
||||||
|
* nor the names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
|
import org.eclipse.jgit.transport.ReceivePack;
|
||||||
|
|
||||||
|
import sonia.scm.repository.RepositoryHookType;
|
||||||
|
import sonia.scm.repository.api.GitHookMessageProvider;
|
||||||
|
import sonia.scm.repository.api.HookMessageProvider;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Sebastian Sdorra
|
||||||
|
*/
|
||||||
|
public class GitHookContextProvider extends HookContextProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs ...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param receivePack
|
||||||
|
* @param receiveCommands
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
public GitHookContextProvider(ReceivePack receivePack,
|
||||||
|
List<ReceiveCommand> receiveCommands, RepositoryHookType type)
|
||||||
|
{
|
||||||
|
this.receivePack = receivePack;
|
||||||
|
this.receiveCommands = receiveCommands;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public HookChangesetProvider getChangesetProvider()
|
||||||
|
{
|
||||||
|
return new GitHookChangesetProvider(receivePack, receiveCommands, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public HookMessageProvider createMessageProvider()
|
||||||
|
{
|
||||||
|
return new GitHookMessageProvider(receivePack);
|
||||||
|
}
|
||||||
|
|
||||||
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private List<ReceiveCommand> receiveCommands;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private ReceivePack receivePack;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private RepositoryHookType type;
|
||||||
|
}
|
||||||
@@ -45,10 +45,10 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sonia.scm.repository.GitRepositoryHandler;
|
import sonia.scm.repository.GitRepositoryHandler;
|
||||||
import sonia.scm.repository.GitRepositoryHookEvent;
|
|
||||||
import sonia.scm.repository.RepositoryHookType;
|
import sonia.scm.repository.RepositoryHookType;
|
||||||
import sonia.scm.repository.RepositoryManager;
|
|
||||||
import sonia.scm.repository.RepositoryUtil;
|
import sonia.scm.repository.RepositoryUtil;
|
||||||
|
import sonia.scm.repository.spi.GitHookContextProvider;
|
||||||
|
import sonia.scm.repository.spi.HookEventFacade;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -75,13 +75,14 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
|||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param repositoryManager
|
*
|
||||||
|
* @param hookEventFacade
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
public GitReceiveHook(RepositoryManager repositoryManager,
|
public GitReceiveHook(HookEventFacade hookEventFacade,
|
||||||
GitRepositoryHandler handler)
|
GitRepositoryHandler handler)
|
||||||
{
|
{
|
||||||
this.repositoryManager = repositoryManager;
|
this.hookEventFacade = hookEventFacade;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,9 +135,12 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
|||||||
|
|
||||||
logger.trace("resolved repository name to {}", repositoryName);
|
logger.trace("resolved repository name to {}", repositoryName);
|
||||||
|
|
||||||
repositoryManager.fireHookEvent(GitRepositoryHandler.TYPE_NAME,
|
GitHookContextProvider context = new GitHookContextProvider(rpack,
|
||||||
repositoryName,
|
receiveCommands, type);
|
||||||
new GitRepositoryHookEvent(rpack, receiveCommands, type));
|
|
||||||
|
hookEventFacade.handle(GitRepositoryHandler.TYPE_NAME,
|
||||||
|
repositoryName).fireHookEvent(type, context);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -209,5 +213,5 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
|||||||
private GitRepositoryHandler handler;
|
private GitRepositoryHandler handler;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private RepositoryManager repositoryManager;
|
private HookEventFacade hookEventFacade;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
|
|||||||
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
|
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
|
||||||
|
|
||||||
import sonia.scm.repository.GitRepositoryHandler;
|
import sonia.scm.repository.GitRepositoryHandler;
|
||||||
import sonia.scm.repository.RepositoryManager;
|
import sonia.scm.repository.spi.HookEventFacade;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -63,14 +63,15 @@ public class GitReceivePackFactory
|
|||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param repositoryManager
|
*
|
||||||
|
* @param hookEventFacade
|
||||||
* @param handler
|
* @param handler
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public GitReceivePackFactory(RepositoryManager repositoryManager,
|
public GitReceivePackFactory(HookEventFacade hookEventFacade,
|
||||||
GitRepositoryHandler handler)
|
GitRepositoryHandler handler)
|
||||||
{
|
{
|
||||||
hook = new GitReceiveHook(repositoryManager, handler);
|
hook = new GitReceiveHook(hookEventFacade, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
@@ -46,7 +47,6 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import sonia.scm.repository.GitRepositoryHandler;
|
import sonia.scm.repository.GitRepositoryHandler;
|
||||||
import sonia.scm.repository.RepositoryException;
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.RepositoryManager;
|
|
||||||
import sonia.scm.repository.api.PushResponse;
|
import sonia.scm.repository.api.PushResponse;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
@@ -111,11 +111,11 @@ public class GitPushCommandTest extends AbstractRemoteCommandTestBase
|
|||||||
{
|
{
|
||||||
|
|
||||||
// store reference to handle weak references
|
// store reference to handle weak references
|
||||||
proto = new ScmTransportProtocol(new Provider<RepositoryManager>()
|
proto = new ScmTransportProtocol(new Provider<HookEventFacade>()
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RepositoryManager get()
|
public HookEventFacade get()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user