forked from operasoftware/upstreamtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_upstream_list.py
executable file
·66 lines (59 loc) · 2.32 KB
/
generate_upstream_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python2
# coding: utf-8
import re
from jinja2 import Environment, FileSystemLoader
import config
from repository import Repo
def get_commit_log(git_repo):
is_v8 = 'v8' in git_repo
repo = Repo(git_repo)
log = repo.commits(is_v8)
for commit in log:
m = re.search(r'git-svn-id: ([^\s]+)', commit.body)
if not m:
# Found nothing!
raise Exception("Didn't find git-svn-id in the commit body! Rev {0}"
"".format(commit.sha))
id = m.group(1)
if is_v8:
# e.g. https://v8.googlecode.com/svn/branches/bleeding_edge@18761
m2 = re.match(r'https://v8.googlecode.com/svn/([^/]+)/[^@]*@(\d+)', id)
m3 = re.search('(Contributed|Patch) (from|by) [^<]*<(?P<name>[^@]+)@opera\.com>',
commit.body)
if not m3:
raise Exception("Didn't find opera employee in commit msg ({})".format(commit.body))
author = m3.group('name')
else:
# e.g. svn://svn.chromium.org/blink/trunk@165617
m2 = re.match(r'svn://svn.chromium.org/([^/]+)/[^@]*@(\d+)', id)
author = commit.author.replace('@opera.com', '')
if not m2:
# Found nothing!
raise Exception("Didn't find product and revision in the svn URL! "
"URL {0}, rev {1}.".format(id, commit.sha))
commit.product = m2.group(1)
commit.svn_revision = m2.group(2)
if is_v8:
commit.viewvc = (
"https://code.google.com/p/v8/source/detail?r={rev}"
.format(rev=commit.svn_revision)
)
else:
commit.viewvc = (
"http://src.chromium.org/viewvc/{prod}?revision={rev}&"
"view=revision"
.format(prod=commit.product, rev=commit.svn_revision)
)
commit.author_stripped = author
return log
chr_log = get_commit_log(config.CHROMIUM_GIT)
blink_log = get_commit_log(config.BLINK_GIT)
v8_log = get_commit_log(config.V8_GIT)
log = [
{ 'name': 'Chromium', 'log': chr_log },
{ 'name': 'Blink', 'log': blink_log },
{ 'name': 'v8', 'log': v8_log },
]
env = Environment(loader=FileSystemLoader('templates'))
tmpl = env.get_template('upstreamed_commits.html')
print tmpl.render(projects=log).encode('utf-8')