mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Fixed test name and added to file store.
This commit is contained in:
parent
ae5a55747e
commit
f3a24603d9
5 changed files with 19 additions and 13 deletions
|
@ -1,11 +1,13 @@
|
|||
package uk.ac.ic.wlgitbridge.bridge;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.SnapshotDBAPI;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -37,17 +39,23 @@ public class WLBridgedProject {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateRepositoryFromSnapshots(Repository repository) throws ServiceNotEnabledException {
|
||||
private void updateRepositoryFromSnapshots(Repository repository) throws ServiceNotEnabledException, RepositoryNotFoundException, FailedConnectionException {
|
||||
List<Snapshot> snapshotsToAdd;
|
||||
try {
|
||||
snapshotsToAdd = snapshotDBAPI.getSnapshotsToAddToProject(name);
|
||||
} catch (InvalidProjectException e) {
|
||||
throw new RepositoryNotFoundException(name);
|
||||
}
|
||||
try {
|
||||
List<Snapshot> snapshotsToAdd = snapshotDBAPI.getSnapshotsToAddToProject(name);
|
||||
for (Snapshot snapshot : snapshotsToAdd) {
|
||||
snapshot.writeToDisk(repositoryDirectory.getAbsolutePath());
|
||||
Git git = new Git(repository);
|
||||
git.add().addFilepattern(".").call();
|
||||
git.commit().setAuthor(snapshot.getUserName(), snapshot.getUserEmail()).setMessage(snapshot.getComment()).call();
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
} catch (GitAPIException e) {
|
||||
throw new ServiceNotEnabledException();
|
||||
} catch (IOException e) {
|
||||
throw new ServiceNotEnabledException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,11 @@ public class SnapshotRepositoryBuilder implements RepositorySource {
|
|||
Repository repository = null;
|
||||
try {
|
||||
repository = new FileRepositoryBuilder().setWorkTree(repositoryDirectory).build();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
new WLBridgedProject(repository, name, repositoryDirectory, snapshotDBAPI).buildRepository();
|
||||
} catch (FailedConnectionException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceNotEnabledException();
|
||||
} catch (IOException e) {
|
||||
throw new ServiceNotEnabledException();
|
||||
}
|
||||
return repository;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ public class FileIndexStore {
|
|||
urlMappings = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
|
||||
public void addAttachment(String url, String filePath) {
|
||||
urlMappings.put(url, filePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package uk.ac.ic.wlgitbridge.writelatex.filestore;
|
|||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.WLProject;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
|||
/**
|
||||
* Created by Winston on 03/11/14.
|
||||
*/
|
||||
public class InvalidRootDirectoryPathException {
|
||||
public class InvalidRootDirectoryPathExceptionTest {
|
||||
|
||||
@Test
|
||||
public void nothingToTest() {
|
Loading…
Reference in a new issue