Exemplo n.º 1
0
def get_changelog(old_version, new_version, filename='CHANGELOG'):
    old_zipfile, new_zipfile = get_zipfiles(old_version, new_version)
    oldlines, newlines = grab_lines(old_zipfile, filename), grab_lines(new_zipfile, filename)
    chunks = get_chunks(oldlines, newlines)

    contents = []
    for chunk in chunks:
        if chunk['operation'] != 'insert':
            continue

        content = '\n'.join(newlines[line['newindex']] for line in chunk['lines'])
        contents.append(content)

    return '\n\n'.join(contents)
Exemplo n.º 2
0
def ajax_get_file_diff_view(request, version):
    filename = request.GET['filename']

    file_base, file_extension = os.path.splitext(filename)
    if file_extension in IMAGE_TYPES:
        return None

    if file_extension in BINARY_TYPES:
        return None

    old_zipfile, new_zipfile = get_zipfiles(get_old_version(version), version)
    oldlines, newlines = grab_lines(old_zipfile, filename), grab_lines(new_zipfile, filename)

    chunks = list(get_chunks(oldlines, newlines))
    return dict(chunks=chunks,
                oldlines=oldlines,
                newlines=newlines)