Skip to content

Commit 5705c19

Browse files
committed
Tighten the checks
1 parent b413cb8 commit 5705c19

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

index.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ async function mergeIfLGTMAndHasAccess() {
124124
}
125125
}
126126

127+
/**
128+
*
129+
* @param {string} owner
130+
* @param {string[]} files
131+
* @param {string} cwd
132+
*/
127133
function getFilesNotOwnedByCodeOwner(owner, files, cwd) {
128134
const filesWhichArentOwned = []
129135
const codeowners = new Codeowners(cwd);
@@ -139,6 +145,11 @@ function getFilesNotOwnedByCodeOwner(owner, files, cwd) {
139145
return filesWhichArentOwned
140146
}
141147

148+
/**
149+
*
150+
* @param {string[]} files
151+
* @param {string} cwd
152+
*/
142153
function listFilesWithOwners(files, cwd) {
143154
const codeowners = new Codeowners(cwd);
144155
console.log("\nKnown code-owners for changed files:")
@@ -181,8 +192,6 @@ async function getPRChangedFiles(octokit, repoDeets, prNumber) {
181192
return fileStrings
182193
}
183194

184-
185-
186195
async function createOrAddLabel(octokit, repoDeets, labelConfig) {
187196
let label = null
188197
const existingLabels = await octokit.paginate('GET /repos/:owner/:repo/labels', { owner: repoDeets.owner, repo: repoDeets.repo })
@@ -207,10 +216,6 @@ async function createOrAddLabel(octokit, repoDeets, labelConfig) {
207216
})
208217
}
209218

210-
process.on('uncaughtException', function (error) {
211-
core.setFailed(error.message)
212-
})
213-
214219
module.exports = {
215220
getFilesNotOwnedByCodeOwner,
216221
findCodeOwnersForChangedFiles
@@ -225,3 +230,11 @@ if (!module.parent) {
225230
throw error
226231
}
227232
}
233+
234+
// Bail correctly
235+
process.on('uncaughtException', function (err) {
236+
core.setFailed(err.message)
237+
console.error((new Date).toUTCString() + ' uncaughtException:', err.message)
238+
console.error(err.stack)
239+
process.exit(1)
240+
})

node_modules/codeowners/codeowners.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)