Implemented bare repos. (resolved #5)

This commit is contained in:
Winston Li 2015-01-06 20:36:56 +00:00
parent 553a1064a5
commit ece573c942
3 changed files with 12 additions and 1 deletions

View file

@ -8,6 +8,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; 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.api.request.getdoc.exception.InvalidProjectException;
import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -53,6 +54,8 @@ public class WLBridgedProject {
git.commit().setAuthor(new PersonIdent(contents.getUserName(), contents.getUserEmail(), contents.getWhen(), TimeZone.getDefault())) git.commit().setAuthor(new PersonIdent(contents.getUserName(), contents.getUserEmail(), contents.getWhen(), TimeZone.getDefault()))
.setMessage(contents.getCommitMessage()) .setMessage(contents.getCommitMessage())
.call(); .call();
System.out.println(repository.getDirectory());
WLFileStore.deleteInDirectoryApartFrom(contents.getDirectory(), ".git");
} }
} catch (GitAPIException e) { } catch (GitAPIException e) {
throw new ServiceNotEnabledException(); throw new ServiceNotEnabledException();

View file

@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge.bridge;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.util.Date;
@ -12,6 +13,8 @@ public interface WritableRepositoryContents {
public void write() throws IOException, FailedConnectionException; public void write() throws IOException, FailedConnectionException;
public File getDirectory();
public String getUserName(); public String getUserName();
public String getUserEmail(); public String getUserEmail();
public String getCommitMessage(); public String getCommitMessage();

View file

@ -34,12 +34,17 @@ public class GitDirectoryContents implements WritableRepositoryContents {
@Override @Override
public void write() throws IOException, FailedConnectionException { public void write() throws IOException, FailedConnectionException {
WLFileStore.deleteInDirectoryApartFrom(gitDirectory, ".git", ".wlgb"); WLFileStore.deleteInDirectoryApartFrom(gitDirectory, ".git");
for (FileNode fileNode : fileNodes) { for (FileNode fileNode : fileNodes) {
fileNode.writeToDisk(gitDirectory); fileNode.writeToDisk(gitDirectory);
} }
} }
@Override
public File getDirectory() {
return gitDirectory;
}
@Override @Override
public String getUserName() { public String getUserName() {
return userName; return userName;