mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Rejecting all pushes.
This commit is contained in:
@@ -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<HttpServletReque
|
||||
|
||||
@Override
|
||||
public ReceivePack create(HttpServletRequest httpServletRequest, Repository repository) throws ServiceNotEnabledException, ServiceNotAuthorizedException {
|
||||
return new ReceivePack(repository);
|
||||
ReceivePack receivePack = new ReceivePack(repository);
|
||||
receivePack.setPreReceiveHook(new PreReceiveHook() {
|
||||
@Override
|
||||
public void onPreReceive(ReceivePack receivePack, Collection<ReceiveCommand> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.io.IOException;
|
||||
public class WLRepositoryResolver implements RepositoryResolver<HttpServletRequest> {
|
||||
|
||||
@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<HttpServletReque
|
||||
|
||||
CommitCommand co = git.commit();
|
||||
co.setAuthor("Winston", "wl3912@ic.ac.uk");
|
||||
co.setMessage("Initial import of the existing contents");
|
||||
co.setMessage("i am java miaow");
|
||||
co.call();
|
||||
} catch (GitAPIException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user