Exemple #1
0
def create_codereview_if_neccessary_message(request, issue):
    """Create a message with a link to create patchset if it's necessary for the issue.

    If there are pushes after latest patchset, it's necessary to create another patchset to reflect the full set
    of changes.
    """
    case_id = get_case_id(issue)
    _, case_title, original_branch, feature_branch, ci_project = get_fogbugz_case_info(case_id)

    if feature_branch and original_branch:
        source_vcs, source_url, source_revision, source_branch_is_local, _ = parse_branch_vcs_info(
            feature_branch, settings.FEATURE_BRANCH_DEFAULT_PREFIX)
        if os.path.isdir(source_url):
            source = GuessVCS(
                attrdict({'revision': source_revision, 'vcs': source_vcs}), source_url)

            source_revision = source.CheckRevision().strip()

            if issue.latest_patch_rev != source_revision:
                messages_api.warning(
                    request, 'There are commits after the latest created patchset. '
                    'Please create a <a href="{0}?case={1}">new one</a>'.format(
                        reverse('process_from_fogbugz'),
                        case_id
                    )
                )
    return ''
Exemple #2
0
    def get_results(self, request, term, page, context):
        """Get the list of possible target branch(es)."""
        case_id = self.kwargs['case_id']
        _, case_title, original_branch, feature_branch, ci_project, target_branch = views.get_fogbugz_case_info(
            request, case_id)

        target_vcs, target_url, target_revision, target_branch_is_local, _ = views.parse_branch_vcs_info(
            original_branch, settings.ORIGINAL_BRANCH_DEFAULT_PREFIX)

        branches = []
        if os.path.isdir(target_url):
            target = GuessVCS(
                views.attrdict({'revision': target_revision, 'vcs': target_vcs}), target_url)
            try:
                branches = target.GetBranches()
            except Exception:
                # could be not yet supported by VCS
                pass

        if settings.CODEREVIEW_TARGET_BRANCH_CHOICES_GETTER:
            choices = settings.CODEREVIEW_TARGET_BRANCH_CHOICES_GETTER(
                ci_project, target_revision, target_branch, branches)
        else:
            choices = []
        return (NO_ERR_RESP, False, choices)  # Any error response, Has more results, options list
Exemple #3
0
def create_codereview_if_neccessary_message(request, issue):
    """Create a message with a link to create patchset if it's necessary for the issue.

    If there are pushes after latest patchset, it's necessary to create another patchset to reflect the full set
    of changes.
    """
    case_id = get_case_id(issue)
    _, case_title, original_branch, feature_branch, ci_project, target_branch = get_fogbugz_case_info(
        request, case_id)

    if feature_branch and original_branch:
        source_vcs, source_url, source_revision, source_branch_is_local, _ = parse_branch_vcs_info(
            feature_branch, settings.FEATURE_BRANCH_DEFAULT_PREFIX)
        if os.path.isdir(source_url):
            source = GuessVCS(
                attrdict({
                    'revision': source_revision,
                    'vcs': source_vcs
                }), source_url)

            try:
                source_revision = source.CheckRevision().strip()
            except RuntimeError:
                return ''

            if issue.latest_patch_rev != source_revision:
                messages_api.warning(
                    request,
                    'There are commits after the latest created patchset. '
                    'Please create a <a href="{0}?case={1}">new one</a>'.
                    format(reverse('process_from_fogbugz'), case_id))
    return ''
Exemple #4
0
    def get_results(self, request, term, page, context):
        """Get the list of possible target branch(es)."""
        case_id = self.kwargs['case_id']
        _, case_title, original_branch, feature_branch, ci_project, target_branch = views.get_fogbugz_case_info(
            request, case_id)

        target_vcs, target_url, target_revision, target_branch_is_local, _ = views.parse_branch_vcs_info(
            original_branch, settings.ORIGINAL_BRANCH_DEFAULT_PREFIX)

        branches = []
        if os.path.isdir(target_url):
            target = GuessVCS(
                views.attrdict({
                    'revision': target_revision,
                    'vcs': target_vcs
                }), target_url)
            try:
                branches = target.GetBranches()
            except Exception:
                # could be not yet supported by VCS
                pass

        if settings.CODEREVIEW_TARGET_BRANCH_CHOICES_GETTER:
            choices = settings.CODEREVIEW_TARGET_BRANCH_CHOICES_GETTER(
                ci_project, target_revision, target_branch, branches)
        else:
            choices = []
        return (NO_ERR_RESP, False, choices
                )  # Any error response, Has more results, options list