|
1 | | -import { CancellationToken, commands, EventEmitter, ExtensionContext, Uri, window } from 'vscode'; |
| 1 | +import { CancellationToken, commands, EventEmitter, ExtensionContext, Uri, env, window } from 'vscode'; |
2 | 2 | import { nanoid } from 'nanoid'; |
3 | 3 | import * as path from 'path'; |
4 | 4 | import * as fs from 'fs-extra'; |
| 5 | +import * as os from 'os'; |
5 | 6 |
|
6 | 7 | import { Credentials } from '../authentication'; |
7 | 8 | import { CodeQLCliServer } from '../cli'; |
@@ -190,6 +191,22 @@ export class RemoteQueriesManager extends DisposableObject { |
190 | 191 | results => this.interfaceManager.setAnalysisResults(results, queryResult.queryId)); |
191 | 192 | } |
192 | 193 |
|
| 194 | + public async copyRemoteQueryRepoListToClipboard(queryId: string) { |
| 195 | + const queryResult = await this.getRemoteQueryResult(queryId); |
| 196 | + const repos = queryResult.analysisSummaries.map(a => a.nwo); |
| 197 | + |
| 198 | + if (repos.length > 0) { |
| 199 | + const text = [ |
| 200 | + '"new-repo-list": [', |
| 201 | + ...repos.slice(0, -1).map(repo => ` "${repo}",`), |
| 202 | + ` "${repos[repos.length - 1]}"`, |
| 203 | + ']' |
| 204 | + ]; |
| 205 | + |
| 206 | + await env.clipboard.writeText(text.join(os.EOL)); |
| 207 | + } |
| 208 | + } |
| 209 | + |
193 | 210 | private mapQueryResult( |
194 | 211 | executionEndTime: number, |
195 | 212 | resultIndex: RemoteQueryResultIndex, |
@@ -259,6 +276,10 @@ export class RemoteQueriesManager extends DisposableObject { |
259 | 276 | await createTimestampFile(path.join(this.storagePath, queryId)); |
260 | 277 | } |
261 | 278 |
|
| 279 | + private async getRemoteQueryResult(queryId: string): Promise<RemoteQueryResult> { |
| 280 | + return await this.retrieveJsonFile<RemoteQueryResult>(queryId, 'query-result.json'); |
| 281 | + } |
| 282 | + |
262 | 283 | private async storeJsonFile<T>(queryId: string, fileName: string, obj: T): Promise<void> { |
263 | 284 | const filePath = path.join(this.storagePath, queryId, fileName); |
264 | 285 | await fs.writeFile(filePath, JSON.stringify(obj, null, 2), 'utf8'); |
|
0 commit comments