-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up setup internals #3435
Clean up setup internals #3435
Conversation
53e1513
to
51e849b
Compare
7e38c3e
to
6440b70
Compare
@@ -131,6 +133,8 @@ export class Extension extends Disposable { | |||
new InternalCommands(outputChannel, ...clis) | |||
) | |||
|
|||
const status = this.dispose.track(new Status(config, ...clis)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] There was a bug in the way that we were creating Status
it did not contain the dvcViewer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a type in a quick follow-up
export const buildSetup = ( | ||
disposer: Disposer, | ||
dependencies?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] This was not used anywhere
dvcReader: DvcReader, | ||
dvcRunner: DvcRunner, | ||
gitExecutor: GitExecutor, | ||
gitReader: GitReader, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] All of these ICli
s sit behind the InternalCommands
facade. No point to include the functionality twice.
} | ||
} | ||
|
||
public async setupWorkspace() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] move from private to public only, also done so it can be registered
@@ -257,10 +241,50 @@ export class Setup | |||
}) | |||
} | |||
|
|||
public async selectFocusedProjects() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] exposed so it can be registered as a command
@@ -310,13 +337,6 @@ export class Setup | |||
} | |||
} | |||
|
|||
private async initializeDvc() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] Registered externally and used in that way so we get a "free" telemetry event
@@ -36,7 +36,7 @@ export const initializeEmptyRepo = async (): Promise<string> => { | |||
return '' | |||
} | |||
|
|||
await gitExecutor.init(TEMP_DIR) | |||
await gitExecutor.gitInit(TEMP_DIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] (unfortunate but) you can't register the same command name twice in InternalCommands
mockDvcRoot: string | undefined, | ||
mockGitRoot: string | undefined, | ||
noGitCommits = true | ||
) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] Now that we are using InternalCommands
we have to build the dependencies in the normal way.
b698552
to
c5f7eaa
Compare
return await this.internalCommands.executeCommand( | ||
AvailableCommands.VERSION, | ||
cwd | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] Move the logic out of the "dumb" reader and into here. Wrote some tests to cover it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great and good cleanup job!
Code Climate has analyzed commit 5198cae and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 89.4% (85% is the threshold). This pull request will bring the total coverage in the repository to 95.7% (0.0% change). View more on Code Climate. |
Related to #3434
This PR starts to clean-up the internals of
Setup
. Comments are inline but the main change is removing instances ofDvcReader
,DvcExecutor
,GitReader
&GitExecutor
fromSetup
. All of the required commands should be available throughInternalCommands
which makes things in the class a bit cleaner.I also moved command registration out of the class (usual pattern) as then we don't have to worry about commands being "re-registered"/throwing errors when we build
Setup
for testing purposes.