refactor: change git_service to always requrie workspaceFolder
This is an initial refactoring as we change the paradigm of the extension from workspace-centric to repository-centric (#345 (closed)).
The first issue we needed to tackle is that the gitlab_service
methods often didn't require the client code to specify workspaceFolder
. Instead, the fetch()
method responsible for making API requests called getCurrentWorkspaceFolder()
to get the instanceUrl
. This would cause bugs in rare cases when the user uses Multi-root Workspace and in their workspace, they have two projects from different instances.
Example:
- User has got two projects in Multi-root Workspace:
-
A
- fromhttps://gitlab.com
-
B
- fromhttps://dev.gitlab.com
-
- User opens a file from project
A
- now thegetCurrentWorkspaceFolder()
always returns the folder for projectA
because the method always looks for the workspace for open file - User tries to fetch open MRs for project
B
in the tree view. - the
gitlab_service
.fetch()
will take theinstanceUrl
from the wrong workspace (https://gitlab.com
instead ofhttps://dev.gitlab.com
), because the user has got an open file fromA
There is very low chance of this happening, I'm just pointing out the design flaw.
Not being able to specify workspaceFolder
in git_service
would also cause issues in the next MR when we switch to repositories and temporarily use the repository root folder as the workspaceFolder
.
Related to #345 (closed)