@@ -172,10 +172,36 @@ def get_repo_file_url(
172172 return f"{ github_host } /{ repository } /{ part } /{ branch } { path } " .rstrip ("/" )
173173
174174
175- def get_html_report_url (github_host : str , repository : str , branch : str ) -> str :
175+ def get_html_report_url (
176+ github_host : str ,
177+ repository : str ,
178+ branch : str ,
179+ use_gh_pages_html_url : bool = False ,
180+ ) -> str :
181+ """
182+ Computes the URL for an HTML report:
183+ - If use_gh_pages_html_url is True:
184+ * GitHub.com => https://<user_or_org>.github.io/<repo>/<pages_path>
185+ * GitHub Enterprise => https://<host>/pages/<user_or_org>/<repo>/<pages_path>
186+ - If use_gh_pages_html_url is False:
187+ * GitHub.com => https://htmlpreview.github.io/?<readme_url>
188+ * GitHub Enterprise => <readme_url>
189+ """
190+ html_report_path = "htmlcov/index.html"
176191 readme_url = get_repo_file_url (
177- github_host , repository = repository , branch = branch , path = "/htmlcov/index.html"
192+ github_host , repository = repository , branch = branch , path = html_report_path
178193 )
194+
179195 if github_host .endswith ("github.com" ):
180- return f"https://htmlpreview.github.io/?{ readme_url } "
196+ if use_gh_pages_html_url :
197+ user , repo = repository .split ("/" , 1 )
198+ return f"https://{ user } .github.io/{ repo } /{ html_report_path } "
199+ else :
200+ return f"https://htmlpreview.github.io/?{ readme_url } "
201+ else :
202+ # Assume GitHub Enterprise
203+ if use_gh_pages_html_url :
204+ return f"{ github_host } /pages/{ repository } /{ html_report_path } "
205+
206+ # Always fallback to the raw readme_url
181207 return readme_url
0 commit comments