diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/GitDirectoryContents.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/GitDirectoryContents.java index 4fd381c68d..ce2b93d9f0 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/GitDirectoryContents.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/GitDirectoryContents.java @@ -3,6 +3,7 @@ package uk.ac.ic.wlgitbridge.writelatex.filestore; import uk.ac.ic.wlgitbridge.bridge.WritableRepositoryContents; import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.writelatex.filestore.node.FileNode; +import uk.ac.ic.wlgitbridge.writelatex.filestore.store.WLFileStore; import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot; import java.io.File; @@ -30,6 +31,7 @@ public class GitDirectoryContents implements WritableRepositoryContents { @Override public void write() throws IOException, FailedConnectionException { + WLFileStore.deleteInDirectoryApartFrom(gitDirectory, ".git"); for (FileNode fileNode : fileNodes) { fileNode.writeToDisk(gitDirectory); } diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/store/WLFileStore.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/store/WLFileStore.java index fceaa4ef16..ac6f2c43f8 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/store/WLFileStore.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/filestore/store/WLFileStore.java @@ -41,6 +41,17 @@ public class WLFileStore { } } + public static void deleteInDirectoryApartFrom(File directory, String apartFrom) { + for (File file : directory.listFiles()) { + if (!file.getName().equals(apartFrom)) { + if (file.isDirectory()) { + deleteInDirectory(file); + } + file.delete(); + } + } + } + public List updateForProject(WLProject project) throws FailedConnectionException, InvalidProjectException { SortedSet snapshots = project.fetchNewSnapshots();