diff --git a/CHANGELOG.md b/CHANGELOG.md index 63d5925cab1..a77f7a359da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to Sourcegraph are documented in this file. - Batch Changes now allows changesets to be exported in CSV and JSON format. [#56721](https://github.com/sourcegraph/sourcegraph/pull/56721) - Supports custom ChatCompletion models in Cody clients for dotcom users. [#58158](https://github.com/sourcegraph/sourcegraph/pull/58158) - Topics synced from GitHub and GitLab are now displayed for repository matches in the search results and on the repository tree page. [#58927](https://github.com/sourcegraph/sourcegraph/pull/58927) +- Added a new column "Repository metadata JSON" to the CSV export of repository search results, which includes the JSON encoded object of metadata key-value pairs. [#59334](https://github.com/sourcegraph/sourcegraph/pull/59334) ### Changed @@ -57,6 +58,7 @@ All notable changes to Sourcegraph are documented in this file. - The feature flag `search-ranking` is now completely removed. [#58156](https://github.com/sourcegraph/sourcegraph/pull/58156) - The notepad UI, notebook creation feature. [#58217](https://github.com/sourcegraph/sourcegraph/pull/58217) - The experimental `indexRepositoryName` option for the rust packages code host connection has been removed. [#59176](https://github.com/sourcegraph/sourcegraph/pull/59176) +- The column "Repository metadata" in the CSV export of repository search results is now deprecated and will be removed in a future release. Use "Repository metadata JSON" instead [#59334](https://github.com/sourcegraph/sourcegraph/pull/59334) ## Unreleased 5.2.6 diff --git a/client/web/src/search/results/export/searchResultsExport.test.ts b/client/web/src/search/results/export/searchResultsExport.test.ts index 2b44dae14f5..2822c43a599 100644 --- a/client/web/src/search/results/export/searchResultsExport.test.ts +++ b/client/web/src/search/results/export/searchResultsExport.test.ts @@ -1404,7 +1404,7 @@ describe('searchResultsToFileContent', () => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const [, results] = data.find(([searchType]) => searchType === 'repo')! expect(searchResultsToFileContent(results, sourcegraphURL, true)).toEqual( - 'Match type,Repository,Repository external URL,Repository metadata\nrepo,github.com/lorenzodifuccia/safaribooks,http://localhost:3443/github.com/lorenzodifuccia/safaribooks,"oss\ndeprecated\nsome"",non-standard-key:value"\nrepo,github.com/rfletcher/safari-json-formatter,http://localhost:3443/github.com/rfletcher/safari-json-formatter,\nrepo,github.com/AdguardTeam/AdGuardForSafari,http://localhost:3443/github.com/AdguardTeam/AdGuardForSafari,\nrepo,github.com/kishikawakatsumi/SourceKitForSafari,http://localhost:3443/github.com/kishikawakatsumi/SourceKitForSafari,\nrepo,github.com/shaojiankui/iOS-UDID-Safari,http://localhost:3443/github.com/shaojiankui/iOS-UDID-Safari,' + 'Match type,Repository,Repository external URL,Repository metadata,Repository metadata JSON\nrepo,github.com/lorenzodifuccia/safaribooks,http://localhost:3443/github.com/lorenzodifuccia/safaribooks,"oss\ndeprecated\nsome"",non-standard-key:value","{""oss"":null,""deprecated"":null,""some\\"",non-standard-key"":""value""}"\nrepo,github.com/rfletcher/safari-json-formatter,http://localhost:3443/github.com/rfletcher/safari-json-formatter,,{}\nrepo,github.com/AdguardTeam/AdGuardForSafari,http://localhost:3443/github.com/AdguardTeam/AdGuardForSafari,,{}\nrepo,github.com/kishikawakatsumi/SourceKitForSafari,http://localhost:3443/github.com/kishikawakatsumi/SourceKitForSafari,,{}\nrepo,github.com/shaojiankui/iOS-UDID-Safari,http://localhost:3443/github.com/shaojiankui/iOS-UDID-Safari,,{}' ) }) }) diff --git a/client/web/src/search/results/export/searchResultsExport.ts b/client/web/src/search/results/export/searchResultsExport.ts index 36aa02d998a..4a1c7d4a2f4 100644 --- a/client/web/src/search/results/export/searchResultsExport.ts +++ b/client/web/src/search/results/export/searchResultsExport.ts @@ -117,7 +117,7 @@ export const searchResultsToFileContent = ( case 'repo': { content = [ - enableRepositoryMetadata ? [...headers, 'Repository metadata'] : headers, + enableRepositoryMetadata ? [...headers, 'Repository metadata', 'Repository metadata JSON'] : headers, ...searchResults .filter((result: SearchMatch): result is RepositoryMatch => result.type === 'repo') .map(result => [ @@ -131,6 +131,19 @@ export const searchResultsToFileContent = ( .join('\n'), ] : []), + ...(enableRepositoryMetadata + ? [ + JSON.stringify( + Object.entries(result.metadata ?? {}).reduce( + (obj: { [key: string]: string | null }, [key, value]) => { + obj[key] = value ?? null + return obj + }, + {} + ) + ), + ] + : []), ]), ] break