Skip to content

Commit

Permalink
reformat: gh_refs_path changed to get_github_refs_path
Browse files Browse the repository at this point in the history
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
  • Loading branch information
CodeWithEmad committed Oct 23, 2023
1 parent 05e84ae commit ff015db
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions tutormfe/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand Down

0 comments on commit ff015db

Please sign in to comment.