diff --git a/scripts/update-release-notes/changelogsAndTags.ts b/scripts/update-release-notes/changelogsAndTags.ts index 624df52d93afed..b5268e52b4a629 100644 --- a/scripts/update-release-notes/changelogsAndTags.ts +++ b/scripts/update-release-notes/changelogsAndTags.ts @@ -1,8 +1,10 @@ -import * as path from 'path'; -import * as fs from 'fs-extra'; import { execSync } from 'child_process'; +import * as path from 'path'; + import { ChangelogJson } from 'beachball'; +import * as fs from 'fs-extra'; import { rollup as lernaAliases } from 'lerna-alias'; + import { IChangelogEntry } from './types'; const MILLIS_PER_DAY = 1000 * 60 * 60 * 24; @@ -49,28 +51,48 @@ export function getTagToChangelogMap(maxAgeDays?: number): Map tag.split(' -- ')) - .filter(arr => arr.length === 2); + console.warn(` + 📣 NOTE: "git for-each-ref" current buffer size is ${currentBufferSize}MB. + If this will be more than maxBuffer ${TEN_MEGABYTES}MB this command will fail and you'll have to increase maxBuffer! + `); - if (maxAgeDays) { - const endIndex = tagsAndDates.findIndex(([, date]) => !_isNewEnough(date, maxAgeDays)); - if (endIndex !== -1) { - tagsAndDates = tagsAndDates.slice(0, endIndex); + let tagsAndDates = gitForEachRefBuffer + .toString() + .split(/\r?\n/g) + .map(tag => tag.split(' -- ')) + .filter(arr => arr.length === 2); + + if (maxAgeDays) { + const endIndex = tagsAndDates.findIndex(([, date]) => !_isNewEnough(date, maxAgeDays)); + if (endIndex !== -1) { + tagsAndDates = tagsAndDates.slice(0, endIndex); + } } - } - const tags = tagsAndDates.map(([tag]) => tag); + const tags = tagsAndDates.map(([tag]) => tag); - console.log(`Found ${tags.length} tag(s).\n`); + console.log(`Found ${tags.length} tag(s).\n`); - return tags; + return tags; + } catch (err) { + if (err.code === 'ENOBUFS') { + throw new Error(`maxBuffer ${TEN_MEGABYTES}MB was reached. Increase its size in the codebase`); + } + + throw err; + } } /**