[VS Code] Only support single account per workspace
Problem to solve
You can add multiple accounts from the same or from multiple GitLab instances.
That's OK.
However, now it's possible to use different accounts for different projects in the same VS Code Workspace (window).
We select the project based on which file is open:
- file from project A is open - we use the account the user associated with project A
- file from project B is open - we use the account the user associated with project B
- file that doesn't belong to any project is open
- for automatic actions (e.g. refreshing current branch information) we don't use any project/account
- for user-initiated actions (e.g. invoking the "Open Current Project in GitLab" command), we ask which project/account the user wants to use
Proposal
Refactor the code to only support one account for the workspace. All projects opened in the workspace (window) will use the same account.
Every project can now have a different account https://gitlab.com/gitlab-org/gitlab-vscode-extension/blob/6ec3a10897619faa677a46081098d86e751dbc56/docs/developer/architecture.md#L62
We can choose one of the following approaches:
- When we are initializing projects, we ensure that only one account is used for the setup
- We change the ProjectInRepository interface not to include the account and we'll get the account from somewhere else (e.g. account service)
- this approach is more future-proof because we'll eventually move to the VS Code
authentication
API where we'll get the account from thegetSession()
method.
- this approach is more future-proof because we'll eventually move to the VS Code
Further details
- I'd suggest that as a migration strategy, we'll ask people to select the account if there are multiple possibilities