Show More
@@ -31,7 +31,7 b' from rhodecode.lib.base import vcs_opera' | |||
|
31 | 31 | from rhodecode.lib.utils2 import str2bool |
|
32 | 32 | from rhodecode.model.changeset_status import ChangesetStatusModel |
|
33 | 33 | from rhodecode.model.comment import CommentsModel |
|
34 | from rhodecode.model.db import Session, ChangesetStatus | |
|
34 | from rhodecode.model.db import Session, ChangesetStatus, ChangesetComment | |
|
35 | 35 | from rhodecode.model.pull_request import PullRequestModel, MergeCheck |
|
36 | 36 | from rhodecode.model.settings import SettingsModel |
|
37 | 37 | |
@@ -360,10 +360,11 b' def close_pull_request(request, apiuser,' | |||
|
360 | 360 | |
|
361 | 361 | |
|
362 | 362 | @jsonrpc_method() |
|
363 | def comment_pull_request(request, apiuser, repoid, pullrequestid, | |
|
364 | message=Optional(None), status=Optional(None), | |
|
365 |
|
|
|
366 | userid=Optional(OAttr('apiuser'))): | |
|
363 | def comment_pull_request( | |
|
364 | request, apiuser, repoid, pullrequestid, message=Optional(None), | |
|
365 | commit_id=Optional(None), status=Optional(None), | |
|
366 | comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE), | |
|
367 | userid=Optional(OAttr('apiuser'))): | |
|
367 | 368 | """ |
|
368 | 369 | Comment on the pull request specified with the `pullrequestid`, |
|
369 | 370 | in the |repo| specified by the `repoid`, and optionally change the |
@@ -375,19 +376,18 b' def comment_pull_request(request, apiuse' | |||
|
375 | 376 | :type repoid: str or int |
|
376 | 377 | :param pullrequestid: The pull request ID. |
|
377 | 378 | :type pullrequestid: int |
|
378 | :param message: The text content of the comment. | |
|
379 | :type message: str | |
|
380 | :param status: (**Optional**) Set the approval status of the pull | |
|
381 | request. Valid options are: | |
|
382 | * not_reviewed | |
|
383 | * approved | |
|
384 | * rejected | |
|
385 | * under_review | |
|
386 | :type status: str | |
|
387 | 379 | :param commit_id: Specify the commit_id for which to set a comment. If |
|
388 | 380 | given commit_id is different than latest in the PR status |
|
389 | 381 | change won't be performed. |
|
390 | 382 | :type commit_id: str |
|
383 | :param message: The text content of the comment. | |
|
384 | :type message: str | |
|
385 | :param status: (**Optional**) Set the approval status of the pull | |
|
386 | request. One of: 'not_reviewed', 'approved', 'rejected', | |
|
387 | 'under_review' | |
|
388 | :type status: str | |
|
389 | :param comment_type: Comment type, one of: 'note', 'todo' | |
|
390 | :type comment_type: Optional(str), default: 'note' | |
|
391 | 391 | :param userid: Comment on the pull request as this user |
|
392 | 392 | :type userid: Optional(str or int) |
|
393 | 393 | |
@@ -421,6 +421,7 b' def comment_pull_request(request, apiuse' | |||
|
421 | 421 | message = Optional.extract(message) |
|
422 | 422 | status = Optional.extract(status) |
|
423 | 423 | commit_id = Optional.extract(commit_id) |
|
424 | comment_type = Optional.extract(comment_type) | |
|
424 | 425 | |
|
425 | 426 | if not message and not status: |
|
426 | 427 | raise JSONRPCError( |
@@ -466,7 +467,8 b' def comment_pull_request(request, apiuse' | |||
|
466 | 467 | status_change=(status_label if status_change else None), |
|
467 | 468 | status_change_type=(status if status_change else None), |
|
468 | 469 | closing_pr=False, |
|
469 | renderer=renderer | |
|
470 | renderer=renderer, | |
|
471 | comment_type=comment_type | |
|
470 | 472 | ) |
|
471 | 473 | |
|
472 | 474 | if allowed_to_change_status and status: |
@@ -36,7 +36,8 b' from rhodecode.lib.ext_json import json' | |||
|
36 | 36 | from rhodecode.model.changeset_status import ChangesetStatusModel |
|
37 | 37 | from rhodecode.model.comment import CommentsModel |
|
38 | 38 | from rhodecode.model.db import ( |
|
39 |
Session, ChangesetStatus, RepositoryField, Repository, RepoGroup |
|
|
39 | Session, ChangesetStatus, RepositoryField, Repository, RepoGroup, | |
|
40 | ChangesetComment) | |
|
40 | 41 | from rhodecode.model.repo import RepoModel |
|
41 | 42 | from rhodecode.model.scm import ScmModel, RepoList |
|
42 | 43 | from rhodecode.model.settings import SettingsModel, VcsSettingsModel |
@@ -1382,8 +1383,9 b' def lock(request, apiuser, repoid, locke' | |||
|
1382 | 1383 | |
|
1383 | 1384 | @jsonrpc_method() |
|
1384 | 1385 | def comment_commit( |
|
1385 | request, apiuser, repoid, commit_id, message, | |
|
1386 | userid=Optional(OAttr('apiuser')), status=Optional(None)): | |
|
1386 | request, apiuser, repoid, commit_id, message, status=Optional(None), | |
|
1387 | comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE), | |
|
1388 | userid=Optional(OAttr('apiuser'))): | |
|
1387 | 1389 | """ |
|
1388 | 1390 | Set a commit comment, and optionally change the status of the commit. |
|
1389 | 1391 | |
@@ -1395,15 +1397,17 b' def comment_commit(' | |||
|
1395 | 1397 | :type commit_id: str |
|
1396 | 1398 | :param message: The comment text. |
|
1397 | 1399 | :type message: str |
|
1400 | :param status: (**Optional**) status of commit, one of: 'not_reviewed', | |
|
1401 | 'approved', 'rejected', 'under_review' | |
|
1402 | :type status: str | |
|
1403 | :param comment_type: Comment type, one of: 'note', 'todo' | |
|
1404 | :type comment_type: Optional(str), default: 'note' | |
|
1398 | 1405 | :param userid: Set the user name of the comment creator. |
|
1399 | 1406 | :type userid: Optional(str or int) |
|
1400 | :param status: status, one of 'not_reviewed', 'approved', 'rejected', | |
|
1401 | 'under_review' | |
|
1402 | :type status: str | |
|
1403 | 1407 | |
|
1404 | 1408 | Example error output: |
|
1405 | 1409 | |
|
1406 |
.. code-block:: |
|
|
1410 | .. code-block:: bash | |
|
1407 | 1411 | |
|
1408 | 1412 | { |
|
1409 | 1413 | "id" : <id_given_in_input>, |
@@ -1426,6 +1430,7 b' def comment_commit(' | |||
|
1426 | 1430 | |
|
1427 | 1431 | user = get_user_or_error(userid) |
|
1428 | 1432 | status = Optional.extract(status) |
|
1433 | comment_type = Optional.extract(comment_type) | |
|
1429 | 1434 | |
|
1430 | 1435 | allowed_statuses = [x[0] for x in ChangesetStatus.STATUSES] |
|
1431 | 1436 | if status and status not in allowed_statuses: |
@@ -1440,7 +1445,9 b' def comment_commit(' | |||
|
1440 | 1445 | message, repo, user, commit_id=commit_id, |
|
1441 | 1446 | status_change=status_change_label, |
|
1442 | 1447 | status_change_type=status, |
|
1443 |
renderer=renderer |
|
|
1448 | renderer=renderer, | |
|
1449 | comment_type=comment_type | |
|
1450 | ) | |
|
1444 | 1451 | if status: |
|
1445 | 1452 | # also do a status change |
|
1446 | 1453 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now