Ugrade jgit and jgit.http.server to 4.4.1.201607150455-r and fix tests

This commit is contained in:
Winston Li 2016-08-20 13:21:56 +01:00
parent 3389615ef6
commit 598ea8a6fb
4 changed files with 31 additions and 22 deletions

View file

@ -81,12 +81,12 @@
<dependency> <dependency>
<groupId>org.eclipse.jgit</groupId> <groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId> <artifactId>org.eclipse.jgit</artifactId>
<version>3.6.0.201412230720-r</version> <version>4.4.1.201607150455-r</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jgit</groupId> <groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.http.server</artifactId> <artifactId>org.eclipse.jgit.http.server</artifactId>
<version>3.6.0.201412230720-r</version> <version>4.4.1.201607150455-r</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>

View file

@ -19,6 +19,7 @@ import uk.ac.ic.wlgitbridge.util.Log;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
/** /**
* Created by Winston on 03/11/14. * Created by Winston on 03/11/14.
@ -57,9 +58,17 @@ public class WriteLatexPutHook implements PreReceiveHook {
private void handleSnapshotPostException(ReceivePack receivePack, ReceiveCommand receiveCommand, SnapshotPostException e) { private void handleSnapshotPostException(ReceivePack receivePack, ReceiveCommand receiveCommand, SnapshotPostException e) {
String message = e.getMessage(); String message = e.getMessage();
receivePack.sendError(message); receivePack.sendError(message);
for (String line : e.getDescriptionLines()) { StringBuilder msg = new StringBuilder();
receivePack.sendMessage("hint: " + line); for (Iterator<String> it = e.getDescriptionLines().iterator(); it.hasNext();) {
String line = it.next();
msg.append("hint: ");
msg.append(line);
if (it.hasNext()) {
msg.append('\n');
}
} }
receivePack.sendMessage("");
receivePack.sendMessage(msg.toString());
receiveCommand.setResult(Result.REJECTED_OTHER_REASON, message); receiveCommand.setResult(Result.REJECTED_OTHER_REASON, message);
} }

View file

@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge;
import com.ning.http.client.AsyncHttpClient; import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.Response; import com.ning.http.client.Response;
import org.apache.commons.io.IOUtils;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -22,8 +23,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertTrue;
/** /**
* Created by Winston on 11/01/15. * Created by Winston on 11/01/15.
@ -336,8 +336,6 @@ public class WLGitBridgeIntegrationTest {
} }
private static final String EXPECTED_OUT_PUSH_OUT_OF_DATE_FIRST = private static final String EXPECTED_OUT_PUSH_OUT_OF_DATE_FIRST =
"To http://127.0.0.1:33867/testproj.git\n" +
" ! [rejected] master -> master (non-fast-forward)\n" +
"error: failed to push some refs to 'http://127.0.0.1:33867/testproj.git'\n" + "error: failed to push some refs to 'http://127.0.0.1:33867/testproj.git'\n" +
"hint: Updates were rejected because the tip of your current branch is behind\n" + "hint: Updates were rejected because the tip of your current branch is behind\n" +
"hint: its remote counterpart. Integrate the remote changes (e.g.\n" + "hint: its remote counterpart. Integrate the remote changes (e.g.\n" +
@ -367,8 +365,6 @@ public class WLGitBridgeIntegrationTest {
} }
private static final String EXPECTED_OUT_PUSH_OUT_OF_DATE_SECOND = private static final String EXPECTED_OUT_PUSH_OUT_OF_DATE_SECOND =
"To http://127.0.0.1:33868/testproj.git\n" +
" ! [rejected] master -> master (non-fast-forward)\n" +
"error: failed to push some refs to 'http://127.0.0.1:33868/testproj.git'\n" + "error: failed to push some refs to 'http://127.0.0.1:33868/testproj.git'\n" +
"hint: Updates were rejected because the tip of your current branch is behind\n" + "hint: Updates were rejected because the tip of your current branch is behind\n" +
"hint: its remote counterpart. Integrate the remote changes (e.g.\n" + "hint: its remote counterpart. Integrate the remote changes (e.g.\n" +
@ -398,7 +394,6 @@ public class WLGitBridgeIntegrationTest {
} }
private static final List<String> EXPECTED_OUT_PUSH_INVALID_FILES = Arrays.asList( private static final List<String> EXPECTED_OUT_PUSH_INVALID_FILES = Arrays.asList(
"remote: error: invalid files",
"remote: hint: You have 4 invalid files in your Overleaf project:", "remote: hint: You have 4 invalid files in your Overleaf project:",
"remote: hint: file1.invalid (error)", "remote: hint: file1.invalid (error)",
"remote: hint: file2.exe (invalid file extension)", "remote: hint: file2.exe (invalid file extension)",
@ -433,7 +428,6 @@ public class WLGitBridgeIntegrationTest {
} }
private static final List<String> EXPECTED_OUT_PUSH_INVALID_PROJECT = Arrays.asList( private static final List<String> EXPECTED_OUT_PUSH_INVALID_PROJECT = Arrays.asList(
"remote: error: invalid project",
"remote: hint: project: no main file", "remote: hint: project: no main file",
"remote: hint: The project would have no (editable) main .tex file.", "remote: hint: The project would have no (editable) main .tex file.",
"To http://127.0.0.1:33870/testproj.git", "To http://127.0.0.1:33870/testproj.git",
@ -465,7 +459,6 @@ public class WLGitBridgeIntegrationTest {
} }
private static final List<String> EXPECTED_OUT_PUSH_UNEXPECTED_ERROR = Arrays.asList( private static final List<String> EXPECTED_OUT_PUSH_UNEXPECTED_ERROR = Arrays.asList(
"remote: error: Overleaf error",
"remote: hint: There was an internal error with the Overleaf server.", "remote: hint: There was an internal error with the Overleaf server.",
"remote: hint: Please contact Overleaf.", "remote: hint: Please contact Overleaf.",
"To http://127.0.0.1:33871/testproj.git", "To http://127.0.0.1:33871/testproj.git",
@ -499,6 +492,7 @@ public class WLGitBridgeIntegrationTest {
private static final List<String> EXPECTED_OUT_PUSH_INVALID_EXE_FILE = Arrays.asList( private static final List<String> EXPECTED_OUT_PUSH_INVALID_EXE_FILE = Arrays.asList(
"remote: error: invalid files", "remote: error: invalid files",
"remote:",
"remote: hint: You have 1 invalid files in your Overleaf project:", "remote: hint: You have 1 invalid files in your Overleaf project:",
"remote: hint: file1.exe (invalid file extension)", "remote: hint: file1.exe (invalid file extension)",
"To http://127.0.0.1:33872/testproj.git", "To http://127.0.0.1:33872/testproj.git",
@ -595,8 +589,14 @@ public class WLGitBridgeIntegrationTest {
private File cloneRepository(String repositoryName, int port, File dir) throws IOException, InterruptedException { private File cloneRepository(String repositoryName, int port, File dir) throws IOException, InterruptedException {
String repo = "git clone http://127.0.0.1:" + port + "/" + repositoryName + ".git"; String repo = "git clone http://127.0.0.1:" + port + "/" + repositoryName + ".git";
assertEquals(0, runtime.exec(repo, null, dir).waitFor()); Process gitProcess = runtime.exec(repo, null, dir);
int exitCode = gitProcess.waitFor();
if (exitCode != 0) {
System.err.println("git clone failed. Dumping stderr and stdout.");
System.err.println(IOUtils.toString(gitProcess.getErrorStream()));
System.err.println(IOUtils.toString(gitProcess.getInputStream()));
fail("git clone failed");
}
File repositoryDir = new File(dir, repositoryName); File repositoryDir = new File(dir, repositoryName);
assertEquals(0, runtime.exec("git config user.name TEST", null, repositoryDir).waitFor()); assertEquals(0, runtime.exec("git config user.name TEST", null, repositoryDir).waitFor());

View file

@ -34,14 +34,14 @@
<orderEntry type="library" name="Maven: com.ning:async-http-client:1.9.38" level="project" /> <orderEntry type="library" name="Maven: com.ning:async-http-client:1.9.38" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty:3.10.5.Final" level="project" /> <orderEntry type="library" name="Maven: io.netty:netty:3.10.5.Final" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jgit:org.eclipse.jgit:3.6.0.201412230720-r" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r" level="project" />
<orderEntry type="library" name="Maven: com.jcraft:jsch:0.1.50" level="project" /> <orderEntry type="library" name="Maven: com.jcraft:jsch:0.1.53" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.javaewah:JavaEWAH:0.7.9" level="project" /> <orderEntry type="library" name="Maven: com.googlecode.javaewah:JavaEWAH:0.7.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.1.3" level="project" /> <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.1.4" level="project" /> <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" /> <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" /> <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
<orderEntry type="library" name="Maven: org.eclipse.jgit:org.eclipse.jgit.http.server:3.6.0.201412230720-r" level="project" /> <orderEntry type="library" name="Maven: org.eclipse.jgit:org.eclipse.jgit.http.server:4.4.1.201607150455-r" level="project" />
<orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.8.11.2" level="project" /> <orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.8.11.2" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" /> <orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client:1.22.0" level="project" /> <orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client:1.22.0" level="project" />