Fix exceptions with workspace history
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
19
src/act.ts
19
src/act.ts
@@ -161,12 +161,6 @@ export class Act {
|
|||||||
const commandArgs: CommandArgs = taskDefinition.commandArgs;
|
const commandArgs: CommandArgs = taskDefinition.commandArgs;
|
||||||
const historyIndex = taskDefinition.historyIndex;
|
const historyIndex = taskDefinition.historyIndex;
|
||||||
|
|
||||||
// Initialize history for workspace
|
|
||||||
if (!this.historyManager.workspaceHistory[commandArgs.fsPath]) {
|
|
||||||
this.historyManager.workspaceHistory[commandArgs.fsPath] = [];
|
|
||||||
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new entry to workspace history
|
// Add new entry to workspace history
|
||||||
this.historyManager.workspaceHistory[commandArgs.fsPath].push({
|
this.historyManager.workspaceHistory[commandArgs.fsPath].push({
|
||||||
index: historyIndex,
|
index: historyIndex,
|
||||||
@@ -253,6 +247,7 @@ export class Act {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async runCommand(commandArgs: CommandArgs) {
|
async runCommand(commandArgs: CommandArgs) {
|
||||||
|
// Check if required components are ready
|
||||||
const unreadyComponents = await this.componentsManager.getUnreadyComponents();
|
const unreadyComponents = await this.componentsManager.getUnreadyComponents();
|
||||||
if (unreadyComponents.length > 0) {
|
if (unreadyComponents.length > 0) {
|
||||||
window.showErrorMessage(`The following required components are not ready: ${unreadyComponents.map(component => component.name).join(', ')}`, 'Fix...').then(async value => {
|
window.showErrorMessage(`The following required components are not ready: ${unreadyComponents.map(component => component.name).join(', ')}`, 'Fix...').then(async value => {
|
||||||
@@ -263,12 +258,20 @@ export class Act {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Map to workspace folder
|
||||||
const workspaceFolder = workspace.getWorkspaceFolder(Uri.file(commandArgs.fsPath));
|
const workspaceFolder = workspace.getWorkspaceFolder(Uri.file(commandArgs.fsPath));
|
||||||
if (!workspaceFolder) {
|
if (!workspaceFolder) {
|
||||||
window.showErrorMessage(`Failed to locate workspace folder for ${commandArgs.fsPath}`);
|
window.showErrorMessage(`Failed to locate workspace folder for ${commandArgs.fsPath}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize history for workspace
|
||||||
|
if (!this.historyManager.workspaceHistory[commandArgs.fsPath]) {
|
||||||
|
this.historyManager.workspaceHistory[commandArgs.fsPath] = [];
|
||||||
|
this.storageManager.update(StorageKey.WorkspaceHistory, this.historyManager.workspaceHistory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build command with settings
|
||||||
const secrets = (await this.settingsManager.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true)).filter(secret => secret.selected);
|
const secrets = (await this.settingsManager.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true)).filter(secret => secret.selected);
|
||||||
const variables = (await this.settingsManager.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false)).filter(variable => variable.selected);
|
const variables = (await this.settingsManager.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false)).filter(variable => variable.selected);
|
||||||
const inputs = (await this.settingsManager.getSetting(workspaceFolder, SettingsManager.inputsRegExp, StorageKey.Inputs, false)).filter(input => input.selected && input.value);
|
const inputs = (await this.settingsManager.getSetting(workspaceFolder, SettingsManager.inputsRegExp, StorageKey.Inputs, false)).filter(input => input.selected && input.value);
|
||||||
@@ -279,13 +282,15 @@ export class Act {
|
|||||||
(inputs.length > 0 ? ` ${Option.Input} ${inputs.map(input => `${input.key}=${input.value}`).join(` ${Option.Input} `)}` : ``) +
|
(inputs.length > 0 ? ` ${Option.Input} ${inputs.map(input => `${input.key}=${input.value}`).join(` ${Option.Input} `)}` : ``) +
|
||||||
(runners.length > 0 ? ` ${Option.Platform} ${runners.map(runner => `${runner.key}=${runner.value}`).join(` ${Option.Platform} `)}` : ``);
|
(runners.length > 0 ? ` ${Option.Platform} ${runners.map(runner => `${runner.key}=${runner.value}`).join(` ${Option.Platform} `)}` : ``);
|
||||||
|
|
||||||
|
// Process task count suffix
|
||||||
const historyIndex = this.historyManager.workspaceHistory[commandArgs.fsPath].length;
|
const historyIndex = this.historyManager.workspaceHistory[commandArgs.fsPath].length;
|
||||||
const matchingTasks = this.historyManager.workspaceHistory[commandArgs.fsPath]
|
const matchingTasks = this.historyManager.workspaceHistory[commandArgs.fsPath]
|
||||||
.filter(history => history.name === commandArgs.name)
|
.filter(history => history.name === commandArgs.name)
|
||||||
.sort((a, b) => b.count - a.count);
|
.sort((a, b) => b.count - a.count);
|
||||||
const count = matchingTasks && matchingTasks.length > 0 ? matchingTasks[0].count + 1 : 1;
|
const count = matchingTasks && matchingTasks.length > 0 ? matchingTasks[0].count + 1 : 1;
|
||||||
|
|
||||||
const taskExecution = await tasks.executeTask({
|
// Execute task
|
||||||
|
await tasks.executeTask({
|
||||||
name: `${commandArgs.name} #${count}`,
|
name: `${commandArgs.name} #${count}`,
|
||||||
detail: `${commandArgs.name} #${count}`,
|
detail: `${commandArgs.name} #${count}`,
|
||||||
definition: { type: 'GitHub Local Actions', commandArgs: commandArgs, historyIndex: historyIndex, count: count },
|
definition: { type: 'GitHub Local Actions', commandArgs: commandArgs, historyIndex: historyIndex, count: count },
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
|
|||||||
items.push(...await new WorkspaceFolderHistoryTreeItem(workspaceFolders[0]).getChildren());
|
items.push(...await new WorkspaceFolderHistoryTreeItem(workspaceFolders[0]).getChildren());
|
||||||
|
|
||||||
const workspaceHistory = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath];
|
const workspaceHistory = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath];
|
||||||
if (workspaceHistory.length > 0) {
|
if (workspaceHistory && workspaceHistory.length > 0) {
|
||||||
isRunning = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath].find(workspaceHistory => workspaceHistory.status === HistoryStatus.Running) !== undefined;
|
isRunning = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath].find(workspaceHistory => workspaceHistory.status === HistoryStatus.Running) !== undefined;
|
||||||
noHistory = false;
|
noHistory = false;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
|
|||||||
items.push(new WorkspaceFolderHistoryTreeItem(workspaceFolder));
|
items.push(new WorkspaceFolderHistoryTreeItem(workspaceFolder));
|
||||||
|
|
||||||
const workspaceHistory = act.historyManager.workspaceHistory[workspaceFolder.uri.fsPath];
|
const workspaceHistory = act.historyManager.workspaceHistory[workspaceFolder.uri.fsPath];
|
||||||
if (workspaceHistory.length > 0) {
|
if (workspaceHistory && workspaceHistory.length > 0) {
|
||||||
isRunning = act.historyManager.workspaceHistory[workspaceFolder.uri.fsPath].find(workspaceHistory => workspaceHistory.status === HistoryStatus.Running) !== undefined;
|
isRunning = act.historyManager.workspaceHistory[workspaceFolder.uri.fsPath].find(workspaceHistory => workspaceHistory.status === HistoryStatus.Running) !== undefined;
|
||||||
noHistory = false;
|
noHistory = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
items.push(...await new WorkspaceFolderSettingsTreeItem(workspaceFolders[0]).getChildren());
|
items.push(...await new WorkspaceFolderSettingsTreeItem(workspaceFolders[0]).getChildren());
|
||||||
|
|
||||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolders[0]);
|
const workflows = await act.workflowsManager.getWorkflows(workspaceFolders[0]);
|
||||||
if (workflows.length > 0) {
|
if (workflows && workflows.length > 0) {
|
||||||
noSettings = false;
|
noSettings = false;
|
||||||
}
|
}
|
||||||
} else if (workspaceFolders.length > 1) {
|
} else if (workspaceFolders.length > 1) {
|
||||||
@@ -74,7 +74,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
|||||||
items.push(new WorkspaceFolderSettingsTreeItem(workspaceFolder));
|
items.push(new WorkspaceFolderSettingsTreeItem(workspaceFolder));
|
||||||
|
|
||||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
||||||
if (workflows.length > 0) {
|
if (workflows && workflows.length > 0) {
|
||||||
noSettings = false;
|
noSettings = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
|
|||||||
items.push(...await new WorkspaceFolderWorkflowsTreeItem(workspaceFolders[0]).getChildren());
|
items.push(...await new WorkspaceFolderWorkflowsTreeItem(workspaceFolders[0]).getChildren());
|
||||||
|
|
||||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolders[0]);
|
const workflows = await act.workflowsManager.getWorkflows(workspaceFolders[0]);
|
||||||
if (workflows.length > 0) {
|
if (workflows && workflows.length > 0) {
|
||||||
noWorkflows = false;
|
noWorkflows = false;
|
||||||
}
|
}
|
||||||
} else if (workspaceFolders.length > 1) {
|
} else if (workspaceFolders.length > 1) {
|
||||||
@@ -86,7 +86,7 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
|
|||||||
items.push(new WorkspaceFolderWorkflowsTreeItem(workspaceFolder));
|
items.push(new WorkspaceFolderWorkflowsTreeItem(workspaceFolder));
|
||||||
|
|
||||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
||||||
if (workflows.length > 0) {
|
if (workflows && workflows.length > 0) {
|
||||||
noWorkflows = false;
|
noWorkflows = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user