From 2d6f3d7df2b5d5b6421d9c61b5ef3b8b44e0c6ba Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Sun, 14 Apr 2024 09:51:39 -0700 Subject: [PATCH] Don't fail on change fail Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- cli/insertBuild.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cli/insertBuild.js b/cli/insertBuild.js index 24bb8d1..6ed1dc3 100644 --- a/cli/insertBuild.js +++ b/cli/insertBuild.js @@ -149,13 +149,19 @@ async function run() { "project": project.value._id, "version": version.value._id }, {sort: {_id: -1}}); - let changes = []; + const changes = []; const lastBuild = previousBuild && previousBuild.changes.length ? previousBuild.changes.slice(0, 1)[0].commit : "HEAD^1"; - const commits = gitlog({ - repo: repositoryPath, - fields: ["hash", "subject", "rawBody"], - branch: lastBuild + "...HEAD" - }); + const commits = []; + try { + commits = gitlog({ + repo: repositoryPath, + fields: ["hash", "subject", "rawBody"], + branch: lastBuild + "...HEAD" + }); + } catch (error) { + // Likely failed due to history be broken by a force push + commits = []; + } commits.forEach(function (commit) { changes.push({ "commit": commit.hash,