mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
ZEPPELIN-143: WIP - very basic sketch of GitNotebookRepo
This commit is contained in:
parent
cf0b4bc1dc
commit
c21b3e632a
2 changed files with 112 additions and 0 deletions
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.zeppelin.notebook.repo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
|
||||
/**
|
||||
* NotebookRepo that hosts all the notebook FS in a single Git repo
|
||||
*
|
||||
* 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 {
|
||||
|
||||
// I. First usefull case:
|
||||
// start \w repo + tutorial notebook
|
||||
// all modifications results in a commit
|
||||
|
||||
// II. Next case:
|
||||
// start \wo .git
|
||||
// create one
|
||||
// add existing notebooks
|
||||
// ..and then I...
|
||||
|
||||
// III. Next case:
|
||||
// start \w repo
|
||||
// show history
|
||||
// user can switch to REV in read-only
|
||||
|
||||
public GitNotebookRepo(ZeppelinConfiguration conf) throws IOException {
|
||||
super(conf);
|
||||
|
||||
//TODO(bzz):
|
||||
// - check that ./notebooks/.git exists
|
||||
// - git init
|
||||
// - setup EGit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Note note) throws IOException {
|
||||
super.save(note);
|
||||
//TODO(alex): if (git diff) { git add; git commit }
|
||||
}
|
||||
|
||||
@Override
|
||||
public Note get(String noteId, String rev) throws IOException {
|
||||
//TODO(alex): something instead of 'git checkout rev', which will not change-the-world
|
||||
return super.get(noteId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> history(String noteId) {
|
||||
//TODO(alex): git logs
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package org.apache.zeppelin.notebook.repo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.zeppelin.notebook.Note;
|
||||
|
||||
/**
|
||||
* Notebook repository w/ versions
|
||||
*/
|
||||
public interface NotebookRepoVersioned extends NotebookRepo {
|
||||
|
||||
/**
|
||||
* Get particular revision of the Notebooks
|
||||
*
|
||||
* @param noteId Id of the Notebook
|
||||
* @param rev revision of the Notebook
|
||||
* @return a Notebook
|
||||
* @throws IOException
|
||||
*/
|
||||
public abstract Note get(String noteId, String rev) throws IOException;
|
||||
|
||||
/**
|
||||
* List of revisions of the given Notebook
|
||||
*
|
||||
* @param noteId id of the Notebook
|
||||
* @return list of revisions
|
||||
*/
|
||||
public abstract List<String> history(String noteId);
|
||||
}
|
||||
Loading…
Reference in a new issue