Remove references to 'remote query' in user-facing text

(Only in recently introduced locations. More work still needs to be
done.)

Also:

- Change error to info
- Create credentials directly, don't use a callback.
This commit is contained in:
Andrew Eisenberg
2022-04-12 11:46:03 -07:00
parent 61d4305593
commit 2ca0060c6a
7 changed files with 12 additions and 14 deletions

View File

@@ -455,7 +455,6 @@ async function activateWithInstalledDistribution(
queryStorageDir,
ctx,
queryHistoryConfigurationListener,
() => Credentials.initialize(ctx),
async (from: CompletedLocalQueryInfo, to: CompletedLocalQueryInfo) =>
showResultsForComparison(from, to),
);

View File

@@ -318,9 +318,8 @@ export class QueryHistoryManager extends DisposableObject {
private qs: QueryServerClient,
private dbm: DatabaseManager,
private queryStorageDir: string,
ctx: ExtensionContext,
private ctx: ExtensionContext,
private queryHistoryConfigListener: QueryHistoryConfig,
private readonly getCredentials: () => Promise<Credentials>,
private doCompareCallback: (
from: CompletedLocalQueryInfo,
to: CompletedLocalQueryInfo
@@ -515,6 +514,10 @@ export class QueryHistoryManager extends DisposableObject {
this.registerQueryHistoryScrubber(queryHistoryConfigListener, ctx);
}
private getCredentials() {
return Credentials.initialize(this.ctx);
}
/**
* Register and create the history scrubber.
*/
@@ -839,7 +842,7 @@ export class QueryHistoryManager extends DisposableObject {
if (item.t === 'local') {
item.cancel();
} else if (item.t === 'remote') {
void showAndLogInformationMessage('Cancelling remote query. This may take a while.');
void showAndLogInformationMessage('Cancelling variant analysis. This may take a while.');
const credentials = await this.getCredentials();
await cancelRemoteQuery(credentials, item.remoteQuery);
}

View File

@@ -82,7 +82,7 @@ export async function cancelRemoteQuery(
const { actionsWorkflowRunId, controllerRepository: { owner, name } } = remoteQuery;
const response = await octokit.request(`POST /repos/${owner}/${name}/actions/runs/${actionsWorkflowRunId}/cancel`);
if (response.status >= 300) {
throw new Error(`Error cancelling remote query: ${response.status}`);
throw new Error(`Error cancelling variant analysis: ${response.status} ${response?.data?.message || ''}`);
}
}

View File

@@ -6,7 +6,7 @@ import * as fs from 'fs-extra';
import { Credentials } from '../authentication';
import { CodeQLCliServer } from '../cli';
import { ProgressCallback } from '../commandRunner';
import { createTimestampFile, showAndLogErrorMessage, showInformationMessageWithAction } from '../helpers';
import { createTimestampFile, showAndLogErrorMessage, showAndLogInformationMessage, showInformationMessageWithAction } from '../helpers';
import { Logger } from '../logging';
import { runRemoteQuery } from './run-remote-query';
import { RemoteQueriesInterfaceManager } from './remote-queries-interface';
@@ -159,7 +159,7 @@ export class RemoteQueriesManager extends DisposableObject {
// workflow was cancelled on the server
queryItem.failureReason = 'Cancelled';
queryItem.status = QueryStatus.Failed;
void showAndLogErrorMessage('Variant analysis monitoring was cancelled');
void showAndLogInformationMessage('Variant analysis was cancelled');
} else {
queryItem.failureReason = queryWorkflowResult.error;
queryItem.status = QueryStatus.Failed;
@@ -168,7 +168,7 @@ export class RemoteQueriesManager extends DisposableObject {
} else if (queryWorkflowResult.status === 'Cancelled') {
queryItem.failureReason = 'Cancelled';
queryItem.status = QueryStatus.Failed;
void showAndLogErrorMessage('Variant analysis monitoring was cancelled');
void showAndLogErrorMessage('Variant analysis was cancelled');
} else if (queryWorkflowResult.status === 'InProgress') {
// Should not get here. Only including this to ensure `assertNever` uses proper type checking.
void showAndLogErrorMessage(`Unexpected status: ${queryWorkflowResult.status}`);

View File

@@ -27,7 +27,6 @@ describe('query-history', () => {
let showQuickPickSpy: sinon.SinonStub;
let queryHistoryManager: QueryHistoryManager | undefined;
let selectedCallback: sinon.SinonStub;
let getCredentialsCallback: sinon.SinonStub;
let doCompareCallback: sinon.SinonStub;
let tryOpenExternalFile: Function;
@@ -50,7 +49,6 @@ describe('query-history', () => {
tryOpenExternalFile = (QueryHistoryManager.prototype as any).tryOpenExternalFile;
configListener = new QueryHistoryConfigListener();
selectedCallback = sandbox.stub();
getCredentialsCallback = sandbox.stub();
doCompareCallback = sandbox.stub();
});
@@ -751,7 +749,6 @@ describe('query-history', () => {
extensionPath: vscode.Uri.file('/x/y/z').fsPath,
} as vscode.ExtensionContext,
configListener,
getCredentialsCallback,
doCompareCallback
);
qhm.onWillOpenQueryItem(selectedCallback);

View File

@@ -32,9 +32,9 @@ describe('gh-actions-api-client', () => {
});
it('should fail to cancel a remote query', async () => {
mockResponse = sinon.stub().resolves({ status: 409 });
mockResponse = sinon.stub().resolves({ status: 409, data: { message: 'Uh oh!' } });
await expect(cancelRemoteQuery(mockCredentials, createMockRemoteQuery())).to.be.rejectedWith(/Error cancelling remote query/);
await expect(cancelRemoteQuery(mockCredentials, createMockRemoteQuery())).to.be.rejectedWith(/Error cancelling variant analysis: 409 Uh oh!/);
expect(mockResponse.calledOnce).to.be.true;
expect(mockResponse.firstCall.args[0]).to.equal('POST /repos/github/codeql/actions/runs/123/cancel');
});

View File

@@ -71,7 +71,6 @@ describe('Remote queries and query history manager', function() {
{
onDidChangeConfiguration: () => new DisposableBucket(),
} as unknown as QueryHistoryConfig,
asyncNoop as any,
asyncNoop
);
disposables.push(qhm);