##// END OF EJS Templates
api: pull-requests allow automatic title generation via API
marcink -
r2871:4a62bdfc default
parent child Browse files
Show More
@@ -44,7 +44,6 b' class TestCreatePullRequestApi(object):'
44 'target_repo': 'tests/target_repo',
44 'target_repo': 'tests/target_repo',
45 'source_ref': 'branch:default:initial',
45 'source_ref': 'branch:default:initial',
46 'target_ref': 'branch:default:new-feature',
46 'target_ref': 'branch:default:new-feature',
47 'title': 'Test PR 1'
48 }
47 }
49 for key in required_data:
48 for key in required_data:
50 data = required_data.copy()
49 data = required_data.copy()
@@ -574,7 +574,7 b' def comment_pull_request('
574 @jsonrpc_method()
574 @jsonrpc_method()
575 def create_pull_request(
575 def create_pull_request(
576 request, apiuser, source_repo, target_repo, source_ref, target_ref,
576 request, apiuser, source_repo, target_repo, source_ref, target_ref,
577 title, description=Optional(''), reviewers=Optional(None)):
577 title=Optional(''), description=Optional(''), reviewers=Optional(None)):
578 """
578 """
579 Creates a new pull request.
579 Creates a new pull request.
580
580
@@ -595,7 +595,7 b' def create_pull_request('
595 :type source_ref: str
595 :type source_ref: str
596 :param target_ref: Set the target ref name.
596 :param target_ref: Set the target ref name.
597 :type target_ref: str
597 :type target_ref: str
598 :param title: Set the pull request title.
598 :param title: Optionally Set the pull request title, it's generated otherwise
599 :type title: str
599 :type title: str
600 :param description: Set the pull request description.
600 :param description: Set the pull request description.
601 :type description: Optional(str)
601 :type description: Optional(str)
@@ -666,6 +666,15 b' def create_pull_request('
666 except ValueError as e:
666 except ValueError as e:
667 raise JSONRPCError('Reviewers Validation: {}'.format(e))
667 raise JSONRPCError('Reviewers Validation: {}'.format(e))
668
668
669 title = Optional.extract(title)
670 if not title:
671 title_source_ref = source_ref.split(':', 2)[1]
672 title = PullRequestModel().generate_pullrequest_title(
673 source=source_repo,
674 source_ref=title_source_ref,
675 target=target_repo
676 )
677
669 pull_request = PullRequestModel().create(
678 pull_request = PullRequestModel().create(
670 created_by=apiuser.user_id,
679 created_by=apiuser.user_id,
671 source_repo=source_repo,
680 source_repo=source_repo,
@@ -676,6 +685,7 b' def create_pull_request('
676 reviewers=reviewers,
685 reviewers=reviewers,
677 title=title,
686 title=title,
678 description=Optional.extract(description),
687 description=Optional.extract(description),
688 reviewer_data=reviewer_rules,
679 auth_user=apiuser
689 auth_user=apiuser
680 )
690 )
681
691
General Comments 0
You need to be logged in to leave comments. Login now