Skip to content

Commit

Permalink
Merge pull request #761 from fcollonval/auto-backport-of-pr-759-on-0.…
Browse files Browse the repository at this point in the history
…11.x

Backport PR #759 on branch 0.11.x
  • Loading branch information
fcollonval authored Sep 5, 2020
2 parents b95e6cd + b659c81 commit 7ffee10
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion binder/postBuild
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pip install .
jupyter lab build
jupyter serverextension enable --sys-prefix --py nbgitpuller
jupyter lab build --dev-build=False --minimize=False --debug
6 changes: 0 additions & 6 deletions src/commandsAndMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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')
});
}
});

Expand Down
8 changes: 0 additions & 8 deletions src/components/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
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')
});
}
}
});
Expand All @@ -179,10 +175,6 @@ export class FileList extends React.Component<IFileListProps, IFileListState> {
});
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')
});
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ export class GitExtension implements IGitExtension {
});

this.refreshStatus();
this._openGitignore();
return Promise.resolve(response);
}

Expand Down Expand Up @@ -1274,6 +1275,7 @@ export class GitExtension implements IGitExtension {
});

this.refreshStatus();
this._openGitignore();
return Promise.resolve(response);
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7ffee10

Please sign in to comment.