Ejemplo n.º 1
0
    def diff_file_type(self, changes, patches, from_sha, to_sha):
        for i in xrange(len(changes)):
            changes[i]['patch'] = patches[i]
            name = changes[i]['filename']
            ext_name = splitext(name)[1]
            changes[i]['binary'] = False
            if ext_name in NOT_GENERATED:
                if name.endswith(MINIFIED):
                    changes[i]['generated'] = True
                else:
                    changes[i]['generated'] = False
            elif ext_name in IS_GENERATED:
                changes[i]['generated'] = True
            elif ext_name in IGNORE_FILE_EXTS:
                changes[i]['binary'] = True
                changes[i]['generated'] = False
            else:
                if changes[i]['change'] in ['D', 'C', 'R', 'T']:
                    cat_ref = from_sha
                else:
                    cat_ref = to_sha

                def _get_data():
                    try:
                        data = self.cat('%s:%s' % (
                            cat_ref, name))
                    except:  # very first commit ??
                        data = ''
                    return data
                changes[i]['generated'] = Generated.is_generated(
                    name, _get_data)
        return changes
Ejemplo n.º 2
0
    def diff_file_type(self, changes, patches, from_sha, to_sha):
        for i in xrange(len(changes)):
            changes[i]['patch'] = patches[i]
            name = changes[i]['filename']
            ext_name = splitext(name)[1]
            changes[i]['binary'] = False
            if ext_name in NOT_GENERATED:
                if name.endswith(MINIFIED):
                    changes[i]['generated'] = True
                else:
                    changes[i]['generated'] = False
            elif ext_name in IS_GENERATED:
                changes[i]['generated'] = True
            elif ext_name in IGNORE_FILE_EXTS:
                changes[i]['binary'] = True
                changes[i]['generated'] = False
            else:
                if changes[i]['change'] in ['D', 'C', 'R', 'T']:
                    cat_ref = from_sha
                else:
                    cat_ref = to_sha

                def _get_data():
                    try:
                        data = self.cat('%s:%s' % (cat_ref, name))
                    except:  # very first commit ??
                        data = ''
                    return data

                changes[i]['generated'] = Generated.is_generated(
                    name, _get_data)
        return changes
Ejemplo n.º 3
0
    def generated(self):
        # FIXME: generated 性能问题
        if self._generated is not None:
            return self._generated

        def get_data():
            data = ''
            try:
                if self.status == 'D':
                    blob = self.repo.get_file(self.old_sha, self.old_file_path)
                else:
                    blob = self.repo.get_file(self.new_sha, self.new_file_path)
                if blob:
                    data = blob.data
            except:  # very first commit ??
                data = ''
            return data

        generated = Generated.is_generated(self.new_file_path, get_data)
        self._generated = generated
        return generated
Ejemplo n.º 4
0
    def generated(self):
        # FIXME: generated 性能问题
        if self._generated is not None:
            return self._generated

        def get_data():
            data = ""
            try:
                if self.status == "D":
                    blob = self.repo.get_file(self.old_sha, self.old_file_path)
                else:
                    blob = self.repo.get_file(self.new_sha, self.new_file_path)
                if blob:
                    data = blob.data
            except:  # very first commit ??
                data = ""
            return data

        generated = Generated.is_generated(self.new_file_path, get_data)
        self._generated = generated
        return generated