Show More
@@ -364,6 +364,7 b' def comment_pull_request(' | |||||
364 | request, apiuser, repoid, pullrequestid, message=Optional(None), |
|
364 | request, apiuser, repoid, pullrequestid, message=Optional(None), | |
365 | commit_id=Optional(None), status=Optional(None), |
|
365 | commit_id=Optional(None), status=Optional(None), | |
366 | comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE), |
|
366 | comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE), | |
|
367 | resolves_comment_id=Optional(None), | |||
367 | userid=Optional(OAttr('apiuser'))): |
|
368 | userid=Optional(OAttr('apiuser'))): | |
368 | """ |
|
369 | """ | |
369 | Comment on the pull request specified with the `pullrequestid`, |
|
370 | Comment on the pull request specified with the `pullrequestid`, | |
@@ -422,6 +423,7 b' def comment_pull_request(' | |||||
422 | status = Optional.extract(status) |
|
423 | status = Optional.extract(status) | |
423 | commit_id = Optional.extract(commit_id) |
|
424 | commit_id = Optional.extract(commit_id) | |
424 | comment_type = Optional.extract(comment_type) |
|
425 | comment_type = Optional.extract(comment_type) | |
|
426 | resolves_comment_id = Optional.extract(resolves_comment_id) | |||
425 |
|
427 | |||
426 | if not message and not status: |
|
428 | if not message and not status: | |
427 | raise JSONRPCError( |
|
429 | raise JSONRPCError( | |
@@ -446,6 +448,17 b' def comment_pull_request(' | |||||
446 | if commit_idx != 0: |
|
448 | if commit_idx != 0: | |
447 | allowed_to_change_status = False |
|
449 | allowed_to_change_status = False | |
448 |
|
450 | |||
|
451 | if resolves_comment_id: | |||
|
452 | comment = ChangesetComment.get(resolves_comment_id) | |||
|
453 | if not comment: | |||
|
454 | raise JSONRPCError( | |||
|
455 | 'Invalid resolves_comment_id `%s` for this pull request.' | |||
|
456 | % resolves_comment_id) | |||
|
457 | if comment.comment_type != ChangesetComment.COMMENT_TYPE_TODO: | |||
|
458 | raise JSONRPCError( | |||
|
459 | 'Comment `%s` is wrong type for setting status to resolved.' | |||
|
460 | % resolves_comment_id) | |||
|
461 | ||||
449 | text = message |
|
462 | text = message | |
450 | status_label = ChangesetStatus.get_status_lbl(status) |
|
463 | status_label = ChangesetStatus.get_status_lbl(status) | |
451 | if status and allowed_to_change_status: |
|
464 | if status and allowed_to_change_status: | |
@@ -468,7 +481,8 b' def comment_pull_request(' | |||||
468 | status_change_type=(status if status_change else None), |
|
481 | status_change_type=(status if status_change else None), | |
469 | closing_pr=False, |
|
482 | closing_pr=False, | |
470 | renderer=renderer, |
|
483 | renderer=renderer, | |
471 | comment_type=comment_type |
|
484 | comment_type=comment_type, | |
|
485 | resolves_comment_id=resolves_comment_id | |||
472 | ) |
|
486 | ) | |
473 |
|
487 | |||
474 | if allowed_to_change_status and status: |
|
488 | if allowed_to_change_status and status: |
@@ -1385,6 +1385,7 b' def lock(request, apiuser, repoid, locke' | |||||
1385 | def comment_commit( |
|
1385 | def comment_commit( | |
1386 | request, apiuser, repoid, commit_id, message, status=Optional(None), |
|
1386 | request, apiuser, repoid, commit_id, message, status=Optional(None), | |
1387 | comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE), |
|
1387 | comment_type=Optional(ChangesetComment.COMMENT_TYPE_NOTE), | |
|
1388 | resolves_comment_id=Optional(None), | |||
1388 | userid=Optional(OAttr('apiuser'))): |
|
1389 | userid=Optional(OAttr('apiuser'))): | |
1389 | """ |
|
1390 | """ | |
1390 | Set a commit comment, and optionally change the status of the commit. |
|
1391 | Set a commit comment, and optionally change the status of the commit. | |
@@ -1431,12 +1432,24 b' def comment_commit(' | |||||
1431 | user = get_user_or_error(userid) |
|
1432 | user = get_user_or_error(userid) | |
1432 | status = Optional.extract(status) |
|
1433 | status = Optional.extract(status) | |
1433 | comment_type = Optional.extract(comment_type) |
|
1434 | comment_type = Optional.extract(comment_type) | |
|
1435 | resolves_comment_id = Optional.extract(resolves_comment_id) | |||
1434 |
|
1436 | |||
1435 | allowed_statuses = [x[0] for x in ChangesetStatus.STATUSES] |
|
1437 | allowed_statuses = [x[0] for x in ChangesetStatus.STATUSES] | |
1436 | if status and status not in allowed_statuses: |
|
1438 | if status and status not in allowed_statuses: | |
1437 | raise JSONRPCError('Bad status, must be on ' |
|
1439 | raise JSONRPCError('Bad status, must be on ' | |
1438 | 'of %s got %s' % (allowed_statuses, status,)) |
|
1440 | 'of %s got %s' % (allowed_statuses, status,)) | |
1439 |
|
1441 | |||
|
1442 | if resolves_comment_id: | |||
|
1443 | comment = ChangesetComment.get(resolves_comment_id) | |||
|
1444 | if not comment: | |||
|
1445 | raise JSONRPCError( | |||
|
1446 | 'Invalid resolves_comment_id `%s` for this commit.' | |||
|
1447 | % resolves_comment_id) | |||
|
1448 | if comment.comment_type != ChangesetComment.COMMENT_TYPE_TODO: | |||
|
1449 | raise JSONRPCError( | |||
|
1450 | 'Comment `%s` is wrong type for setting status to resolved.' | |||
|
1451 | % resolves_comment_id) | |||
|
1452 | ||||
1440 | try: |
|
1453 | try: | |
1441 | rc_config = SettingsModel().get_all_settings() |
|
1454 | rc_config = SettingsModel().get_all_settings() | |
1442 | renderer = rc_config.get('rhodecode_markup_renderer', 'rst') |
|
1455 | renderer = rc_config.get('rhodecode_markup_renderer', 'rst') | |
@@ -1446,7 +1459,8 b' def comment_commit(' | |||||
1446 | status_change=status_change_label, |
|
1459 | status_change=status_change_label, | |
1447 | status_change_type=status, |
|
1460 | status_change_type=status, | |
1448 | renderer=renderer, |
|
1461 | renderer=renderer, | |
1449 | comment_type=comment_type |
|
1462 | comment_type=comment_type, | |
|
1463 | resolves_comment_id=resolves_comment_id | |||
1450 | ) |
|
1464 | ) | |
1451 | if status: |
|
1465 | if status: | |
1452 | # also do a status change |
|
1466 | # also do a status change |
General Comments 0
You need to be logged in to leave comments.
Login now