refactor: migrate all extension commands to the new project model
This MR changes the parameter of every command from the old, soon-to-be-replaced, WrappedRepository
to the new `ProjectInRepository' type.
The old and the new model can't be used as a source of truth at the same time. The user sets them up differently, and there would be inconsistencies in more complex scenarios (multiple repositories, multiple git remotes). So we temporarily have to introduce a translation method that translates the old model to the new one. Eventually, we'll get the model from GitLabProjectRepository
, but now we still get it the old way and then translate it to the new object structure.
Where do the commands get their parameter from now?
graph LR;
A[getActiveRepositoryOrSelectOne] -- "produces WrappedRepository" --> B[convertRepositoryToProject]
B -- "produces ProjectInRepository" --> C[extension command]
And this is how will the commands get it when the migration is complete
graph LR;
A[getActiveProjectOrSelectOne] -- "produces ProjectInRepository" --> B[extension command]
The implementation
- The
getActiveRepository
moved fromgit_extension_wrapper
to therun_with_valid_project
module. This way thegit_extension_wrapper
can focus on basic interaction with VS Code Git extension and not on additional business logic. - The
runWithValidProject
method changed signature to the new model and uses theconvertRepositoryToProject
method to translate the old model to the new model - The commands are migrated in small chunks to the new model (in separate commits that still work and pass tests)
This MR might be best-reviewed commit-by-commit.
There is no change to user-facing behaviour.
Related to #558 (closed)
Edited by Tomas Vik (OOO back on 2024-08-12)