Skip to content

Commit

Permalink
utils: do not make unnecessary request to addons GitHub repository if…
Browse files Browse the repository at this point in the history
… addon path is None (#3571)

---------

Co-authored-by: Tomas Zigo <tomas.zigo@slovanet.sk>
  • Loading branch information
mmacata and tmszi committed Apr 12, 2024
1 parent d327df2 commit 20a7620
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions utils/mkhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,26 @@ def get_git_commit_from_rest_api_for_addon_repo(
# Accessed date time if getting commit from GitHub REST API wasn't successful
if not git_log:
git_log = get_default_git_log(src_dir=src_dir)
grass_addons_url = (
"https://api.github.com/repos/osgeo/grass-addons/commits?"
"path={path}&page=1&per_page=1&sha=grass{major}".format(
path=addon_path,
major=major,
)
) # sha=git_branch_name

response = download_git_commit(
url=grass_addons_url,
response_format="application/json",
)
if response:
commit = json.loads(response.read())
if commit:
git_log["commit"] = commit[0]["sha"]
git_log["date"] = format_git_commit_date_from_rest_api(
commit_datetime=commit[0]["commit"]["author"]["date"],
if addon_path is not None:
grass_addons_url = (
"https://api.github.com/repos/osgeo/grass-addons/commits?"
"path={path}&page=1&per_page=1&sha=grass{major}".format(
path=addon_path,
major=major,
)
) # sha=git_branch_name

response = download_git_commit(
url=grass_addons_url,
response_format="application/json",
)
if response:
commit = json.loads(response.read())
if commit:
git_log["commit"] = commit[0]["sha"]
git_log["date"] = format_git_commit_date_from_rest_api(
commit_datetime=commit[0]["commit"]["author"]["date"],
)
return git_log


Expand Down

0 comments on commit 20a7620

Please sign in to comment.