old, new = Repo(old_url).packages, Repo(new_url).packages
elif style == 'image':
old, new = packages(old_url), packages(new_url)
+ elif style == 'commit':
+ old, new = Repo(old_url).packages, Repo(new_url).packages
else:
return
data = []
for idx in range(1, len(sp), 2):
l = sp[idx].split("<$^=->")
- data.append({"commit_id": escape_html(l[0]),
- "committer": escape_html(l[1]),
- "commit_date": escape_html(l[2]),
- "commit_log": {'html':escape_html_newline(escape_html(l[3])), 'raw':escape_html(l[3])}})
+ if style != 'commit':
+ data.append({"commit_id": escape_html(l[0]),
+ "committer": escape_html(l[1]),
+ "commit_date": escape_html(l[2]),
+ "commit_log": {'html':escape_html_newline(escape_html(l[3])), 'raw':escape_html(l[3])}})
+ else:
+ committer = escape_html(l[1])
+ found = re.search('<(.+?)>', committer)
+ if found:
+ committer = found.group(1)
+ committer = committer.split('@')[0]
+ # if (committer.find('<') != -1) and (committer.find('>') != -1):
+ # committer = committer.split('<')[-1].split('>')[0].replace('@samsung.com','')
+ data.append({"commit_id": escape_html(l[0])[:7],
+ "committer": committer,
+ "commit_date": escape_html(l[2]),
+ "commit_log": {'html':escape_html_newline(escape_html(l[3])), 'raw':escape_html(l[3])}})
f.close()
return data
'removed': [],
'modified': [],
'rebuilded': [],
+ 'count': {'added' : 0, 'removed': 0, 'modified': 0, 'rebuilded': 0},
}}
#-----------------------------------------------------------------------------
added_p = {}
p = {'oldpkg': None,
'newpkg': {
- 'name': ','.join(ps),
+ 'name': ','.join(ps) if style != 'commit' else _pp.name,
'version': {
'epoch': _p.version.epoch,
'rel': _p.version.rel,
'ver': _p.version.ver,
},
- 'git_path': _git_path,
+ 'git_path': _git_path.split(':/')[-1],
'commit_id': _commit_id
},
'codediff': _codediff,
obj['diff']['removed'].append(
{'oldpkg': {
- 'name': ','.join(ps),
+ 'name': ','.join(ps) if style != 'commit' else _pp.name,
'version': {
'epoch': _p.version.epoch,
'rel': _p.version.rel,
'ver': _p.version.ver,
},
- 'git_path': _git_path,
+ 'git_path': _git_path.split(':/')[-1],
'commit_id': _commit_id
},
'newpkg': None,
for _old, _new in modified_p[_git_path][_version]:
ps.append('.'.join([_old.name,_old.arch]))
- names = ','.join(ps)
+ names = ','.join(ps) if style != 'commit' else _old.name
obj['diff']['modified'].append(
{'oldpkg': {
'name': names,
'rel': _old.version.rel,
'ver': _old.version.ver,
},
- 'git_path': _old_git_path,
+ 'git_path': _old_git_path.split(':/')[-1],
'commit_id': _old_commit_id
},
'newpkg':{
'rel': _new.version.rel,
'ver': _new.version.ver,
},
- 'git_path': _new_git_path,
+ 'git_path': _new_git_path.split(':/')[-1],
'commit_id': _new_commit_id
},
'codediff': _codediff,
'codediff': _codediff,
})
+
+ idxs = ['added', 'removed', 'modified', 'rebuilded']
+ for idx in idxs:
+ for item in obj['diff'][idx]:
+ if 'commit_log' in item:
+ obj['diff']['count'][idx] += len(item['commit_log'])
+
#-----------------------------------------------------------------------------
#obj = {style: {'old': old_url, 'new': new_url},
#'diff': {
return output_html('diff.csv', **context)
elif style == 'image':
return output_html('image_diff.csv', **context)
+ elif style == 'commit':
+ return output_html('commit_diff.csv', **context)
def diff_to_html(old_url, new_url, **kwargs):
"""Output diffs' html format.
'filename': diff_name,
'gitweb': data['gitweb']
}
+
if style == 'repo':
return output_html('diff.html', **context)
elif style == 'image':
return output_html('image_diff.html', **context)
+ elif style == 'commit':
+ return output_html('commit_diff.html', **context)
def diff_to_dist(old_url, new_url, dist_path, **kwargs):
"""Create a dist-dir of diffs, contains html and css.
fname.write(output)
output = diff_to_csv(old_url, new_url, style=kwargs.get('style'), diff_name=diff_name)
- with io.open(os.path.join(dist_path, '%s.csv' % diff_name), 'w', encoding='utf-8', errors='ignore') as fname:
+ with io.open(os.path.join(dist_path, '%s.csv' % diff_name), 'w', encoding='utf-8-sig', errors='ignore') as fname:
fname.write(output)
return dist_path
lines = response.content.split('\n')
for line in lines:
if suffix in line:
- target = line.split('*')[-1]
+ target = line.split('*')[-1].split(' ')[-1]
f_response = requests.get(url + '/' + target)
if f_response.status_code == 200:
# use StringIO to keep wrapped lines
if line.strip():
name_arch, version, vcs = line.strip().split()
name = name_arch.split('.')[0]
+ arch = name_arch.split('.')[1]
setattr(packages_info, name, [])
package_info = JsonDict()
package_info.name = name
+ package_info.arch = arch
package_info.version = JsonDict()
ver, rel = version.split('-')
package_info.version.epoch = 0 # we can't get epoch, so give 0.
--- /dev/null
+Difference between {{old['name']}} and {{new['name']}}
+
+Added Commits: {{ diff['count']['added'] }}
+Removed Packages: {{ diff['removed']|count }}
+Modified Commits: {{ diff['count']['modified'] }}
+
+Added Packages,{% if diff['added'] %}
+Package,Git Path,CommitId,Committer,CommitDate,CommitLog
+ {%- for item in diff['added'] -%}
+ {%- for commit_item in item['commit_log'] %}
+"{{ item['newpkg']['name'] }}","{{ item['newpkg']['git_path'] }}","{{commit_item['commit_id']}}","{{commit_item['committer']}}","{{commit_item['commit_date']}}","{{commit_item['commit_log']['raw']}}"
+ {%- endfor -%}
+ {%- endfor -%}
+{%- endif %}
+
+Removed Packages,{% if diff['removed'] %}
+Package,Version,Git Path,CommitId
+ {%- for item in diff['removed'] %}
+"{{ item['oldpkg']['name'] }}","{{ item['oldpkg']['version']['ver'] }}-{{item['oldpkg']['version']['rel']}}","{{ item['oldpkg']['git_path'] }}","{{ item['oldpkg']['commit_id'] }}"
+ {%- endfor -%}
+{%- endif %}
+
+Modified Packages,{% if diff['modified'] %}
+Package,Git Path,CommitId,Committer,CommitDate,CommitLog
+ {%- for item in diff['modified'] -%}
+ {%- if item['oldpkg']['git_path'] != item['newpkg']['git_path'] -%}
+ {%- set git_path = item['oldpkg']['git_path'] + "-" + item['newpkg']['git_path'] -%}
+ {%- else -%}
+ {%- set git_path = item['oldpkg']['git_path'] -%}
+ {%- endif %}
+ {%- for commit_item in item['commit_log'] %}
+"{{ item['oldpkg']['name'] }}","{{ git_path }}","{{commit_item['commit_id']}}","{{commit_item['committer']}}","{{commit_item['commit_date']}}","{{commit_item['commit_log']['raw']}}"
+ {%- endfor -%}
+ {%- endfor -%}
+{%- endif %}
+
--- /dev/null
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <link href="./css/html-reset.css" media="screen" rel="stylesheet" type="text/css" />
+ <link href="./css/layout-liquid.css" media="screen" rel="stylesheet" type="text/css" />
+ <link href="./css/tizen.css" media="screen" rel="stylesheet" type="text/css" />
+ <link href="./css/style.css" media="screen" rel="stylesheet" type="text/css" />
+ <link href="./css/shCore.css" rel="stylesheet" type="text/css" />
+ <link href="./css/shThemeDefault.css" rel="stylesheet" type="text/css" />
+ <link href="./css/diff.css" rel="stylesheet" type="text/css" />
+
+<script>
+function toggle_show(table_id, button) {
+ var obj = document.getElementById(table_id);
+ if( obj.style.display == 'none' ) {
+ obj.style.display = "";
+ button.innerHTML="-";
+ } else {
+ obj.style.display = "none";
+ button.innerHTML="+";
+ }
+}
+
+</script>
+</head>
+<body>
+ <div id="page-wrapper">
+ <div id="page">
+ <div id="header">
+ <div class="section clearfix">
+ <h1 id="logo">
+ <a href="http://www.tizen.org"><img alt="Tizen-logo" src="./img/tizen-logo.png" width="180px" height="50px"></a>
+ </h1>
+ </div>
+ </div>
+ </div>
+ </div>
+ <h1>
+ Difference and Changelogs Overview
+ </h1>
+ <a href="index.html">Go back</a>...<br>
+ <a href="{{filename}}.csv">csv format</a>...<br>
+ <p>Difference between
+ <a href="{{old['url']}}">{{ old['name'] }}</a> and <a href="{{new['url']}}">{{ new['name'] }}</a>
+ </p>
+ <h3>Highlights</h3>
+ <ul>
+ <li><a href="#added">Added Commits: {{ diff['count']['added'] }}</a></li>
+ <li><a href="#removed">Removed Packages: {{ diff['removed']|count }}</a></li>
+ <li><a href="#modified">Modified Commits: {{ diff['count']['modified'] }}</a></li>
+ </ul>
+ <table id='data_table'>
+ <tr><td colspan="8" id='added' class="tableTitle"><h3><a>Added Packages</a></h3></td></tr>
+ {% set git_web = gitweb %}
+ {% if diff['added'] %}
+ <tbody>
+ <tr>
+ <th>Package</th><th>Git Path</th><th>CommitId</th><th>Committer</th><th>CommitDate</th><th width='50%'>CommitLog</th>
+ </tr>
+ {% for item in diff['added'] %}
+ {% for commit_item in item['commit_log'] %}
+ <tr>
+ <td>{{ item['newpkg']['name'] }}</td>
+ <td><a href="{{ git_web['new'] }}?p={{ item['newpkg']['git_path'] }}.git">{{ item['newpkg']['git_path'] }}</a></td>
+ <td><a href="{{ git_web['new'] }}?p={{ item['newpkg']['git_path'] }}.git;a=commit;h={{ commit_item['commit_id'] }}">{{ commit_item['commit_id'] }}</a></td>
+ <td>{{ commit_item['committer'] }}</td>
+ <td>{{ commit_item['commit_date'] }}</td>
+ <td>{{ commit_item['commit_log']['html'] }}</td>
+ </tr>
+ {% endfor %}
+ {% endfor %}
+ </tbody>
+ {% endif %}
+ <tr><td colspan="8" id='removed' class="tableTitle"><h3><a>Removed Packages</a></h3></td></tr>
+ {% if diff['removed'] %}
+ <tbody>
+ <tr>
+ <th>Package</th><th colspan="2">Version</th><th>GitPath</th><th colspan="3">CommitId</th>
+ </tr>
+ {% for item in diff['removed'] %}
+ <tr>
+ <td>{{ item['oldpkg']['name'] }}</td>
+ <td colspan="2">{{ item['oldpkg']['version']['ver'] }}-{{item['oldpkg']['version']['rel']}}</td>
+ <td><a href="{{ git_web['old'] }}?p={{ item['oldpkg']['git_path'] }}.git">{{ item['oldpkg']['git_path'] }}</a></td>
+ <td colspan="3"><a href="{{ git_web['old'] }}?p={{ item['oldpkg']['git_path'] }}.git;a=commit;h={{ item['oldpkg']['commit_id'] }}">{{ item['oldpkg']['commit_id'] }}</a></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ {% endif %}
+ <tr><td colspan="8" id='modified' class="tableTitle"><h3><a>Modified Packages</a></h3></td></tr>
+ {% if diff['modified'] %}
+ <tbody>
+ <tr>
+ <th>Package</th><th>Git Path</th><th>CommitId</th><th>Committer</th><th>CommitDate</th><th width='50%'>CommitLog</th>
+ </tr>
+ {% for item in diff['modified'] %}
+ {% for commit_item in item['commit_log'] %}
+ <tr>
+ <td>{{ item['oldpkg']['name'] }}</td>
+ <td>
+ <ul>
+ {% if item['oldpkg']['git_path'] != item['newpkg']['git_path'] %}
+ <li><a href="{{ git_web['old'] }}?p={{ item['oldpkg']['git_path'] }}.git">{{ item['oldpkg']['git_path'] }}</a> </li>
+ <li><a href="{{ git_web['new'] }}?p={{ item['newpkg']['git_path'] }}.git">{{ item['newpkg']['git_path'] }}</a> </li>
+ {% else %}
+ <li><a href="{{ git_web['old'] }}?p={{ item['oldpkg']['git_path'] }}.git">{{ item['oldpkg']['git_path'] }}</a></li>
+ {% endif %}
+ </ul>
+ </td>
+ <td><a href="{{ git_web['new'] }}?p={{ item['newpkg']['git_path'] }}.git;a=commit;h={{ commit_item['commit_id'] }}">{{ commit_item['commit_id'] }}</a></td>
+ <td>{{ commit_item['committer'] }}</td>
+ <td>{{ commit_item['commit_date'] }}</td>
+ <td>{{ commit_item['commit_log']['html'] }}</td>
+ </tr>
+ {% endfor %}
+ {% endfor %}
+ </tbody>
+ {% endif %}
+ </table>
+</body>
+
+</html>
+