Esempio n. 1
0
    def get_template_data(self):
        """Extract templated data from an issue body"""

        if self.is_issue():
            tfile = '.github/ISSUE_TEMPLATE.md'
        else:
            tfile = '.github/PULL_REQUEST_TEMPLATE.md'

        tf = self.repo.get_file_contents(tfile)
        tf_content = tf.decoded_content
        tf_sections = extract_template_sections(tf_content)

        self._required_template_sections = \
            [x.lower() for x in tf_sections.keys()
             if tf_sections[x]['required']]

        template_data = \
            extract_template_data(
                self.instance.body,
                issue_number=self.number,
                issue_class=self.github_type,
                SECTIONS=tf_sections.keys()
            )

        return template_data
Esempio n. 2
0
    def get_template_data(self):
        """Extract templated data from an issue body"""

        if not self.template_data:
            self.template_data = \
                extract_template_data(
                    self.instance.body,
                    issue_number=self.number,
                    issue_class=self.github_type
                )
        return self.template_data
Esempio n. 3
0
    def get_template_data(self):
        """Extract templated data from an issue body"""

        if self.instance.pull_request:
            issue_class = 'pullrequest'
        else:
            issue_class = 'issue'

        if not self.template_data:
            self.template_data = \
                extract_template_data(self.instance.body, issue_number=self.number, issue_class=issue_class)
        return self.template_data
Esempio n. 4
0
    def test_module_matching(self):

        print('')

        AT = AnsibleTriage(args={})

        jfile = 'tests/fixtures/issue_template_meta.json'
        with open(jfile, 'rb') as f:
            jdata = json.load(f)

        keys = sorted([int(x) for x in jdata.keys()])

        for key in keys:

            k = str(key)
            v = jdata[k]

            if '/pull/' in v['html_url']:
                continue

            print(v['html_url'])

            # extract fields from the body
            td = extract_template_data(
                v['body'],
                issue_number=key,
                issue_class=None
            )

            # schema tests
            assert isinstance(td, dict)
            assert 'component_raw' in td
            assert 'component name' in td

            # confirm the raw converted to the component name
            assert td['component_raw'] == v['component_raw']
            assert td['component name'] == v['component_name']

            # confirm module matching works.
            mm = AT.find_module_match(v['title'], td)
            if v['module_match']:
                if mm is None:
                    import epdb; epdb.st()
                elif mm['filepath'] != v['module_match'] and \
                        mm['name'] != v['module_match']:
                    import epdb; epdb.st()
            elif mm is not None:
                import epdb; epdb.st()
    def test_component_matching(self):

        print('')

        AT = AnsibleTriage(args={})
        AT.file_indexer.get_files()

        jfile = 'tests/fixtures/issue_template_meta.json'
        with open(jfile, 'rb') as f:
            jdata = json.load(f)

        keys = sorted([int(x) for x in jdata.keys()])

        for key in keys:

            k = str(key)
            v = jdata[k]

            if '/pull/' in v['html_url']:
                continue

            if not v.get('labels'):
                continue

            if 'module' in v['labels']:
                continue

            clabels = [x for x in v['labels'] if x.startswith('c:')]
            #if not clabels:
            #    continue

            print(v['html_url'])

            # extract fields from the body
            td = extract_template_data(v['body'],
                                       issue_number=key,
                                       issue_class=None)

            components = AT.file_indexer.find_component_match(
                v['title'], v['body'], td)
            if components and clabels:
                comp_labels = AT.file_indexer.get_component_labels(
                    AT.valid_labels, components)
                print('\t' + str(comp_labels))
Esempio n. 6
0
 def get_template_data(self):
     """Extract templated data from an issue body"""
     if not self.template_data:
         self.template_data = \
             extract_template_data(self.instance.body, issue_number=self.number)
     return self.template_data