regex - Parse git - log file with python -
regex - Parse git - log file with python -
so need parse thing :
commit e397a6e988c05d6fd87ae904303ec0e17f4d79a2 author: name <email@email.com> date: sat jul 9 21:29:10 2011 +0400 commit message 1 files changed, 21 insertions(+), 11 deletions(-)
and author name , number of insertions , deletions.
for name have this:
re.findall(r"author: (.+) <",gitlog)
for numbers have this:
re.findall(r" (\d+) insertions\s+, (\d+) deletions",gitlog)
but want list of tuples of name,insertions , delitions 1 regular-expression.
i tryed somthing like
re.findall(r"author: (.+) <.+ (\d+) insertions\s+, (\d+) deletions",gitlog,re.dotall)
but returns nothing...
so mistake? how regular-expression should like?
upadte: wrar right, somehow when read file , seek parse whole file name , , lastly insertion , deletion, matches whole file not single commit... [.+] gets whole file not part of commit...
if have access repo , not text dump of git log
, save parsing problem , generate different log output:
git log --pretty="%an" --numstat
will produce output of form:
author name
lines_inserted lines_deleted modified_file
which don't need regex for. if want maintain regex, need match (+)
after insertions or else not match @ , not capture numbers.
python regex git git-log
Comments
Post a Comment