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