Skip to content

refactor: use repositories instead of workspaces

Tomas Vik requested to merge 345-commands-use-repositories into main

This MR moves all extension logic to use repositories instead of workspaces (more details on #345 (closed)).

The main change in this MR is replacing two workspace helper method with repository helper methods:

before after explanation
getCurrentWorkspaceFolder gitExtensionWrapper.getActiveRepository it used to find workspace for the open file, return the only workspace, or return undefined if there was more workspaces. Now the logic is the same, but with repositories.
getCurrentWorkspaceFolderOrSelectOne gitExtensionWrapper.getActiveRepositoryOrSelectOne same as the previous one, except that when there is no open file and multiple repositories, we show a quick pick dialogue and let the user choose which repository should be used. This is used, for example, if you want to open GitLab web with issues that are assigned to you.

Screenshots

The open workspace doesn't have .git in it, but it does have multiple repositories in subfolders. The open text editor contains one file from a subfolder repository.

The screenshots highlight two changes (current_branch.ts and status_bar.ts) but there are more commands that are converted.

Before After
CHANGELOG_md___workspace_and_New_Recording_2021-05-03_at_17_18_49_and_New_Recording_2021-05-03_at_17_15_57 Extension_Development_Host_-CHANGELOG_md___workspace_and_status_bar_ts___gitlab-vscode-extension_and_Stone_Sour-Wicked_Game-_Acoustic__Live_and_New_Recording_2021-05-03_at_17_18_49

How to review

This MR is structured in meaningful commits and is best-reviewed commit-by-commit. However, the diff discussion is only going to be visible when looking at the whole diff.

Future work

There is going to be a follow-up MR that renames workspaceFolder to repositoryRoot throughout the whole project.

Related to #345 (closed)

Edited by Tomas Vik

Merge request reports