mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix(resolver): Allow using github.token in Actions and fix base_domain handling (#7934)
This commit is contained in:
parent
0e0f043e59
commit
523c6d03c1
@ -584,6 +584,12 @@ def main() -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Send a pull request to Github or Gitlab.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--selected-repo',
|
||||
type=str,
|
||||
default=None,
|
||||
help='repository to send pull request in form of `owner/repo`.',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--token',
|
||||
type=str,
|
||||
@ -677,7 +683,7 @@ def main() -> None:
|
||||
)
|
||||
username = my_args.username if my_args.username else os.getenv('GIT_USERNAME')
|
||||
|
||||
platform = identify_token(token, None, my_args.base_domain)
|
||||
platform = identify_token(token, my_args.selected_repo, my_args.base_domain)
|
||||
if platform == Platform.INVALID:
|
||||
raise ValueError('Token is invalid.')
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ class Platform(Enum):
|
||||
|
||||
|
||||
def identify_token(
|
||||
token: str, selected_repo: str | None = None, base_domain: str = 'github.com'
|
||||
token: str, selected_repo: str | None = None, base_domain: str | None = 'github.com'
|
||||
) -> Platform:
|
||||
"""
|
||||
Identifies whether a token belongs to GitHub or GitLab.
|
||||
@ -37,7 +37,7 @@ def identify_token(
|
||||
"Invalid" if the token is not recognized by either.
|
||||
"""
|
||||
# Determine GitHub API base URL based on domain
|
||||
if base_domain == 'github.com':
|
||||
if base_domain is None or base_domain == 'github.com':
|
||||
github_api_base = 'https://api.github.com'
|
||||
else:
|
||||
github_api_base = f'https://{base_domain}/api/v3'
|
||||
|
||||
@ -1249,6 +1249,7 @@ def test_main(
|
||||
mock_args.target_branch = None
|
||||
mock_args.reviewer = None
|
||||
mock_args.pr_title = None
|
||||
mock_args.selected_repo = None
|
||||
mock_parser.return_value.parse_args.return_value = mock_args
|
||||
|
||||
# Setup environment variables
|
||||
|
||||
@ -1151,6 +1151,7 @@ def test_main(
|
||||
mock_args.target_branch = None
|
||||
mock_args.reviewer = None
|
||||
mock_args.pr_title = None
|
||||
mock_args.selected_repo = None
|
||||
mock_parser.return_value.parse_args.return_value = mock_args
|
||||
|
||||
# Setup environment variables
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user