Skip to content
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

Scope task config lookup to workspace folder #3798

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/debugging/DockerDebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi
}

private async resolveDebugConfigurationInternal(context: DockerDebugContext, originalConfiguration: DockerDebugConfiguration): Promise<DockerDebugConfiguration | undefined> {
context.runDefinition = await getAssociatedDockerRunTask(originalConfiguration);
context.runDefinition = await getAssociatedDockerRunTask(originalConfiguration, context.folder);
context.actionContext.telemetry.properties.runTaskFound = context.runDefinition ? 'true' : 'false';

const helper = this.getHelper(context.platform);
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/DockerRunTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class DockerRunTaskProvider extends DockerTaskProvider {

context.actionContext.telemetry.properties.containerOS = definition.dockerRun.os || 'Linux';

context.buildDefinition = await getAssociatedDockerBuildTask(task);
context.buildDefinition = await getAssociatedDockerBuildTask(task, context.folder);
context.actionContext.telemetry.properties.buildTaskFound = context.buildDefinition ? 'true' : 'false';

const helper = this.getHelper(context.platform);
Expand Down
12 changes: 6 additions & 6 deletions src/tasks/TaskHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ export function registerTaskProviders(ctx: ExtensionContext): void {
}

export function hasTask(taskLabel: string, folder: WorkspaceFolder): boolean {
const workspaceTasks = workspace.getConfiguration('tasks', folder.uri);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we can just pass the folder instead of folder.uri. Same as line 113 below.

const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];
return allTasks.findIndex(t => t.label === taskLabel) > -1;
}

export async function addTask(newTask: DockerBuildTaskDefinition | DockerRunTaskDefinition, folder: WorkspaceFolder, overwrite?: boolean): Promise<boolean> {
// Using config API instead of tasks API means no wasted perf on re-resolving the tasks, and avoids confusion on resolved type !== true type
const workspaceTasks = workspace.getConfiguration('tasks', folder.uri);
const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];

const existingTaskIndex = allTasks.findIndex(t => t.label === newTask.label);
Expand All @@ -131,17 +131,17 @@ export async function addTask(newTask: DockerBuildTaskDefinition | DockerRunTask
return true;
}

export async function getAssociatedDockerRunTask(debugConfiguration: DockerDebugConfiguration): Promise<DockerRunTaskDefinition | undefined> {
export async function getAssociatedDockerRunTask(debugConfiguration: DockerDebugConfiguration, folder: WorkspaceFolder): Promise<DockerRunTaskDefinition | undefined> {
// Using config API instead of tasks API means no wasted perf on re-resolving the tasks (not just our tasks), and avoids confusion on resolved type !== true type
const workspaceTasks = workspace.getConfiguration('tasks');
const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks: TaskDefinitionBase[] = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];

return await recursiveFindTaskByType(allTasks, 'docker-run', debugConfiguration) as DockerRunTaskDefinition;
}

export async function getAssociatedDockerBuildTask(runTask: DockerRunTask): Promise<DockerBuildTaskDefinition | undefined> {
export async function getAssociatedDockerBuildTask(runTask: DockerRunTask, folder: WorkspaceFolder): Promise<DockerBuildTaskDefinition | undefined> {
// Using config API instead of tasks API means no wasted perf on re-resolving the tasks (not just our tasks), and avoids confusion on resolved type !== true type
const workspaceTasks = workspace.getConfiguration('tasks');
const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks: TaskDefinitionBase[] = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];

// Due to inconsistencies in the Task API, runTask does not have its dependsOn, so we need to re-find it by label
Expand Down