@@ -6,7 +6,7 @@ const Codeowners = require('codeowners');
6
6
7
7
// Effectively the main function
8
8
async function run ( ) {
9
- console . log ( "Starting with " , context )
9
+ core . info ( "Running version 1.0.1" )
10
10
11
11
// Tell folks they can merge
12
12
if ( context . eventName === "pull_request_target" ) {
@@ -30,10 +30,16 @@ async function commentOnMergablePRs() {
30
30
const pr = context . payload . pull_request
31
31
const thisRepo = { owner : context . repo . owner , repo : context . repo . repo }
32
32
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 ` )
34
34
35
+ const co = new Codeowners ( cwd ) ;
36
+ core . info ( `Codeowners file found at: ${ co . codeownersFilePath } ` )
37
+
35
38
const changedFiles = await getPRChangedFiles ( octokit , thisRepo , pr . number )
39
+ core . info ( `Changed files: \n\n - ${ changedFiles . join ( "\n - " ) } ` )
40
+
36
41
const codeowners = findCodeOwnersForChangedFiles ( changedFiles , cwd )
42
+ core . info ( `Codeowners: \n\n - ${ changedFiles . join ( "\n - " ) } ` )
37
43
38
44
if ( ! codeowners . length ) {
39
45
console . log ( "This PR does not have any code-owners" )
@@ -81,16 +87,16 @@ async function mergeIfLGTMAndHasAccess() {
81
87
process . exit ( 0 )
82
88
}
83
89
84
-
85
90
// Setup
86
91
const cwd = "."
87
92
const octokit = getOctokit ( process . env . GITHUB_TOKEN )
88
93
const thisRepo = { owner : context . repo . owner , repo : context . repo . repo }
89
94
const issue = context . payload . issue || context . payload . pull_request
90
95
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` )
92
97
93
98
const changedFiles = await getPRChangedFiles ( octokit , thisRepo , issue . number )
99
+ core . info ( `Changed files: \n\n - ${ changedFiles . join ( "\n - " ) } ` )
94
100
95
101
const filesWhichArentOwned = getFilesNotOwnedByCodeOwner ( "@" + context . payload . sender . login , changedFiles , cwd )
96
102
if ( filesWhichArentOwned . length !== 0 ) {
@@ -100,6 +106,7 @@ async function mergeIfLGTMAndHasAccess() {
100
106
process . exit ( 0 )
101
107
}
102
108
109
+ core . info ( `Creating comments and merging` )
103
110
await octokit . issues . createComment ( { ...thisRepo , issue_number : issue . number , body : `Merging because @${ issue . user . login } is a code-owner of all the changes - thanks!` } ) ;
104
111
await octokit . pulls . merge ( { ...thisRepo , pull_number : issue . number } ) ;
105
112
}
0 commit comments