Show More
@@ -45,7 +45,7 b' from rhodecode.lib.auth import (' | |||
|
45 | 45 | from rhodecode.lib.channelstream import channelstream_request |
|
46 | 46 | from rhodecode.lib.utils import jsonify |
|
47 | 47 | from rhodecode.lib.utils2 import safe_int, safe_str, str2bool, safe_unicode |
|
48 | from rhodecode.lib.vcs.backends.base import EmptyCommit | |
|
48 | from rhodecode.lib.vcs.backends.base import EmptyCommit, UpdateFailureReason | |
|
49 | 49 | from rhodecode.lib.vcs.exceptions import ( |
|
50 | 50 | EmptyRepositoryError, CommitDoesNotExistError, RepositoryRequirementError) |
|
51 | 51 | from rhodecode.lib.diffs import LimitedDiffContainer |
@@ -518,60 +518,54 b' class PullrequestsController(BaseRepoCon' | |||
|
518 | 518 | return |
|
519 | 519 | |
|
520 | 520 | def _update_commits(self, pull_request): |
|
521 | try: | |
|
522 | if PullRequestModel().has_valid_update_type(pull_request): | |
|
523 | updated_version, changes = PullRequestModel().update_commits( | |
|
524 | pull_request) | |
|
525 | if updated_version: | |
|
526 | msg = _( | |
|
527 | u'Pull request updated to "{source_commit_id}" with ' | |
|
528 | u'{count_added} added, {count_removed} removed ' | |
|
529 | u'commits.' | |
|
530 |
|
|
|
531 | source_commit_id=pull_request.source_ref_parts.commit_id, | |
|
532 | count_added=len(changes.added), | |
|
533 | count_removed=len(changes.removed)) | |
|
534 | h.flash(msg, category='success') | |
|
535 | registry = get_current_registry() | |
|
536 | rhodecode_plugins = getattr(registry, | |
|
537 | 'rhodecode_plugins', {}) | |
|
538 | channelstream_config = rhodecode_plugins.get( | |
|
539 | 'channelstream', {}) | |
|
540 | if channelstream_config.get('enabled'): | |
|
541 | message = msg + ' - <a onclick="' \ | |
|
542 | 'window.location.reload()">' \ | |
|
543 | '<strong>{}</strong></a>'.format( | |
|
544 | _('Reload page') | |
|
545 | ) | |
|
546 |
|
|
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
|
550 |
|
|
|
551 |
|
|
|
552 |
|
|
|
553 |
|
|
|
554 |
|
|
|
555 |
|
|
|
556 |
|
|
|
557 |
|
|
|
558 |
|
|
|
559 |
|
|
|
560 |
|
|
|
561 |
|
|
|
562 | '/message', raise_exc=False) | |
|
563 |
|
|
|
564 | h.flash(_("Nothing changed in pull request."), | |
|
565 | category='warning') | |
|
566 | else: | |
|
567 | msg = _( | |
|
568 | u"Skipping update of pull request due to reference " | |
|
569 | u"type: {reference_type}" | |
|
570 | ).format(reference_type=pull_request.source_ref_parts.type) | |
|
571 | h.flash(msg, category='warning') | |
|
572 | except CommitDoesNotExistError: | |
|
573 | h.flash( | |
|
574 | _(u'Update failed due to missing commits.'), category='error') | |
|
521 | resp = PullRequestModel().update_commits(pull_request) | |
|
522 | msg = PullRequestModel.UPDATE_STATUS_MESSAGES[resp.reason] | |
|
523 | ||
|
524 | # Abort if pull request update failed. | |
|
525 | if not resp.success: | |
|
526 | h.flash(msg, category='error') | |
|
527 | return | |
|
528 | ||
|
529 | if resp.reason == UpdateFailureReason.NONE: | |
|
530 | msg = _( | |
|
531 | u'Pull request updated to "{source_commit_id}" with ' | |
|
532 | u'{count_added} added, {count_removed} removed commits.') | |
|
533 | msg = msg.format( | |
|
534 | source_commit_id=pull_request.source_ref_parts.commit_id, | |
|
535 | count_added=len(resp.changes.added), | |
|
536 | count_removed=len(resp.changes.removed)) | |
|
537 | h.flash(msg, category='success') | |
|
538 | ||
|
539 | registry = get_current_registry() | |
|
540 | rhodecode_plugins = getattr(registry, 'rhodecode_plugins', {}) | |
|
541 | channelstream_config = rhodecode_plugins.get('channelstream', {}) | |
|
542 | if channelstream_config.get('enabled'): | |
|
543 | message = msg + ( | |
|
544 | ' - <a onclick="window.location.reload()">' | |
|
545 | '<strong>{}</strong></a>'.format(_('Reload page'))) | |
|
546 | channel = '/repo${}$/pr/{}'.format( | |
|
547 | pull_request.target_repo.repo_name, | |
|
548 | pull_request.pull_request_id | |
|
549 | ) | |
|
550 | payload = { | |
|
551 | 'type': 'message', | |
|
552 | 'user': 'system', | |
|
553 | 'exclude_users': [request.user.username], | |
|
554 | 'channel': channel, | |
|
555 | 'message': { | |
|
556 | 'message': message, | |
|
557 | 'level': 'success', | |
|
558 | 'topic': '/notifications' | |
|
559 | } | |
|
560 | } | |
|
561 | channelstream_request( | |
|
562 | channelstream_config, [payload], '/message', | |
|
563 | raise_exc=False) | |
|
564 | elif resp.reason == UpdateFailureReason.NO_CHANGE: | |
|
565 | # Display a warning if no update is needed. | |
|
566 | h.flash(msg, category='warning') | |
|
567 | else: | |
|
568 | h.flash(msg, category='error') | |
|
575 | 569 | |
|
576 | 570 | @auth.CSRFRequired() |
|
577 | 571 | @LoginRequired() |
General Comments 0
You need to be logged in to leave comments.
Login now