From eb4e31a9d6c5900436ba2a964f8e4937691f098a Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Thu, 4 May 2023 11:57:00 +0200 Subject: [PATCH 1/2] fix(scripts-update-release-notes): properly handle git for-each-ref cmd call to not fail release notes update --- .../update-release-notes/changelogsAndTags.ts | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/scripts/update-release-notes/changelogsAndTags.ts b/scripts/update-release-notes/changelogsAndTags.ts index 624df52d93afed..d3d079db389cc2 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,44 @@ export function getTagToChangelogMap(maxAgeDays?: number): Map tag.split(' -- ')) - .filter(arr => arr.length === 2); + 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); + 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) { + throw new Error(`maxBuffer ${TEN_MEGABYTES}MB was reached. Increase its size in the codebase`); + } } /** From b5d3082fdb52ee4eaed6f31b818f86dcae5fe447 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Thu, 4 May 2023 15:51:43 +0200 Subject: [PATCH 2/2] fixup! fix(scripts-update-release-notes): properly handle git for-each-ref cmd call to not fail release notes update --- scripts/update-release-notes/changelogsAndTags.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/update-release-notes/changelogsAndTags.ts b/scripts/update-release-notes/changelogsAndTags.ts index d3d079db389cc2..b5268e52b4a629 100644 --- a/scripts/update-release-notes/changelogsAndTags.ts +++ b/scripts/update-release-notes/changelogsAndTags.ts @@ -87,7 +87,11 @@ export function getTags(maxAgeDays?: number): string[] { return tags; } catch (err) { - throw new Error(`maxBuffer ${TEN_MEGABYTES}MB was reached. Increase its size in the codebase`); + if (err.code === 'ENOBUFS') { + throw new Error(`maxBuffer ${TEN_MEGABYTES}MB was reached. Increase its size in the codebase`); + } + + throw err; } }