FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
core/script/hassfest/codeowners.py at dev · phireside/core · GitHub
phireside
/
core
Public
forked from
home-assistant/core
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
core
/
script
/
hassfest
/
codeowners.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (65 loc) · 2.55 KB
Breadcrumbs
core
/
script
/
hassfest
/
codeowners.py
Copy path
File metadata and controls
89 lines (65 loc) · 2.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""Generate CODEOWNERS."""
from
__future__
import
annotations
from
.
model
import
Config
,
Integration
BASE
=
"""
# This file is generated by script/hassfest/codeowners.py
# People marked here will be automatically requested for a review
# when the code that they own is touched.
# https://github.com/blog/2392-introducing-code-owners
# Home Assistant Core
setup.py @home-assistant/core
homeassistant/*.py @home-assistant/core
homeassistant/helpers/* @home-assistant/core
homeassistant/util/* @home-assistant/core
# Home Assistant Supervisor
build.json @home-assistant/supervisor
machine/* @home-assistant/supervisor
rootfs/* @home-assistant/supervisor
Dockerfile @home-assistant/supervisor
# Other code
homeassistant/scripts/check_config.py @kellerza
# Integrations
"""
.
strip
()
INDIVIDUAL_FILES
=
"""
# Individual files
homeassistant/components/demo/weather @fabaff
"""
def
generate_and_validate
(
integrations
:
dict
[
str
,
Integration
],
config
:
Config
):
"""Generate CODEOWNERS."""
parts
=
[
BASE
]
for
domain
in
sorted
(
integrations
):
integration
=
integrations
[
domain
]
if
not
integration
.
manifest
:
continue
codeowners
=
integration
.
manifest
[
"codeowners"
]
if
not
codeowners
:
continue
for
owner
in
codeowners
:
if
not
owner
.
startswith
(
"@"
):
integration
.
add_error
(
"codeowners"
,
"Code owners need to be valid GitHub handles."
)
parts
.
append
(
f"homeassistant/components/
{
domain
}
/*
{
' '
.
join
(
codeowners
)
}
"
)
if
(
config
.
root
/
"tests/components"
/
domain
).
exists
():
parts
.
append
(
f"tests/components/
{
domain
}
/*
{
' '
.
join
(
codeowners
)
}
"
)
parts
.
append
(
f"
\n
{
INDIVIDUAL_FILES
.
strip
()
}
"
)
return
"
\n
"
.
join
(
parts
)
def
validate
(
integrations
:
dict
[
str
,
Integration
],
config
:
Config
):
"""Validate CODEOWNERS."""
codeowners_path
=
config
.
root
/
"CODEOWNERS"
config
.
cache
[
"codeowners"
]
=
content
=
generate_and_validate
(
integrations
,
config
)
if
config
.
specific_integrations
:
return
with
open
(
str
(
codeowners_path
))
as
fp
:
if
fp
.
read
().
strip
()
!=
content
:
config
.
add_error
(
"codeowners"
,
"File CODEOWNERS is not up to date. Run python3 -m script.hassfest"
,
fixable
=
True
,
)
return
def
generate
(
integrations
:
dict
[
str
,
Integration
],
config
:
Config
):
"""Generate CODEOWNERS."""
codeowners_path
=
config
.
root
/
"CODEOWNERS"
with
open
(
str
(
codeowners_path
),
"w"
)
as
fp
:
fp
.
write
(
f"
{
config
.
cache
[
'codeowners'
]
}
\n
"
)
Back
|
FazBrowse Home
|
New Git URL