Skip to content

Commit 5781965

Browse files
committed
Logs
1 parent d64de8e commit 5781965

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Codeowners = require('codeowners');
66

77
// Effectively the main function
88
async function run() {
9-
console.log("Starting with ", context)
9+
core.info("Running version 1.0.1")
1010

1111
// Tell folks they can merge
1212
if (context.eventName === "pull_request_target") {
@@ -30,10 +30,16 @@ async function commentOnMergablePRs() {
3030
const pr = context.payload.pull_request
3131
const thisRepo = { owner: context.repo.owner, repo: context.repo.repo }
3232

33-
core.info(`\n\nLooking at PR: '${pr.title}' for codeowners`)
33+
core.info(`\n\nLooking at PR: '${pr.title}' to see if the changed files all fit inside one set of codeowners to make a comment`)
3434

35+
const co = new Codeowners(cwd);
36+
core.info(`Codeowners file found at: ${co.codeownersFilePath}`)
37+
3538
const changedFiles = await getPRChangedFiles(octokit, thisRepo, pr.number)
39+
core.info(`Changed files: \n\n - ${changedFiles.join("\n - ")}`)
40+
3641
const codeowners = findCodeOwnersForChangedFiles(changedFiles, cwd)
42+
core.info(`Codeowners: \n\n - ${changedFiles.join("\n - ")}`)
3743

3844
if (!codeowners.length) {
3945
console.log("This PR does not have any code-owners")
@@ -81,16 +87,16 @@ async function mergeIfLGTMAndHasAccess() {
8187
process.exit(0)
8288
}
8389

84-
8590
// Setup
8691
const cwd = "."
8792
const octokit = getOctokit(process.env.GITHUB_TOKEN)
8893
const thisRepo = { owner: context.repo.owner, repo: context.repo.repo }
8994
const issue = context.payload.issue || context.payload.pull_request
9095

91-
core.info(`\n\nLooking at PR: ${issue.title} to see if we can merge`)
96+
core.info(`\n\nLooking at PR: '${issue.title}' to see if we can merge`)
9297

9398
const changedFiles = await getPRChangedFiles(octokit, thisRepo, issue.number)
99+
core.info(`Changed files: \n\n - ${changedFiles.join("\n - ")}`)
94100

95101
const filesWhichArentOwned = getFilesNotOwnedByCodeOwner("@" + context.payload.sender.login, changedFiles, cwd)
96102
if (filesWhichArentOwned.length !== 0) {
@@ -100,6 +106,7 @@ async function mergeIfLGTMAndHasAccess() {
100106
process.exit(0)
101107
}
102108

109+
core.info(`Creating comments and merging`)
103110
await octokit.issues.createComment({ ...thisRepo, issue_number: issue.number, body: `Merging because @${issue.user.login} is a code-owner of all the changes - thanks!` });
104111
await octokit.pulls.merge({ ...thisRepo, pull_number: issue.number });
105112
}

0 commit comments

Comments
 (0)