@@ -63,31 +63,26 @@ def check_javascript_files(self):
63
63
f"{ missing_files } are present in coverage reports, but missing from the repository"
64
64
)
65
65
66
- def upload_phabricator (self , report , use_local_clone = True ):
67
- phabricatorUploader = PhabricatorUploader ( self . repo_dir , self . revision )
68
-
69
- # Build HGMO config according to this repo's configuration
66
+ def get_hgmo_changesets (self , use_local_clone = True ):
67
+ """
68
+ Build HGMO changesets according to this repo's configuration
69
+ """
70
70
hgmo_config = {}
71
71
if use_local_clone :
72
72
hgmo_config ["repo_dir" ] = self .repo_dir
73
73
else :
74
74
hgmo_config ["server_address" ] = self .repository
75
75
76
76
with hgmo .HGMO (** hgmo_config ) as hgmo_server :
77
- changesets = hgmo_server .get_automation_relevance_changesets (self .revision )
78
-
79
- if not any (
80
- parse_revision_id (changeset ["desc" ]) is not None for changeset in changesets
81
- ):
82
- logger .info (
83
- "None of the commits in the try push are linked to a Phabricator revision"
84
- )
85
- return
77
+ return hgmo_server .get_automation_relevance_changesets (self .revision )
86
78
79
+ def upload_phabricator (self , report , changesets ):
80
+ """
81
+ Helper to upload coverage report on Phabricator
82
+ """
83
+ phabricatorUploader = PhabricatorUploader (self .repo_dir , self .revision )
87
84
logger .info ("Upload changeset coverage data to Phabricator" )
88
- coverage = phabricatorUploader .upload (report , changesets )
89
-
90
- return changesets , coverage
85
+ return phabricatorUploader .upload (report , changesets )
91
86
92
87
93
88
class MozillaCentralHook (RepositoryHook ):
@@ -140,7 +135,8 @@ def run(self):
140
135
logger .info ("Uploaded all covdir reports" , nb = len (reports ))
141
136
142
137
# Upload coverage on phabricator
143
- changesets , coverage = self .upload_phabricator (report )
138
+ changesets = self .get_hgmo_changesets ()
139
+ coverage = self .upload_phabricator (report , changesets )
144
140
145
141
# Send an email on low coverage
146
142
notify_email (self .revision , changesets , coverage )
@@ -164,6 +160,16 @@ def __init__(self, *args, **kwargs):
164
160
)
165
161
166
162
def run (self ):
163
+ changesets = self .get_hgmo_changesets (use_local_clone = False )
164
+
165
+ if not any (
166
+ parse_revision_id (changeset ["desc" ]) is not None for changeset in changesets
167
+ ):
168
+ logger .info (
169
+ "None of the commits in the try push are linked to a Phabricator revision"
170
+ )
171
+ return
172
+
167
173
self .retrieve_source_and_artifacts ()
168
174
169
175
reports = self .build_reports (only = [("all" , "all" )])
@@ -175,7 +181,7 @@ def run(self):
175
181
report = json .load (open (full_path ))
176
182
177
183
# Upload coverage on phabricator
178
- self .upload_phabricator (report , use_local_clone = False )
184
+ self .upload_phabricator (report , changesets )
179
185
180
186
181
187
def main ():
0 commit comments