MCPcopy Index your code
hub / github.com/fastapi/fastapi / main

Function main

scripts/contributors.py:238–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

236
237
238def main() -> None:
239 logging.basicConfig(level=logging.INFO)
240 settings = Settings() # ty: ignore[missing-argument]
241 logging.info(f"Using config: {settings.model_dump_json()}")
242 g = Github(settings.github_token.get_secret_value())
243 repo = g.get_repo(settings.github_repository)
244
245 pr_nodes = get_pr_nodes(settings=settings)
246 contributors_results = get_contributors(pr_nodes=pr_nodes)
247 authors = contributors_results.authors
248
249 top_contributors = get_users_to_write(
250 counter=contributors_results.contributors,
251 authors=authors,
252 )
253
254 top_translators = get_users_to_write(
255 counter=contributors_results.translators,
256 authors=authors,
257 )
258 top_translations_reviewers = get_users_to_write(
259 counter=contributors_results.translation_reviewers,
260 authors=authors,
261 )
262
263 # For local development
264 # contributors_path = Path("../docs/en/data/contributors.yml")
265 contributors_path = Path("./docs/en/data/contributors.yml")
266 # translators_path = Path("../docs/en/data/translators.yml")
267 translators_path = Path("./docs/en/data/translators.yml")
268 # translation_reviewers_path = Path("../docs/en/data/translation_reviewers.yml")
269 translation_reviewers_path = Path("./docs/en/data/translation_reviewers.yml")
270
271 updated = [
272 update_content(content_path=contributors_path, new_content=top_contributors),
273 update_content(content_path=translators_path, new_content=top_translators),
274 update_content(
275 content_path=translation_reviewers_path,
276 new_content=top_translations_reviewers,
277 ),
278 ]
279
280 if not any(updated):
281 logging.info("The data hasn't changed, finishing.")
282 return
283
284 logging.info("Setting up GitHub Actions git user")
285 subprocess.run(["git", "config", "user.name", "github-actions[bot]"], check=True)
286 subprocess.run(
287 ["git", "config", "user.email", "github-actions[bot]@users.noreply.github.com"],
288 check=True,
289 )
290 branch_name = f"fastapi-people-contributors-{secrets.token_hex(4)}"
291 logging.info(f"Creating a new branch {branch_name}")
292 subprocess.run(["git", "checkout", "-b", branch_name], check=True)
293 logging.info("Adding updated file")
294 subprocess.run(
295 [

Callers 1

contributors.pyFile · 0.70

Calls 6

get_pr_nodesFunction · 0.85
get_contributorsFunction · 0.85
SettingsClass · 0.70
get_users_to_writeFunction · 0.70
update_contentFunction · 0.70
PathClass · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…