Skip to content

Commit

Permalink
added a better regex to get TOKEN for when gh updates the output
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry McGuinness committed Feb 26, 2025
1 parent cd90dd5 commit 468b7bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ci/scripts/utils/githubpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def __init__(self, repo_url=None, TOKEN=None):
if TOKEN is None:
gh_cli = which('gh')
gh_cli.add_default_arg(['auth', 'status', '--show-token'])
TOKEN = gh_cli(output=str, error=str).split('\n')[3].split(': ')[1]
gh_output = gh_cli(output=str, error=str)
token_match = re.search(r"Token:\s*([a-zA-Z0-9_]+)", gh_output)
if token_match:
TOKEN = token_match.group(1)
else:
raise ValueError("Token not found in gh CLI output.")
super().__init__(TOKEN)

self.repo = self.get_repo_url(repo_url)
Expand Down

0 comments on commit 468b7bc

Please sign in to comment.