From 6f5b316c529eff2f1a20d749b2b4cdb094678fab Mon Sep 17 00:00:00 2001 From: Winston Li Date: Mon, 3 Nov 2014 09:31:06 +0000 Subject: [PATCH] Rejecting all pushes. --- services/git-bridge/.idea/workspace.xml | 243 ++++++++++-------- .../wlgitbridge/git/WLReceivePackFactory.java | 22 +- .../wlgitbridge/git/WLRepositoryResolver.java | 6 +- 3 files changed, 156 insertions(+), 115 deletions(-) diff --git a/services/git-bridge/.idea/workspace.xml b/services/git-bridge/.idea/workspace.xml index fd5b58e595..7499abde9b 100644 --- a/services/git-bridge/.idea/workspace.xml +++ b/services/git-bridge/.idea/workspace.xml @@ -2,9 +2,8 @@ - - - + + @@ -28,21 +27,21 @@ - - + + - - + + - - + + - - + + @@ -52,57 +51,67 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + @@ -111,8 +120,8 @@ - - + + @@ -168,14 +177,18 @@ - @@ -611,7 +624,7 @@ - + @@ -619,19 +632,19 @@ - + - + - - + + @@ -905,54 +918,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1001,22 +966,6 @@ - - - - - - - - - - - - - - - - @@ -1025,10 +974,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1036,15 +1041,31 @@ - + - + - - + + + + + + + + + + + + + + + + + + diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLReceivePackFactory.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLReceivePackFactory.java index d78a189aad..5e68977c99 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLReceivePackFactory.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLReceivePackFactory.java @@ -1,12 +1,16 @@ package uk.ac.ic.wlgitbridge.git; +import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.transport.PreReceiveHook; +import org.eclipse.jgit.transport.ReceiveCommand; import org.eclipse.jgit.transport.ReceivePack; import org.eclipse.jgit.transport.resolver.ReceivePackFactory; import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import javax.servlet.http.HttpServletRequest; +import java.util.Collection; /** * Created by Winston on 02/11/14. @@ -15,7 +19,23 @@ public class WLReceivePackFactory implements ReceivePackFactory receiveCommands) { + System.out.println("Size: " + receiveCommands.size()); + for (ReceiveCommand receiveCommand : receiveCommands) { + System.out.println(receiveCommand); + System.out.println(receiveCommand.getMessage()); + System.out.println(receiveCommand.getType()); + System.out.println(receiveCommand.getResult()); + System.out.println(receiveCommand.getRefName()); + receiveCommand.setResult(RefUpdate.Result.REJECTED); + } + receivePack.sendError("hello this is not a fast forward"); + } + }); + return receivePack; } } diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLRepositoryResolver.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLRepositoryResolver.java index 22ebf7dcc3..267f8abb54 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLRepositoryResolver.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/WLRepositoryResolver.java @@ -22,8 +22,8 @@ import java.io.IOException; public class WLRepositoryResolver implements RepositoryResolver { @Override - public Repository open(HttpServletRequest httpServletRequest, String s) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException { - System.out.println(s); + public Repository open(HttpServletRequest httpServletRequest, String name) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException { + System.out.println(name); File workspace = new File("/Users/Roxy/git-test/hello"); @@ -52,7 +52,7 @@ public class WLRepositoryResolver implements RepositoryResolver