|
@@ -3,6 +3,7 @@ package uk.ac.ic.wlgitbridge.git.handler.hook;
|
|
|
import org.eclipse.jgit.lib.Repository;
|
|
import org.eclipse.jgit.lib.Repository;
|
|
|
import org.eclipse.jgit.transport.PreReceiveHook;
|
|
import org.eclipse.jgit.transport.PreReceiveHook;
|
|
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
|
|
|
|
+import org.eclipse.jgit.transport.ReceiveCommand.Result;
|
|
|
import org.eclipse.jgit.transport.ReceivePack;
|
|
import org.eclipse.jgit.transport.ReceivePack;
|
|
|
import uk.ac.ic.wlgitbridge.bridge.RawDirectoryContents;
|
|
import uk.ac.ic.wlgitbridge.bridge.RawDirectoryContents;
|
|
|
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource;
|
|
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource;
|
|
@@ -10,6 +11,7 @@ import uk.ac.ic.wlgitbridge.git.handler.hook.exception.ForcedPushException;
|
|
|
import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker;
|
|
import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.OutOfDateException;
|
|
import uk.ac.ic.wlgitbridge.writelatex.OutOfDateException;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.SnapshotPostException;
|
|
import uk.ac.ic.wlgitbridge.writelatex.SnapshotPostException;
|
|
|
|
|
+import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
@@ -32,21 +34,24 @@ public class WriteLatexPutHook implements PreReceiveHook {
|
|
|
handleReceiveCommand(receivePack.getRepository(), receiveCommand);
|
|
handleReceiveCommand(receivePack.getRepository(), receiveCommand);
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
receivePack.sendError("IOException");
|
|
receivePack.sendError("IOException");
|
|
|
- receiveCommand.setResult(ReceiveCommand.Result.REJECTED_OTHER_REASON, "I/O Exception");
|
|
|
|
|
|
|
+ receiveCommand.setResult(Result.REJECTED_OTHER_REASON, "I/O Exception");
|
|
|
|
|
+ } catch (FailedConnectionException e) {
|
|
|
|
|
+ receivePack.sendError("failed connection");
|
|
|
|
|
+ receiveCommand.setResult(Result.REJECTED_OTHER_REASON, "failed connection");
|
|
|
} catch (OutOfDateException e) {
|
|
} catch (OutOfDateException e) {
|
|
|
- receiveCommand.setResult(ReceiveCommand.Result.REJECTED_NONFASTFORWARD);
|
|
|
|
|
|
|
+ receiveCommand.setResult(Result.REJECTED_NONFASTFORWARD);
|
|
|
} catch (SnapshotPostException e) {
|
|
} catch (SnapshotPostException e) {
|
|
|
String message = e.getMessage();
|
|
String message = e.getMessage();
|
|
|
receivePack.sendError(message);
|
|
receivePack.sendError(message);
|
|
|
for (String line : e.getDescriptionLines()) {
|
|
for (String line : e.getDescriptionLines()) {
|
|
|
receivePack.sendMessage("hint: " + line);
|
|
receivePack.sendMessage("hint: " + line);
|
|
|
}
|
|
}
|
|
|
- receiveCommand.setResult(ReceiveCommand.Result.REJECTED_OTHER_REASON, message);
|
|
|
|
|
|
|
+ receiveCommand.setResult(Result.REJECTED_OTHER_REASON, message);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void handleReceiveCommand(Repository repository, ReceiveCommand receiveCommand) throws ForcedPushException, IOException, SnapshotPostException {
|
|
|
|
|
|
|
+ private void handleReceiveCommand(Repository repository, ReceiveCommand receiveCommand) throws IOException, SnapshotPostException, FailedConnectionException {
|
|
|
checkForcedPush(receiveCommand);
|
|
checkForcedPush(receiveCommand);
|
|
|
writeLatexDataSource.putDirectoryContentsToProjectWithName(repository.getWorkTree().getName(),
|
|
writeLatexDataSource.putDirectoryContentsToProjectWithName(repository.getWorkTree().getName(),
|
|
|
getPushedDirectoryContents(repository,
|
|
getPushedDirectoryContents(repository,
|