Skip to content

Commit

Permalink
refactor: simplify complex f-string
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Apr 10, 2024
1 parent 59baa91 commit 35383ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ Changelog
.. scriv-start-here
Unreleased
----------

- GitHub Enterprise is supported via ``GITHUB_SERVER_URL`` and
``GITHUB_API_URL`` environment variables.
Thanks, `Colin Marquardt <pull 21_>`_.

- Fix: in unusual cases, GitHub can return strange statuses for job steps.
Those are now displayed as question marks.

.. _pull 21: https://github.com/nedbat/watchgha/pull/21


2.2.2 – 2024-02-03
------------------

Expand Down
6 changes: 4 additions & 2 deletions src/watchgha/watch_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,16 @@ def gha_urls(repo, branch, sha):
# repo_url = "https://github.com/owner/repo.git"
# repo_url = "[email protected]:someorg/somerepo.git"
# see also https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
server_url = os.getenv("GITHUB_SERVER_URL", "https://github.com")
repo_match = re.fullmatch(
rf"(?:{os.getenv('GITHUB_SERVER_URL', 'https://github.com')}/|[email protected]:)([^/]+/[^/]+?)(?:\.git|/)?",
rf"(?:{re.escape(server_url)}/|[email protected]:)([^/]+/[^/]+?)(?:\.git|/)?",
repo_url,
)
if repo_match is None:
continue

url = f"{os.getenv('GITHUB_API_URL', 'https://api.github.com')}/repos/{repo_match[1]}/actions/runs?{url_args}"
api_url = os.getenv("GITHUB_API_URL", "https://api.github.com")
url = f"{api_url}/repos/{repo_match[1]}/actions/runs?{url_args}"
github_urls.append(url)

if not github_urls:
Expand Down

0 comments on commit 35383ac

Please sign in to comment.