##// END OF EJS Templates
api: expose owner to create_pull_request API. Fixes #5537
marcink -
r3474:e9c81a05 default
parent child Browse files
Show More
@@ -26,7 +26,7 b' from rhodecode.api import jsonrpc_method'
26 26 from rhodecode.api.utils import (
27 27 has_superadmin_permission, Optional, OAttr, get_repo_or_error,
28 28 get_pull_request_or_error, get_commit_or_error, get_user_or_error,
29 validate_repo_permissions, resolve_ref_or_error)
29 validate_repo_permissions, resolve_ref_or_error, validate_set_owner_permissions)
30 30 from rhodecode.lib.auth import (HasRepoPermissionAnyApi)
31 31 from rhodecode.lib.base import vcs_operation_context
32 32 from rhodecode.lib.utils2 import str2bool
@@ -614,8 +614,8 b' def comment_pull_request('
614 614 @jsonrpc_method()
615 615 def create_pull_request(
616 616 request, apiuser, source_repo, target_repo, source_ref, target_ref,
617 title=Optional(''), description=Optional(''), description_renderer=Optional(''),
618 reviewers=Optional(None)):
617 owner=Optional(OAttr('apiuser')), title=Optional(''), description=Optional(''),
618 description_renderer=Optional(''), reviewers=Optional(None)):
619 619 """
620 620 Creates a new pull request.
621 621
@@ -636,6 +636,8 b' def create_pull_request('
636 636 :type source_ref: str
637 637 :param target_ref: Set the target ref name.
638 638 :type target_ref: str
639 :param owner: user_id or username
640 :type owner: Optional(str)
639 641 :param title: Optionally Set the pull request title, it's generated otherwise
640 642 :type title: str
641 643 :param description: Set the pull request description.
@@ -659,6 +661,8 b' def create_pull_request('
659 661 _perms = ('repository.admin', 'repository.write', 'repository.read',)
660 662 validate_repo_permissions(apiuser, source_repo, source_db_repo, _perms)
661 663
664 owner = validate_set_owner_permissions(apiuser, owner)
665
662 666 full_source_ref = resolve_ref_or_error(source_ref, source_db_repo)
663 667 full_target_ref = resolve_ref_or_error(target_ref, target_db_repo)
664 668
@@ -704,7 +708,7 b' def create_pull_request('
704 708
705 709 # recalculate reviewers logic, to make sure we can validate this
706 710 reviewer_rules = get_default_reviewers_data(
707 apiuser.get_instance(), source_db_repo,
711 owner, source_db_repo,
708 712 source_commit, target_db_repo, target_commit)
709 713
710 714 # now MERGE our given with the calculated
@@ -731,7 +735,7 b' def create_pull_request('
731 735 description_renderer = Optional.extract(description_renderer) or default_system_renderer
732 736
733 737 pull_request = PullRequestModel().create(
734 created_by=apiuser.user_id,
738 created_by=owner.user_id,
735 739 source_repo=source_repo,
736 740 source_ref=full_source_ref,
737 741 target_repo=target_repo,
General Comments 0
You need to be logged in to leave comments. Login now