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 6, 2023
1 parent 0c8bad5 commit df74770
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions tutormfe/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,64 +24,65 @@
}


# 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(owner: str, name: str) -> str:
"""
Generate a URL to access refs in heads (nightly) or tags (stable) via Github API.
Args:
owner (str): The name of the Github repository owner, as a string in 'owner' format.
name (str): The name of the Github repository, as a string in 'repo' format.
Returns:
str: A string URL to the Github API, pointing to heads if version_suffix is set, tags otherwise.
"""
url = f"https://api.github.com/repos/{owner}/{name}/git/refs/"
return url + "heads" if __version_suffix__ else url + "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 df74770

Please sign in to comment.