Custom code after Git/commit
Posted: Wed Nov 25, 2020 7:02 pm
Hi,
I want to add some custom javascript code after a git-commit-actions has completed successfully.
I already managed to execute some code (console.log() for testing) after the action. But how do I check if the commit was successful? Currently it is also executed when the user aborts in the commit dialog.
My current code looks like this (also checking for the document to be valid before the commit):
Thanks and regards,
Patrik
I want to add some custom javascript code after a git-commit-actions has completed successfully.
I already managed to execute some code (console.log() for testing) after the action. But how do I check if the commit was successful? Currently it is also executed when the user aborts in the commit dialog.
My current code looks like this (also checking for the document to be valid before the commit):
Code: Select all
goog.events.listenOnce(e.editor, sync.api.Editor.EventTypes.ACTIONS_LOADED, function(e) {
var commitAction = editor.getActionsManager().getActionById('Git/Commit');
var oldActionPerformed = commitAction.actionPerformed;
commitAction.actionPerformed = function(callback) {
editor.getActionsManager().invokeOperation(
'com.gdvdl.webauth.IsDocumentValid',
{}, // no parameters
function (err, result) {
console.log('Git/Commit - isValid: ' + result);
if (result == 'true') {
console.log('Git/Commit - valid');
oldActionPerformed.call(commitAction, function(callback) {
console.log('Git/Commit - Done!');
// TODO: check for successfull commit and perform some post-commit-action
});
} else {
[...] (error message)
}
},
null,
true // This is a background operation - it does not update the document
);
};
});
Thanks and regards,
Patrik