Add stack trace prints and remove bugged git config.

This commit is contained in:
Winston Li 2015-02-22 00:45:19 +00:00
parent a91390dd37
commit 680c7fabf7
12 changed files with 6 additions and 151 deletions

View file

@ -7,6 +7,7 @@ import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import uk.ac.ic.wlgitbridge.bridge.RepositorySource;
import uk.ac.ic.wlgitbridge.bridge.WLBridgedProject;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource;
import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InternalErrorException;
import java.io.File;
@ -35,6 +36,7 @@ public class SnapshotRepositoryBuilder implements RepositorySource {
repository = new FileRepositoryBuilder().setWorkTree(repositoryDirectory).build();
new WLBridgedProject(repository, name, writeLatexDataSource).buildRepository();
} catch (IOException e) {
Util.printStackTrace(e);
throw new ServiceMayNotContinueException(new InternalErrorException().getDescriptionLines().get(0));
}
return repository;

View file

@ -18,7 +18,7 @@ public class InternalErrorException extends SevereSnapshotPostException {
@Override
public List<String> getDescriptionLines() {
return Arrays.asList("There as an internal error with the Git server.",
return Arrays.asList("There was an internal error with the Git server.",
"Please contact " + Util.getServiceName() + ".");
}

View file

@ -7,6 +7,7 @@ import com.ning.http.client.Response;
import org.eclipse.jgit.lib.Repository;
import uk.ac.ic.wlgitbridge.bridge.RawFile;
import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker;
import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.filestore.RepositoryFile;
@ -57,8 +58,10 @@ public class ResourceFetcher {
}).get();
} catch (InterruptedException e) {
Util.printStackTrace(e);
throw new FailedConnectionException();
} catch (ExecutionException e) {
Util.printStackTrace(e);
throw new FailedConnectionException();
}
urlIndexStore.addURLIndexForProject(projectName, url, path);

View file

@ -35,10 +35,6 @@ public class WLGitBridgeIntegrationTest {
put("canCloneMultipleRepositories", new HashMap<String, SnapshotAPIState>() {{
put("state", new SnapshotAPIStateBuilder(getResourceAsStream("/canCloneMultipleRepositories/state/state.json")).build());
}});
put("canPullAModifiedTexFile", new HashMap<String, SnapshotAPIState>() {{
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/base/state.json")).build());
put("withModifiedTexFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullAModifiedTexFile/withModifiedTexFile/state.json")).build());
}});
put("canPullADeletedTexFile", new HashMap<String, SnapshotAPIState>() {{
put("base", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedTexFile/base/state.json")).build());
put("withDeletedTexFile", new SnapshotAPIStateBuilder(getResourceAsStream("/canPullADeletedTexFile/withDeletedTexFile/state.json")).build());
@ -98,29 +94,6 @@ public class WLGitBridgeIntegrationTest {
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canCloneMultipleRepositories/state/testproj2"), testproj2.toPath()));
}
@Test
public void canPullAModifiedTexFile() throws IOException, GitAPIException {
MockSnapshotServer server = new MockSnapshotServer(3859, getResource("/canPullAModifiedTexFile").toFile());
server.start();
server.setState(states.get("canPullAModifiedTexFile").get("base"));
WLGitBridgeApplication wlgb = new WLGitBridgeApplication(new String[] {
makeConfigFile(33859, 3859)
});
wlgb.run();
folder.create();
File git = folder.newFolder();
Git base = Git.cloneRepository()
.setURI("http://127.0.0.1:33859/testproj.git")
.setDirectory(git)
.call();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedTexFile/base/testproj"), git.toPath()));
server.setState(states.get("canPullAModifiedTexFile").get("withModifiedTexFile"));
base.pull().call();
base.close();
wlgb.stop();
assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/canPullAModifiedTexFile/withModifiedTexFile/testproj"), git.toPath()));
}
@Test
public void canPullADeletedTexFile() throws IOException, GitAPIException {
MockSnapshotServer server = new MockSnapshotServer(3860, getResource("/canPullADeletedTexFile").toFile());

View file

@ -1,46 +0,0 @@
[
{
"project": "testproj",
"getDoc": {
"versionID": 1,
"createdAt": "2014-11-30T18:40:58Z",
"email": "jdleesmiller+1@gmail.com",
"name": "John+1"
},
"getSavedVers": [
{
"versionID": 1,
"comment": "added more info on doc GET and error details",
"email": "jdleesmiller+1@gmail.com",
"name": "John+1",
"createdAt": "2014-11-30T18:47:01Z"
}
],
"getForVers": [
{
"versionID": 1,
"srcs": [
{
"content": "content\n",
"path": "main.tex"
},
{
"content": "This text is from another file.",
"path": "foo/bar/test.tex"
}
],
"atts": [
{
"url": "http://127.0.0.1:3859/base/testproj/overleaf-white-410.png",
"path": "overleaf-white-410.png"
}
]
}
],
"push": "success",
"postback": {
"type": "success",
"versionID": 2
}
}
]

View file

@ -1,72 +0,0 @@
[
{
"project": "testproj",
"getDoc": {
"versionID": 2,
"createdAt": "2014-11-30T18:40:58Z",
"email": "jdleesmiller+1@gmail.com",
"name": "John+1"
},
"getSavedVers": [
{
"versionID": 2,
"comment": "i added more stuff to main.tex",
"email": "jdleesmiller+1@gmail.com",
"name": "John+1",
"createdAt": "2014-11-30T18:48:01Z"
},
{
"versionID": 1,
"comment": "added more info on doc GET and error details",
"email": "jdleesmiller+1@gmail.com",
"name": "John+1",
"createdAt": "2014-11-30T18:47:01Z"
}
],
"getForVers": [
{
"versionID": 2,
"srcs": [
{
"content": "content\nadded more stuff\n",
"path": "main.tex"
},
{
"content": "This text is from another file.",
"path": "foo/bar/test.tex"
}
],
"atts": [
{
"url": "http://127.0.0.1:3859/withModifiedTexFile/testproj/overleaf-white-410.png",
"path": "overleaf-white-410.png"
}
]
},
{
"versionID": 1,
"srcs": [
{
"content": "content\n",
"path": "main.tex"
},
{
"content": "This text is from another file.",
"path": "foo/bar/test.tex"
}
],
"atts": [
{
"url": "http://127.0.0.1:3857/base/testproj/overleaf-white-410.png",
"path": "overleaf-white-410.png"
}
]
}
],
"push": "success",
"postback": {
"type": "success",
"versionID": 2
}
}
]