MRVA: Include number of repositories queried in confirmation message (#1393)
This commit is contained in:
@@ -39,7 +39,7 @@ interface QueriesResponse {
|
|||||||
invalid_repositories?: string[],
|
invalid_repositories?: string[],
|
||||||
repositories_without_database?: string[],
|
repositories_without_database?: string[],
|
||||||
},
|
},
|
||||||
repositories_queried?: string[],
|
repositories_queried: string[],
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,15 +341,16 @@ async function runRemoteQueriesApiRequest(
|
|||||||
const eol = os.EOL;
|
const eol = os.EOL;
|
||||||
const eol2 = os.EOL + os.EOL;
|
const eol2 = os.EOL + os.EOL;
|
||||||
|
|
||||||
// exported for testng only
|
// exported for testing only
|
||||||
export function parseResponse(owner: string, repo: string, response: QueriesResponse) {
|
export function parseResponse(owner: string, repo: string, response: QueriesResponse) {
|
||||||
const popupMessage = `Successfully scheduled runs. [Click here to see the progress](https://github.com/${owner}/${repo}/actions/runs/${response.workflow_run_id}).`
|
const repositoriesQueried = response.repositories_queried;
|
||||||
|
const numRepositoriesQueried = repositoriesQueried.length;
|
||||||
|
|
||||||
|
const popupMessage = `Successfully scheduled runs on ${numRepositoriesQueried} repositories. [Click here to see the progress](https://github.com/${owner}/${repo}/actions/runs/${response.workflow_run_id}).`
|
||||||
+ (response.errors ? `${eol2}Some repositories could not be scheduled. See extension log for details.` : '');
|
+ (response.errors ? `${eol2}Some repositories could not be scheduled. See extension log for details.` : '');
|
||||||
|
|
||||||
let logMessage = `Successfully scheduled runs. See https://github.com/${owner}/${repo}/actions/runs/${response.workflow_run_id}.`;
|
let logMessage = `Successfully scheduled runs on ${numRepositoriesQueried} repositories. See https://github.com/${owner}/${repo}/actions/runs/${response.workflow_run_id}.`;
|
||||||
if (response.repositories_queried) {
|
logMessage += `${eol2}Repositories queried:${eol}${repositoriesQueried.join(', ')}`;
|
||||||
logMessage += `${eol2}Repositories queried:${eol}${response.repositories_queried.join(', ')}`;
|
|
||||||
}
|
|
||||||
if (response.errors) {
|
if (response.errors) {
|
||||||
logMessage += `${eol2}Some repositories could not be scheduled.`;
|
logMessage += `${eol2}Some repositories could not be scheduled.`;
|
||||||
if (response.errors.invalid_repositories?.length) {
|
if (response.errors.invalid_repositories?.length) {
|
||||||
|
|||||||
@@ -10,26 +10,15 @@ describe('run-remote-query', () => {
|
|||||||
repositories_queried: ['a/b', 'c/d'],
|
repositories_queried: ['a/b', 'c/d'],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.popupMessage).to.equal('Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).');
|
expect(result.popupMessage).to.equal('Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).');
|
||||||
expect(result.logMessage).to.equal(
|
expect(result.logMessage).to.equal(
|
||||||
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
|
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
|
||||||
'',
|
'',
|
||||||
'Repositories queried:',
|
'Repositories queried:',
|
||||||
'a/b, c/d'].join(os.EOL),
|
'a/b, c/d'].join(os.EOL),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse a response with no repositories queried', () => {
|
|
||||||
const result = parseResponse('org', 'name', {
|
|
||||||
workflow_run_id: 123,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(result.popupMessage).to.equal('Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).');
|
|
||||||
expect(result.logMessage).to.equal(
|
|
||||||
'Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should parse a response with invalid repos', () => {
|
it('should parse a response with invalid repos', () => {
|
||||||
const result = parseResponse('org', 'name', {
|
const result = parseResponse('org', 'name', {
|
||||||
workflow_run_id: 123,
|
workflow_run_id: 123,
|
||||||
@@ -40,12 +29,12 @@ describe('run-remote-query', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(result.popupMessage).to.equal(
|
expect(result.popupMessage).to.equal(
|
||||||
['Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
|
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
|
||||||
'',
|
'',
|
||||||
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
|
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
|
||||||
);
|
);
|
||||||
expect(result.logMessage).to.equal(
|
expect(result.logMessage).to.equal(
|
||||||
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
|
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
|
||||||
'',
|
'',
|
||||||
'Repositories queried:',
|
'Repositories queried:',
|
||||||
'a/b, c/d',
|
'a/b, c/d',
|
||||||
@@ -67,12 +56,12 @@ describe('run-remote-query', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(result.popupMessage).to.equal(
|
expect(result.popupMessage).to.equal(
|
||||||
['Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
|
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
|
||||||
'',
|
'',
|
||||||
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
|
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
|
||||||
);
|
);
|
||||||
expect(result.logMessage).to.equal(
|
expect(result.logMessage).to.equal(
|
||||||
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
|
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
|
||||||
'',
|
'',
|
||||||
'Repositories queried:',
|
'Repositories queried:',
|
||||||
'a/b, c/d',
|
'a/b, c/d',
|
||||||
@@ -96,12 +85,12 @@ describe('run-remote-query', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(result.popupMessage).to.equal(
|
expect(result.popupMessage).to.equal(
|
||||||
['Successfully scheduled runs. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
|
['Successfully scheduled runs on 2 repositories. [Click here to see the progress](https://github.com/org/name/actions/runs/123).',
|
||||||
'',
|
'',
|
||||||
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
|
'Some repositories could not be scheduled. See extension log for details.'].join(os.EOL)
|
||||||
);
|
);
|
||||||
expect(result.logMessage).to.equal(
|
expect(result.logMessage).to.equal(
|
||||||
['Successfully scheduled runs. See https://github.com/org/name/actions/runs/123.',
|
['Successfully scheduled runs on 2 repositories. See https://github.com/org/name/actions/runs/123.',
|
||||||
'',
|
'',
|
||||||
'Repositories queried:',
|
'Repositories queried:',
|
||||||
'a/b, c/d',
|
'a/b, c/d',
|
||||||
|
|||||||
Reference in New Issue
Block a user