-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Zeppelin-540: Notebook versioning control, commit from frontend notebook menu #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
2ebe628
8069ccd
a1894c2
de7bdd6
bdeb0ed
32e403c
39c8e00
b69f2ff
c9192cb
b8fc035
39c2873
339c9fe
b0fa219
33f6e0f
a03a953
74db747
8b5766f
ef3a8fb
5f10b46
64111e0
4f04af0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,6 +155,21 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', | |
| }); | ||
| }; | ||
|
|
||
| // checkpoint/commit notebook | ||
| $scope.checkpointNotebook = function(commitMessage) { | ||
| BootstrapDialog.confirm({ | ||
| closable: true, | ||
| title: '', | ||
| message: 'Commit notebook to local Git repository?', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one, too. 'Git' should be removed. |
||
| callback: function(result) { | ||
| if (result) { | ||
| websocketMsgSrv.checkpointNotebook($routeParams.noteId, commitMessage); | ||
| } | ||
| } | ||
| }); | ||
| document.getElementById('note.checkpoint.message').value=''; | ||
| }; | ||
|
|
||
| $scope.runNote = function() { | ||
| BootstrapDialog.confirm({ | ||
| closable: true, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,16 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, | |
| }); | ||
| }, | ||
|
|
||
| checkpointNotebook: function(noteId, gitCommitMessage) { | ||
| websocketEvents.sendNewEvent({ | ||
| op: 'CHECKPOINT_NOTEBOOK', | ||
| data: { | ||
| noteId: noteId, | ||
| gitCommitMessage: gitCommitMessage | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use just 'message' or 'commitMessage' instead of 'gitCommitMessage' for the field name? |
||
| } | ||
| }); | ||
| }, | ||
|
|
||
| isConnected: function(){ | ||
| return websocketEvents.isConnected(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,28 +61,34 @@ public GitNotebookRepo(ZeppelinConfiguration conf) throws IOException { | |
| localRepo.create(); | ||
| } | ||
| git = new Git(localRepo); | ||
| maybeAddAndCommit("."); | ||
| checkpoint(".", "initialization commit"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this shouldn't be executed when Git repo already exists. Isn't it?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, that's more friendly. Actually I changed it not to commit even at first start when initializing Git repo. So on first start all the notebooks will be unstaged, and user will explicitly commit whenever needed. |
||
| } | ||
|
|
||
| @Override | ||
| public synchronized void save(Note note) throws IOException { | ||
| super.save(note); | ||
| maybeAddAndCommit(note.getId()); | ||
| } | ||
|
|
||
| private void maybeAddAndCommit(String pattern) { | ||
| /* implemented as git add+commit | ||
| * @param pattern is the noteId | ||
| * @param commitMessage is a commit message (checkpoint name) | ||
| * (non-Javadoc) | ||
| * @see org.apache.zeppelin.notebook.repo.VFSNotebookRepo#checkpoint(String, String) | ||
| */ | ||
| @Override | ||
| public void checkpoint(String pattern, String commitMessage) { | ||
| try { | ||
| List<DiffEntry> gitDiff = git.diff().call(); | ||
| if (!gitDiff.isEmpty()) { | ||
| LOG.debug("Changes found for pattern '{}': {}", pattern, gitDiff); | ||
| DirCache added = git.add().addFilepattern(pattern).call(); | ||
| LOG.debug("{} changes are about to be commited", added.getEntryCount()); | ||
| git.commit().setMessage("Updated " + pattern).call(); | ||
| git.commit().setMessage(commitMessage).call(); | ||
| } else { | ||
| LOG.debug("No changes found {}", pattern); | ||
| } | ||
| } catch (GitAPIException e) { | ||
| LOG.error("Faild to add+comit {} to Git", pattern, e); | ||
| LOG.error("Failed to add+comit {} to Git", pattern, e); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -100,7 +106,7 @@ public List<Rev> history(String noteId) { | |
| Iterable<RevCommit> logs = git.log().addPath(noteId).call(); | ||
| for (RevCommit log: logs) { | ||
| history.add(new Rev(log.getName(), log.getCommitTime())); | ||
| LOG.debug(" - ({},{})", log.getName(), log.getCommitTime()); | ||
| LOG.debug(" - ({},{},{})", log.getName(), log.getCommitTime(), log.getFullMessage()); | ||
| } | ||
| } catch (GitAPIException e) { | ||
| LOG.error("Failed to get logs for {}", noteId, e); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this dropdown menu independent from git?
Remove 'git' from Icons, descriptions..