[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/getpatchwork/patchwork/main/patchwork/hasher.py [Back]  [Original]

#!/usr/bin/env python
#
# Patchwork - automated patch tracking system
# Copyright (C) 2008 Jeremy Kerr 
#
# SPDX-License-Identifier: GPL-2.0-or-later

"""Hash generation for diffs."""

import hashlib
import re
import sys

HUNK_RE = re.compile(r'^\@\@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? \@\@')
FILENAME_RE = re.compile(r'^(---|\+\+\+) (\S+)')


def hash_diff(diff):
    """Generate a hash from a diff."""

    # normalise spaces
    diff = diff.replace('\r', '')
    diff = diff.strip() + '\n'

    prefixes = ['-', '+', ' ']
    hashed = hashlib.sha1()

    for line in diff.split('\n'):
        if len(line) 

Web Proxy Viewer  |  New URL  |  Original Page