Skip to content

refactor: change git_service to always requrie workspaceFolder

Tomas Vik requested to merge 345-always-pass-in-workspace into main

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:

  1. User has got two projects in Multi-root Workspace:
    • A - from https://gitlab.com
    • B - from https://dev.gitlab.com
  2. User opens a file from project A - now the getCurrentWorkspaceFolder() always returns the folder for project A because the method always looks for the workspace for open file
  3. User tries to fetch open MRs for project B in the tree view.
  4. the gitlab_service.fetch() will take the instanceUrl from the wrong workspace (https://gitlab.com instead of https://dev.gitlab.com), because the user has got an open file from A

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)

Edited by Tomas Vik

Merge request reports