Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/cloneCommand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export const gitCloneCommandPlugin: JupyterFrontEndPlugin<void> = {
Operation.Clone,
trans,
{
path: fileBrowserModel.path,
path: app.serviceManager.contents.localPath(
fileBrowserModel.path
),
url: result.value.url,
versioning: result.value.versioning,
submodules: result.value.submodules
Expand Down Expand Up @@ -125,7 +127,13 @@ export const gitCloneCommandPlugin: JupyterFrontEndPlugin<void> = {
);

// Add the context menu items for the default file browser
addFileBrowserContextMenu(gitModel, fileBrowser, app.contextMenu, trans);
addFileBrowserContextMenu(
gitModel,
fileBrowser,
app.serviceManager.contents,
app.contextMenu,
trans
);

if (palette) {
// Add the commands to the command palette
Expand Down
18 changes: 12 additions & 6 deletions src/commandsAndMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ export function addCommands(
'Create an empty Git repository or reinitialize an existing one'
),
execute: async () => {
const currentPath = fileBrowserModel.path;
const currentPath = app.serviceManager.contents.localPath(
fileBrowserModel.path
);
const result = await showDialog({
title: trans.__('Initialize a Repository'),
body: trans.__('Do you really want to make this directory a Git Repo?'),
Expand Down Expand Up @@ -1314,7 +1316,9 @@ export function addCommands(
change.newValue?.last_modified ?? 0
).valueOf();
if (
change.newValue?.path === fullPath &&
app.serviceManager.contents.localPath(
change.newValue?.path ?? ''
) === fullPath &&
model.challenger.updateAt !== updateAt
) {
model.challenger = {
Expand Down Expand Up @@ -1794,6 +1798,7 @@ export function addHistoryMenuItems(
export function addFileBrowserContextMenu(
model: IGitExtension,
filebrowser: FileBrowser,
contents: Contents.IManager,
contextMenu: ContextMenuSvg,
trans: TranslationBundle
): void {
Expand All @@ -1809,11 +1814,12 @@ export function addFileBrowserContextMenu(
const statuses = new Set<Git.Status>(
// @ts-expect-error file cannot be undefined or null
items
.map(item =>
model.pathRepository === null
.map(item => {
const itemPath = contents.localPath(item.path);
return model.pathRepository === null
? undefined
: model.getFile(item.path)?.status
)
: model.getFile(itemPath)?.status;
})
.filter(status => typeof status !== 'undefined')
);

Expand Down
19 changes: 13 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,25 @@ async function activate(
// Create the Git model
const gitExtension = new GitExtension(docmanager, app.docRegistry, settings);

// Whenever we restore the application, sync the Git extension path
Promise.all([app.restored, fileBrowser.model.restored]).then(() => {
gitExtension.pathRepository = fileBrowser.model.path;
});

const onPathChanged = (
model: FileBrowserModel,
change: IChangedArgs<string>
) => {
gitExtension.pathRepository = change.newValue;
gitExtension.pathRepository = app.serviceManager.contents.localPath(
change.newValue
);
gitExtension.refreshBranch();
};

// Whenever we restore the application, sync the Git extension path
Promise.all([app.restored, fileBrowser.model.restored]).then(() => {
onPathChanged(fileBrowser.model, {
name: 'path',
newValue: fileBrowser.model.path,
oldValue: ''
});
});

// Whenever the file browser path changes, sync the Git extension path
fileBrowser.model.pathChanged.connect(onPathChanged);

Expand Down Expand Up @@ -245,6 +251,7 @@ async function activate(
addFileBrowserContextMenu(
gitExtension,
fileBrowser,
app.serviceManager.contents,
app.contextMenu,
trans
);
Expand Down