From 41d35fdafda541f9cb87a6a04d598782e2017c42 Mon Sep 17 00:00:00 2001 From: Brooooooklyn Date: Mon, 2 Sep 2024 10:08:16 +0000 Subject: [PATCH] ci: skip generating changelog if prev commit is not found (#8045) --- tools/changelog/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/changelog/index.js b/tools/changelog/index.js index 7220d6e7e2..8431315674 100644 --- a/tools/changelog/index.js +++ b/tools/changelog/index.js @@ -89,8 +89,16 @@ const content = await readFile(join(rootDir, pkgJsonPath), 'utf8'); const { dependencies } = JSON.parse(content); const blocksuiteVersion = dependencies['@blocksuite/block-std']; -const previousPkgJsonBlob = repo - .findCommit(PREV_VERSION) +const prevCommit = repo.findCommit(PREV_VERSION); + +if (!prevCommit) { + console.info( + `Can't find prev commit ${PREV_VERSION} on the git tree, skip the changelog generation` + ); + process.exit(0); +} + +const previousPkgJsonBlob = prevCommit .tree() .getPath(pkgJsonPath) .toObject(repo)