Пример #1
0
    def exclusion_note(self, metrics_in_error: dict, git: GitUtils, logger: Logger):
        logger.info('Please consult the above warnings and errors concerning discrepancies in your build compared to '
                    'latest build.')
        answer = input('Do you want to accept the violations (Yes/No)? [No]: ')
        if not answer.upper() == 'YES':
            logger.info('I am treating this as a No (you typed: "%s").' % answer)
            logger.error('Failing because of metrics increase.')
            return Callable.do_not_proceed

        reason = ''
        while not reason.strip():
            reason = input('Provide a nonempty commit message (reason) for the increase [""]: ')

        username = '******' % (git.get_config_by_key('user.name'), git.get_config_by_key('user.email'))
        metrics = {}
        for key, value in metrics_in_error.items():
            metrics[key] = value['is']
        exclusion = {'reason': reason,
                     'committer': username,
                     'exclusion': metrics}

        note = JSONEncoder().encode(exclusion)

        if git.put_notes(note, STATS_EXCLUSION_REF_NAME, 'HEAD') != Callable.success:
            logger.error('Error encountered while setting note. Consult above messages if any.')
            return Callable.do_not_proceed

        if git.push_notes(STATS_EXCLUSION_REF_NAME) != Callable.success:
            logger.error('Error encountered while pushing notes. Consult above messages if any.')
            return Callable.do_not_proceed

        logger.info('The exclusion note has been pushed.')
        logger.warn('Remember to push your commit. DO NOT rebase (use merge instead) or the exclusion will be lost.')

        return Callable.success
Пример #2
0
    def exclusion_note(self, metrics_in_error: dict, git: GitUtils,
                       logger: Logger):
        logger.info(
            'Please consult the above warnings and errors concerning discrepancies in your build compared to '
            'latest build.')
        answer = input('Do you want to accept the violations (Yes/No)? [No]: ')
        if not answer.upper() == 'YES':
            logger.info('I am treating this as a No (you typed: "%s").' %
                        answer)
            logger.error('Failing because of metrics increase.')
            return Callable.do_not_proceed

        reason = ''
        while not reason.strip():
            reason = input(
                'Provide a nonempty commit message (reason) for the increase [""]: '
            )

        username = '******' % (git.get_config_by_key('user.name'),
                                git.get_config_by_key('user.email'))
        metrics = {}
        for key, value in metrics_in_error.items():
            metrics[key] = value['is']
        exclusion = {
            'reason': reason,
            'committer': username,
            'exclusion': metrics
        }

        note = JSONEncoder().encode(exclusion)

        if git.put_notes(note, STATS_EXCLUSION_REF_NAME,
                         'HEAD') != Callable.success:
            logger.error(
                'Error encountered while setting note. Consult above messages if any.'
            )
            return Callable.do_not_proceed

        if git.push_notes(STATS_EXCLUSION_REF_NAME) != Callable.success:
            logger.error(
                'Error encountered while pushing notes. Consult above messages if any.'
            )
            return Callable.do_not_proceed

        logger.info('The exclusion note has been pushed.')
        logger.warn(
            'Remember to push your commit. DO NOT rebase (use merge instead) or the exclusion will be lost.'
        )

        return Callable.success