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