@@ -11,7 +11,7 @@ import { createGist } from './gh-actions-api-client';
1111import { RemoteQueriesManager } from './remote-queries-manager' ;
1212import { generateMarkdown } from './remote-queries-markdown-generation' ;
1313import { RemoteQuery } from './remote-query' ;
14- import { AnalysisResults } from './shared/analysis-result' ;
14+ import { AnalysisResults , sumAnalysesResults } from './shared/analysis-result' ;
1515
1616/**
1717 * Exports the results of the currently-selected remote query.
@@ -74,13 +74,13 @@ async function determineExportFormat(
7474/**
7575 * Converts the results of a remote query to markdown and uploads the files as a secret gist.
7676 */
77- async function exportResultsToGist (
77+ export async function exportResultsToGist (
7878 ctx : ExtensionContext ,
7979 query : RemoteQuery ,
8080 analysesResults : AnalysisResults [ ]
8181) : Promise < void > {
8282 const credentials = await Credentials . initialize ( ctx ) ;
83- const description = 'CodeQL Variant Analysis Results' ;
83+ const description = buildGistDescription ( query , analysesResults ) ;
8484 const markdownFiles = generateMarkdown ( query , analysesResults , 'gist' ) ;
8585 // Convert markdownFiles to the appropriate format for uploading to gist
8686 const gistFiles = markdownFiles . reduce ( ( acc , cur ) => {
@@ -100,6 +100,17 @@ async function exportResultsToGist(
100100 }
101101}
102102
103+ /**
104+ * Builds Gist description
105+ * Ex: Empty Block (Go) x results (y repositories)
106+ */
107+ const buildGistDescription = ( query : RemoteQuery , analysesResults : AnalysisResults [ ] ) => {
108+ const resultCount = sumAnalysesResults ( analysesResults ) ;
109+ const repositoryLabel = `${ query . numRepositoriesQueried } ${ query . numRepositoriesQueried === 1 ? 'repository' : 'repositories' } ` ;
110+ const repositoryCount = query . numRepositoriesQueried ? repositoryLabel : '' ;
111+ return `${ query . queryName } (${ query . language } ) ${ resultCount } results (${ repositoryCount } )` ;
112+ } ;
113+
103114/**
104115 * Converts the results of a remote query to markdown and saves the files locally
105116 * in the query directory (where query results and metadata are also saved).
0 commit comments