ZEPPELIN-143: adding JGit as initial impl

This commit is contained in:
Alexander Bezzubov 2015-11-30 12:32:02 +09:00
parent c21b3e632a
commit 20a93a454b
3 changed files with 39 additions and 16 deletions

View file

@ -51,13 +51,13 @@
<artifactId>zeppelin-interpreter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.10.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@ -123,12 +123,6 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
@ -151,11 +145,24 @@
<version>1.4.01</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.1.1.201511131810-r</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
</dependency>
</dependencies>
</project>

View file

@ -22,6 +22,11 @@ import java.util.List;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.notebook.Note;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.jgit.lib.Repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* NotebookRepo that hosts all the notebook FS in a single Git repo
@ -29,18 +34,24 @@ import org.apache.zeppelin.notebook.Note;
* This impl intended to be simple and straightforward:
* - does not handle branches
* - only basic git, no Github push\pull yet
*
*
*
*
* TODO(bzz): describe config
* GIT_URL remote
* auth credentials
*/
public class GitNotebookRepo extends VFSNotebookRepo implements NotebookRepoVersioned {
private static final Logger LOG = LoggerFactory.getLogger(GitNotebookRepo.class);
// I. First usefull case:
private Repository localRepo;
private Git git;
private String localPath;
// I. First usefull case:
// start \w repo + tutorial notebook
// all modifications results in a commit
// II. Next case:
// start \wo .git
// create one
@ -48,13 +59,18 @@ public class GitNotebookRepo extends VFSNotebookRepo implements NotebookRepoVers
// ..and then I...
// III. Next case:
// start \w repo
// start \w repo
// show history
// user can switch to REV in read-only
public GitNotebookRepo(ZeppelinConfiguration conf) throws IOException {
super(conf);
localPath = getRootDir().getName().getBaseName();
LOG.info("Opening a git repo at {}", localPath);
localRepo = new FileRepository(localPath + "/.git");
git = new Git(localRepo);
//TODO(bzz):
// - check that ./notebooks/.git exists
// - git init

View file

@ -182,7 +182,7 @@ public class VFSNotebookRepo implements NotebookRepo {
return getNote(noteDir);
}
private FileObject getRootDir() throws IOException {
protected FileObject getRootDir() throws IOException {
FileObject rootDir = fsManager.resolveFile(getPath("/"));
if (!rootDir.exists()) {