refactor: handle multiple GitLab projects in one Git repository
This MR extends our new project-centric model by adding handling for a situation where there are multiple detected repositories for a single repository.
This happens often when you fork a project, or the extension where we have a security remote:
$ git remote -v
origin git@gitlab.com:gitlab-org/gitlab-vscode-extension.git (fetch)
origin git@gitlab.com:gitlab-org/gitlab-vscode-extension.git (push)
security git@gitlab.com:gitlab-org/security/gitlab-vscode-extension.git (fetch)
security git@gitlab.com:gitlab-org/security/gitlab-vscode-extension.git (push)
In this scenario, the extension detects multiple GitLab projects and has to let the user choose which one should it use.
This MR also adds a command that lets you choose a project for a repository:
The flow in this MR
You can follow this flow to understand what the extension does:
- We detect multiple projects in
GitLabProjectRepository.detectProjects
- The
IssuableDataProvider.getNewChildren()
showsMultipleProjectsItem
, which alerts the user that multiple projects are in the repository. - User clicks the item, which will trigger the
ROGRAMMATIC_COMMANDS.SELECT_PROJECT
command, running theselect_project.ts
logic. - User selects a project. The new
SelectedProjectSetting
gets stored in theSelectedProjectStore
. -
SelectedProjectStore
triggered an event. TheGitLabProjectRepository
listens on this event and starts initializing projects again - This time, the
GitLabProjectRepository.addSelectedProjects
marks the selected project -
IssuableDataProvider.getNewChildren()
renders the project item because even though there are multiple detected projects, one of them is selected.
Edited by Tomas Vik (OOO back on 2024-10-31)