From 6a19310bda56e6003dadffeb77042e2a662193f2 Mon Sep 17 00:00:00 2001 From: James Forbes Date: Sun, 9 Jan 2022 14:02:06 +1100 Subject: [PATCH] Fix crash when there is only one release (#241) --- .vscode/launch.json | 30 ++++++++++++++++++++++++++++++ lib/index.js | 3 ++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 4f3afe0..c03c46f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -21,6 +21,22 @@ "skipFiles": [ "/**" ], + "cwd": "/home/james/src/harth/sum-type", + "args": ["pr"], + "program": "${workspaceFolder}/bin.js" + }, + { + "type": "pwa-node", + "request": "launch", + "name": "sum-type:pr", + "skipFiles": [ + "/**" + ], + "cwd": "/home/james/src/harth/sum-type", + "env": { + "GITHUB_REPOSITORY":"JAForbes/sum-type" + }, + "envFile": "${workspaceFolder}/.env", "args": ["pr"], "program": "${workspaceFolder}/bin.js" }, @@ -74,6 +90,20 @@ "args": ["merge", "--commit", "--target", "main", "--source", "next", "--verbose", "--force", "--clean", "--changelog", "--compact"], "program": "${workspaceFolder}/bin.js" }, + { + "type": "pwa-node", + "request": "launch", + "name": "sum-type:merge --commit", + "skipFiles": [ + "/**" + ], + "env": { + "GITHUB_REPOSITORY":"JAForbes/sum-type" + }, + "envFile": "${workspaceFolder}/.env", + "args": ["merge", "--commit", "--target", "main", "--source", "next", "--verbose", "--force", "--clean", "--changelog", "--compact"], + "program": "${workspaceFolder}/bin.js" + }, { "type": "pwa-node", "request": "launch", diff --git a/lib/index.js b/lib/index.js index 43cc1cb..4c779ad 100644 --- a/lib/index.js +++ b/lib/index.js @@ -309,8 +309,9 @@ async function extractChangelog(options){ let recentBranches; { let firstEverRelease = a == null; + let onlyOneRelease = b == null - let q = firstEverRelease + let q = firstEverRelease || onlyOneRelease ? `base:${source} is:pr is:merged repo:${owner}/${repo}` : `merged:${a.closed_at}..${b.closed_at} base:${source} is:pr is:merged repo:${owner}/${repo}`