Skip to content

Commit 1ef2ae6

Browse files
add setting to always clear outputs before commits
1 parent 618ba72 commit 1ef2ae6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

schema/plugin.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@
8282
"title": "Hide hidden file warning",
8383
"description": "If true, the warning popup when opening the .gitignore file without hidden files will not be displayed.",
8484
"default": false
85+
},
86+
"clearOutputsBeforeCommit":{
87+
"type": "boolean",
88+
"title": "Clear outputs before commit",
89+
"description": "If true, notebook outputs will be cleared before committing.",
90+
"default": false
8591
}
8692
},
8793
"jupyter.lab.shortcuts": [

src/components/GitPanel.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,10 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
810810
const notebooksWithOutputs =
811811
await this.props.model.checkNotebooksForOutputs();
812812

813-
if (notebooksWithOutputs.length > 0) {
813+
if (
814+
notebooksWithOutputs.length > 0 &&
815+
!this.props.settings.composite['clearOutputsBeforeCommit']
816+
) {
814817
const dialog = new Dialog({
815818
title: this.props.trans.__('Notebook outputs detected'),
816819
body: `You are about to commit ${notebooksWithOutputs.length} notebook(s) with outputs.
@@ -842,6 +845,13 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
842845
} else {
843846
return;
844847
}
848+
} else if (this.props.settings.composite['clearOutputsBeforeCommit']) {
849+
id = Notification.emit(
850+
this.props.trans.__('Cleaning notebook outputs…'),
851+
'in-progress',
852+
{ autoClose: false }
853+
);
854+
await this.props.model.stripNotebooksOutputs(notebooksWithOutputs);
845855
}
846856

847857
const notificationMsg = this.props.trans.__('Committing changes...');

0 commit comments

Comments
 (0)