Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Renovate Bot
renovate
Commits
0f9a61e4
Commit
0f9a61e4
authored
4 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
logs: add CODEOWNERS debug
parent
67d862d9
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/workers/pr/code-owners.ts
+11
-1
11 additions, 1 deletion
lib/workers/pr/code-owners.ts
with
11 additions
and
1 deletion
lib/workers/pr/code-owners.ts
+
11
−
1
View file @
0f9a61e4
...
...
@@ -5,6 +5,7 @@ import { readLocalFile } from '../../util/fs';
import
{
getBranchFiles
}
from
'
../../util/git
'
;
export
async
function
codeOwnersForPr
(
pr
:
Pr
):
Promise
<
string
[]
>
{
logger
.
debug
(
'
Searching for CODEOWNERS file
'
);
try
{
const
codeOwnersFile
=
(
await
readLocalFile
(
'
CODEOWNERS
'
,
'
utf8
'
))
||
...
...
@@ -13,9 +14,12 @@ export async function codeOwnersForPr(pr: Pr): Promise<string[]> {
(
await
readLocalFile
(
'
docs/CODEOWNERS
'
,
'
utf8
'
));
if
(
!
codeOwnersFile
)
{
logger
.
debug
(
'
No CODEOWNERS file found
'
);
return
[];
}
logger
.
debug
(
`Found CODEOWNERS file:
${
codeOwnersFile
}
`
);
const
prFiles
=
await
getBranchFiles
(
pr
.
sourceBranch
);
const
rules
=
codeOwnersFile
.
split
(
'
\n
'
)
...
...
@@ -35,11 +39,17 @@ export async function codeOwnersForPr(pr: Pr): Promise<string[]> {
const
matchingRule
=
rules
.
find
((
rule
)
=>
prFiles
?.
every
(
rule
.
match
));
if
(
!
matchingRule
)
{
logger
.
debug
(
'
No matching CODEOWNERS rule found
'
);
return
[];
}
logger
.
debug
(
`CODEOWNERS matched the following usernames:
${
JSON
.
stringify
(
matchingRule
.
usernames
)}
`
);
return
matchingRule
.
usernames
;
}
catch
(
err
)
{
logger
.
warn
({
err
,
pr
},
'
Failed to determine
code owners
for PR.
'
);
logger
.
warn
({
err
,
pr
},
'
Failed to determine
CODEOWNERS
for PR.
'
);
return
[];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment