From 2de642a117dc0ef59893d2adccb0fd0bae4a5e13 Mon Sep 17 00:00:00 2001 From: Linus Hagemann Date: Tue, 27 Aug 2024 17:58:25 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A4=EF=B8=8F:=20gracefully=20skip?= =?UTF-8?q?=20deletion=20of=20non-existing=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lively.git/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lively.git/index.js b/lively.git/index.js index 552adf2409..24f40c6e9e 100644 --- a/lively.git/index.js +++ b/lively.git/index.js @@ -97,7 +97,6 @@ export class GitHubAPIWrapper { } static async deleteDeployKey (repoOwner, repoName, title) { - // TODO: If this is called with a non-existing key bad things happen! const resKeyList = await fetch(`https://api.github.com/repos/${repoOwner}/${repoName}/keys`, { method: 'GET', headers: { @@ -106,9 +105,13 @@ export class GitHubAPIWrapper { } }); const deployKeys = await resKeyList.json(); + + // Should allow us to catch all cases where no keys are found in which case we do not have to delete anythings + if (!deployKeys.find) return; + const keyIdToRemove = deployKeys.find(key => key.title === title).id; - const resKeyDeletion = await fetch(`https://api.github.com/repos/${repoOwner}/${repoName}/keys/${keyIdToRemove}`, { + await fetch(`https://api.github.com/repos/${repoOwner}/${repoName}/keys/${keyIdToRemove}`, { method: 'DELETE', headers: { Authorization: `Bearer ${currentUserToken()}`, From c395341c4775d917ac4f35782c59fbd99806979f Mon Sep 17 00:00:00 2001 From: Linus Hagemann Date: Tue, 27 Aug 2024 17:58:58 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=82:=20skip=20deploy=20key=20gener?= =?UTF-8?q?ation=20for=20public=20repositories?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lively.project/project.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lively.project/project.js b/lively.project/project.js index c765c6d6b0..e6c6767ce4 100644 --- a/lively.project/project.js +++ b/lively.project/project.js @@ -469,6 +469,8 @@ export class Project { for (let i = 0; i < dependencies.length; i++) { const dep = dependencies[i]; + if (!dep.privateRepo) continue; + const normalizedDep = normalizedDeps[i]; if (alreadySetupDependencies.includes(normalizedDep)) continue; const [priv, pub] = await generateKeyPair();