diff --git a/binder/postBuild b/binder/postBuild index a87e6c4c1..f3ca7858f 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -1,2 +1,3 @@ pip install . -jupyter lab build \ No newline at end of file +jupyter serverextension enable --sys-prefix --py nbgitpuller +jupyter lab build --dev-build=False --minimize=False --debug diff --git a/src/commandsAndMenu.ts b/src/commandsAndMenu.ts index e25f21e16..450deb2db 100644 --- a/src/commandsAndMenu.ts +++ b/src/commandsAndMenu.ts @@ -12,7 +12,6 @@ import { ITerminal } from '@jupyterlab/terminal'; import { CommandRegistry } from '@phosphor/commands'; import { Menu } from '@phosphor/widgets'; import { IGitExtension } from './tokens'; -import { GitExtension } from './model'; import { GitCredentialsForm } from './widgets/CredentialsBox'; import { doGitClone } from './widgets/gitClone'; import { GitPullPushDialog, Operation } from './widgets/gitPushPull'; @@ -199,11 +198,6 @@ export function addCommands( isEnabled: () => model.pathRepository !== null, execute: async () => { await model.ensureGitignore(); - const gitModel = model as GitExtension; - await gitModel.commands.execute('docmanager:reload'); - await gitModel.commands.execute('docmanager:open', { - path: model.getRelativeFilePath('.gitignore') - }); } }); diff --git a/src/components/FileList.tsx b/src/components/FileList.tsx index 4d6bb699f..2303b8d92 100644 --- a/src/components/FileList.tsx +++ b/src/components/FileList.tsx @@ -152,10 +152,6 @@ export class FileList extends React.Component { execute: async () => { if (this.state.selectedFile) { await this.props.model.ignore(this.state.selectedFile.to, false); - await this.props.model.commands.execute('docmanager:reload'); - await this.props.model.commands.execute('docmanager:open', { - path: this.props.model.getRelativeFilePath('.gitignore') - }); } } }); @@ -179,10 +175,6 @@ export class FileList extends React.Component { }); if (result.button.label === 'Ignore') { await this.props.model.ignore(this.state.selectedFile.to, true); - await this.props.model.commands.execute('docmanager:reload'); - await this.props.model.commands.execute('docmanager:open', { - path: this.props.model.getRelativeFilePath('.gitignore') - }); } } } diff --git a/src/model.ts b/src/model.ts index 3ff88dbed..fdc0c2056 100644 --- a/src/model.ts +++ b/src/model.ts @@ -1243,6 +1243,7 @@ export class GitExtension implements IGitExtension { }); this.refreshStatus(); + this._openGitignore(); return Promise.resolve(response); } @@ -1274,6 +1275,7 @@ export class GitExtension implements IGitExtension { }); this.refreshStatus(); + this._openGitignore(); return Promise.resolve(response); } @@ -1426,6 +1428,22 @@ export class GitExtension implements IGitExtension { return this._taskID; } + /** + * open new editor or show an existing editor of the + * .gitignore file. If the editor does not have unsaved changes + * then ensure the editor's content matches the file on disk + */ + private _openGitignore() { + if (this._docmanager) { + const widget = this._docmanager.openOrReveal( + this.getRelativeFilePath('.gitignore') + ); + if (widget && !widget.context.model.dirty) { + widget.context.revert(); + } + } + } + /** * if file is open in JupyterLab find the widget and ensure the JupyterLab * version matches the version on disk. Do nothing if the file has unsaved changes