From e34766b65ea196f02ed94ebbfc937061778a62dd Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 26 Mar 2024 17:10:15 -0700 Subject: [PATCH] improvements --- .github/supersetbot/src/github.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/supersetbot/src/github.js b/.github/supersetbot/src/github.js index ab37e481e3b4c..0bc3e6fb904a2 100644 --- a/.github/supersetbot/src/github.js +++ b/.github/supersetbot/src/github.js @@ -353,20 +353,22 @@ class Github { await runShellCommand({ command: `git push -f origin ${branchName}`, ...shellOptions }); const existingPRs = await this.searchExistingPRs(branchName); if (existingPRs.length === 0) { - // Create a PR - this.octokit.pulls.create({ - ...this.unPackRepo(), - title: commitMessage, - head: branchName, - labels: ['supersetbot'], - base: 'master', - body: `Updates the python "${pythonPackage}" library version. \n\nGenerated by @supersetbot 🦾`, - }) - .then(({ data }) => { - console.log(`Pull request created: ${data.html_url}`); - return data.html_url; + try { + // Create a PR + const resp = await this.octokit.pulls.create({ + ...this.unPackRepo(), + title: commitMessage, + head: branchName, + labels: ['supersetbot'], + base: 'master', + body: `Updates the python "${pythonPackage}" library version. \n\nGenerated by @supersetbot 🦾`, }) - .catch(console.error); + console.log(`Pull request created: ${resp.data.html_url}`); + return resp.data.html_url; + } catch (error) { + console.error(error); + throw error; // Rethrow the error if you want the caller to handle it + } } else { console.log('PR already exists:', existingPRs[0].html_url); }