From ff015db062d8300d4b240de6a95e07b9af6ec959 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Thu, 5 Oct 2023 15:11:45 +0330 Subject: [PATCH] reformat: gh_refs_path changed to get_github_refs_path instead of only returning heads or tags, and appending it to a GitHub url, the function now accepts an owner and a name and return the full refs path --- tutormfe/plugin.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tutormfe/plugin.py b/tutormfe/plugin.py index ddd77d3..ce18177 100644 --- a/tutormfe/plugin.py +++ b/tutormfe/plugin.py @@ -24,64 +24,64 @@ } -# If the package version suffix is set (for instance, in the nightly branch) use the "heads" Github refs API endpoint by default. -def gh_refs_path() -> str: - return "heads" if __version_suffix__ else "tags" +def get_github_refs_path(name: str) -> str: + """ + Generate a URL to access refs in heads (nightly) or tags (stable) via Github API. + Args: + name (str): Consisted of the repository owner and the repository name, as a string in 'owner/repo' format. + + Returns: + str: A string URL to the Github API, pointing to heads if version_suffix is set, tags otherwise. + + """ + + return f"https://api.github.com/repos/{name}/git/refs/{'heads' if __version_suffix__ else 'tags'}" CORE_MFE_APPS: dict[str, MFE_ATTRS_TYPE] = { "authn": { "repository": "https://github.com/openedx/frontend-app-authn", - "refs": "https://api.github.com/repos/openedx/frontend-app-authn/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-authn"), "port": 1999, }, "account": { "repository": "https://github.com/openedx/frontend-app-account", - "refs": "https://api.github.com/repos/openedx/frontend-app-account/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-account"), "port": 1997, }, "communications": { "repository": "https://github.com/openedx/frontend-app-communications", - "refs": "https://api.github.com/repos/openedx/frontend-app-communications/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-communications"), "port": 1984, }, "course-authoring": { "repository": "https://github.com/openedx/frontend-app-course-authoring", - "refs": "https://api.github.com/repos/openedx/frontend-app-course-authoring/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-course-authoring"), "port": 2001, }, "discussions": { "repository": "https://github.com/openedx/frontend-app-discussions", - "refs": "https://api.github.com/repos/openedx/frontend-app-discussions/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-discussions"), "port": 2002, }, "gradebook": { "repository": "https://github.com/openedx/frontend-app-gradebook", - "refs": "https://api.github.com/repos/openedx/frontend-app-gradebook/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-gradebook"), "port": 1994, }, "learning": { "repository": "https://github.com/openedx/frontend-app-learning", - "refs": "https://api.github.com/repos/openedx/frontend-app-learning/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-learning"), "port": 2000, }, "ora-grading": { "repository": "https://github.com/openedx/frontend-app-ora-grading", - "refs": "https://api.github.com/repos/openedx/frontend-app-ora-grading/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-ora-grading"), "port": 1993, }, "profile": { "repository": "https://github.com/openedx/frontend-app-profile", - "refs": "https://api.github.com/repos/openedx/frontend-app-profile/git/refs/" - + gh_refs_path(), + "refs": get_github_refs_path("openedx/frontend-app-profile"), "port": 1995, }, }