Skip to content

Commit

Permalink
Use RTD environment variables instead of html_context
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
sciencewhiz committed Nov 11, 2024
1 parent 1dd3e2c commit a1c43e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sphinxext/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def on_rtd() -> bool:

def on_pr(html_context: Dict[str, str]) -> bool:
return (
html_context["github_version"].startswith(html_context["commit"])
html_context["github_version"].startswith(
os.environ.get("READTHEDOCS_GIT_COMMIT_HASH")[:8]
)
or os.getenv("GITHUB_EVENT_NAME") == "pull_request"
)

Expand All @@ -47,7 +49,7 @@ def inject_changed_files(html_context: Dict[str, str], app: Sphinx) -> None:
import requests

res = requests.get(
f"https://api.github.com/repos/{html_context['github_user']}/{html_context['github_repo']}/pulls/{html_context['current_version']}/files"
f"https://api.github.com/repos/{html_context['github_user']}/{html_context['github_repo']}/pulls/{os.environ.get('READTHEDOCS_VERSION_NAME')}/files"
)

if res.status_code != requests.codes.ok:
Expand Down

0 comments on commit a1c43e3

Please sign in to comment.