| 1 |
# |
| 2 |
# -*- coding:utf-8 -*- |
| 3 |
# Pull together regular expressions used in multiple places. |
| 4 |
# |
| 5 |
# This code is part of the LWN git data miner. |
| 6 |
# |
| 7 |
# Copyright 2007-8 LWN.net |
| 8 |
# Copyright 2007-8 Jonathan Corbet <corbet@lwn.net> |
| 9 |
# Copyright 2009 Germán Póo-Caamaño <gpoo@gnome.org> |
| 10 |
# |
| 11 |
# This file may be distributed under the terms of the GNU General |
| 12 |
# Public License, version 2. |
| 13 |
# |
| 14 |
import re |
| 15 |
|
| 16 |
# |
| 17 |
# Some people, when confronted with a problem, think "I know, I'll use regular |
| 18 |
# expressions." Now they have two problems. |
| 19 |
# -- Jamie Zawinski |
| 20 |
# |
| 21 |
_pemail = r'\s+"?([^<"]+)"?\s<([^>]+)>' # just email addr + name |
| 22 |
|
| 23 |
patterns = { |
| 24 |
'commit': re.compile (r'^commit ([0-9a-f ]+)$'), |
| 25 |
'author': re.compile (r'^Author:' + _pemail + '$'), |
| 26 |
'signed-off-by': re.compile (r'Signed-off-by:' + _pemail), |
| 27 |
'merge': re.compile (r'^Merge:.*$'), |
| 28 |
'date': re.compile (r'^(Commit)?Date:\s+(.*)$'), |
| 29 |
# filea, fileb are used only in 'parche mode' (-p) |
| 30 |
'filea': re.compile (r'^---\s+(.*)$'), |
| 31 |
'fileb': re.compile (r'^\+\+\+\s+(.*)$'), |
| 32 |
'reviewed-by': re.compile (r'Reviewed-by:' + _pemail), |
| 33 |
'tested-by': re.compile (r' tested-by:' + _pemail, re.I), |
| 34 |
'reported-by': re.compile (r'Reported-by:' + _pemail), |
| 35 |
'reported-and-tested-by': re.compile (r'reported-and-tested-by:' + _pemail, re.I), |
| 36 |
# |
| 37 |
# Merges are described with a variety of lines. |
| 38 |
# |
| 39 |
'ExtMerge': re.compile(r'^ +Merge( branch .* of)? ([^ ]+:[^ ]+)\n$'), |
| 40 |
'IntMerge': re.compile(r'^ +(Merge|Pull) .* into .*$'), |
| 41 |
# PIntMerge2 = re.compile(r"^ +Merge branch(es)? '.*$"), |
| 42 |
'IntMerge2': re.compile(r"^ +Merge .*$"), |
| 43 |
# Another way to get the statistics (per file). |
| 44 |
# It implies --numstat |
| 45 |
'numstat': re.compile('^(\d+|-)\s+(\d+|-)\s+(.*)$'), |
| 46 |
'rename' : re.compile('(.*)\{(.*) => (.*)\}(.*)'), |
| 47 |
} |