feat: Add support for assigning reviewers and assignees to pull requests
This commit is contained in:
parent
0db5ea7214
commit
44104215a2
|
@ -411,6 +411,8 @@ def handle_issues(args, client, seen_issues_db):
|
||||||
issue_description,
|
issue_description,
|
||||||
issue_number,
|
issue_number,
|
||||||
client,
|
client,
|
||||||
|
reviewers=args.reviewers,
|
||||||
|
assignees=args.assignees,
|
||||||
)
|
)
|
||||||
|
|
||||||
if solved:
|
if solved:
|
||||||
|
|
|
@ -22,6 +22,8 @@ class AiderArgs:
|
||||||
owner: str
|
owner: str
|
||||||
repo: str
|
repo: str
|
||||||
base_branch: str
|
base_branch: str
|
||||||
|
reviewers: list[str] = None
|
||||||
|
assignees: list[str] = None
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
|
@ -54,6 +56,16 @@ def parse_args():
|
||||||
default=300,
|
default=300,
|
||||||
help='Interval in seconds between checks in daemon mode (default: 300)',
|
help='Interval in seconds between checks in daemon mode (default: 300)',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--reviewers',
|
||||||
|
type=str,
|
||||||
|
help='Comma-separated list of usernames to assign as reviewers for pull requests',
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--assignees',
|
||||||
|
type=str,
|
||||||
|
help='Comma-separated list of usernames to assign as assignees for pull requests',
|
||||||
|
)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,11 +84,17 @@ def main():
|
||||||
while True:
|
while True:
|
||||||
logger.info('Checking for new issues...')
|
logger.info('Checking for new issues...')
|
||||||
for repo in repositories:
|
for repo in repositories:
|
||||||
|
# Parse reviewers and assignees from comma-separated strings to lists
|
||||||
|
reviewers = args.reviewers.split(',') if args.reviewers else None
|
||||||
|
assignees = args.assignees.split(',') if args.assignees else None
|
||||||
|
|
||||||
aider_args = AiderArgs(
|
aider_args = AiderArgs(
|
||||||
gitea_url=args.gitea_url,
|
gitea_url=args.gitea_url,
|
||||||
owner=args.owner,
|
owner=args.owner,
|
||||||
repo=repo,
|
repo=repo,
|
||||||
base_branch=args.base_branch,
|
base_branch=args.base_branch,
|
||||||
|
reviewers=reviewers,
|
||||||
|
assignees=assignees,
|
||||||
)
|
)
|
||||||
handle_issues(aider_args, client, seen_issues_db)
|
handle_issues(aider_args, client, seen_issues_db)
|
||||||
del repo
|
del repo
|
||||||
|
|
43
test/test_main_args.py
Normal file
43
test/test_main_args.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import pytest
|
||||||
|
from unittest.mock import patch, MagicMock
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from aider_gitea.__main__ import parse_args
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_args_with_reviewers_and_assignees():
|
||||||
|
"""Test that reviewers and assignees arguments are correctly parsed."""
|
||||||
|
test_args = [
|
||||||
|
'--gitea-url', 'https://gitea.example.com',
|
||||||
|
'--owner', 'test-owner',
|
||||||
|
'--repo', 'test-repo',
|
||||||
|
'--reviewers', 'user1,user2',
|
||||||
|
'--assignees', 'user3,user4'
|
||||||
|
]
|
||||||
|
|
||||||
|
with patch('sys.argv', ['aider_gitea'] + test_args):
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
assert args.gitea_url == 'https://gitea.example.com'
|
||||||
|
assert args.owner == 'test-owner'
|
||||||
|
assert args.repo == 'test-repo'
|
||||||
|
assert args.reviewers == 'user1,user2'
|
||||||
|
assert args.assignees == 'user3,user4'
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_args_without_reviewers_and_assignees():
|
||||||
|
"""Test that the parser works without reviewers and assignees."""
|
||||||
|
test_args = [
|
||||||
|
'--gitea-url', 'https://gitea.example.com',
|
||||||
|
'--owner', 'test-owner',
|
||||||
|
'--repo', 'test-repo'
|
||||||
|
]
|
||||||
|
|
||||||
|
with patch('sys.argv', ['aider_gitea'] + test_args):
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
assert args.gitea_url == 'https://gitea.example.com'
|
||||||
|
assert args.owner == 'test-owner'
|
||||||
|
assert args.repo == 'test-repo'
|
||||||
|
assert args.reviewers is None
|
||||||
|
assert args.assignees is None
|
Loading…
Reference in New Issue
Block a user