def getItemsByVersion(self, _items, _versions):
        _versions.sort(cmp=VersionUtil.cmpVersion)
        version_bugs = dict((ver, list()) for ver in _versions)

        size = len(_versions)
        for idx in range(0, size):
            version = _versions[idx]
            nextVersion = _versions[
                idx +
                1] if idx != size - 1 else u'10000.0'  # assign big. version number

            for bugitem in _items:
                if VersionUtil.cmpVersion(version,
                                          bugitem['version']) > 0 and idx != 0:
                    continue
                if VersionUtil.cmpVersion(bugitem['version'],
                                          nextVersion) >= 0:
                    continue
                version_bugs[version].append(bugitem)

        vKeys = version_bugs.keys()
        for version in vKeys:
            if len(version_bugs[version]) != 0: continue
            del version_bugs[version]

        return version_bugs
Exemple #2
0
    def make_minimumVersion(self, _bugs):
        for bug in _bugs:
            min_version = u'10000.0'  # assign big version
            for version in bug['version'].split(u', '):
                if VersionUtil.cmpVersion(version, min_version) < 0:

                    min_version = version
            bug['version'] = min_version
        pass
    def merge(self, _group, _project, _bugs, _dups):
        merges = []
        bugID = 0
        for src, dup in _dups:
            if src not in _bugs or dup not in _bugs:
                print('passed %s\t%s\t%d\t%d' % (_group, _project, src, dup))
                continue
            bugID += 1
            bug = {}
            bug['id'] = str(bugID)
            bug['master'] = _bugs[src]['id']
            bug['duplicate'] = _bugs[dup]['id']
            bug['summary'] = _bugs[src]['summary'] + u' ' + _bugs[dup][
                'summary']
            bug['description'] = _bugs[src]['description'] + u' ' + _bugs[dup][
                'description']

            verSrc = _bugs[src]['version']
            verDup = _bugs[dup]['version']
            bug['version'] = verSrc if VersionUtil.cmpVersion(
                verSrc, verDup) > 0 else verDup

            verSrc = _bugs[src]['fixedVersion']
            verDup = _bugs[dup]['fixedVersion']
            bug['fixedVersion'] = verSrc if VersionUtil.cmpVersion(
                verSrc, verDup) > 0 else verDup

            bug['resolution'] = _bugs[src]['resolution']
            bug['opendate'] = min(_bugs[src]['opendate'],
                                  _bugs[dup]['opendate'])
            bug['fixdate'] = max(_bugs[src]['fixdate'], _bugs[dup]['fixdate'])
            bug['type'] = _bugs[src]['type']
            bug['fixedFiles'] = _bugs[src]['fixedFiles']
            bug['links'] = _bugs[src]['links'] + _bugs[dup]['links']

            merges.append(bug)
        return merges
Exemple #4
0
    def get_gitversion(self, _id):
        '''
		get bug version information from git repository
		:param _id:
		:return:
		'''
        if _id not in self.gitlogs: return u''

        min_version = u''
        commits = self.gitlogs[_id]
        for commit in commits:
            if commit['hash'] not in self.gitversions: continue
            version = self.gitversions[commit['hash']]
            if version is None: continue
            if min_version == u'': min_version = version
            if VersionUtil.cmpVersion(version, min_version) < 0:
                min_version = version

        return min_version
Exemple #5
0
    def complement_reports(self, _src, _dest, _both):
        '''
		complement information from the duplicate bug report
		:param _bugitems:
		:param _dupgroups:
		:param _gitversions:
		:return:
		'''
        # sync fixedfile
        if _both is False:
            if len(_src['fixedFiles']) == 0:
                _src['fixedFiles'] = _dest['fixedFiles']
                _src['commits'] = _dest['commits']
            else:
                _dest['fixedFiles'] = _src['fixedFiles']
                _dest['commits'] = _src['commits']

        # sync version
        if _dest['version'] != u'' and _src['version'] == u'':
            _src['version'] = _dest['version']
        elif _src['version'] != u'' and _dest['version'] == u'':
            _dest['version'] = _src['version']
        elif _src['version'] == u'' and _dest['version'] == u'':
            #if both report has no version, get version information from git repository
            v1 = self.get_gitversion(_src['id'])
            v2 = self.get_gitversion(_dest['id'])
            if v1 != u'' and v2 != u'':
                if v1 == u'': _src['version'] = v2
                _src['version'] = v1 if VersionUtil.cmpVersion(v1,
                                                               v2) < 0 else v2
                _dest['version'] = _src['version']

        # sync fixdate
        if _dest['fixdate'] != u'' and _src['fixdate'] == u'':
            _src['fixdate'] = _dest['fixdate']
        if _src['fixdate'] != u'' and _dest['fixdate'] == u'':
            _src['fixdate'] = _src['fixdate']

        pass