Commit 715f00a6 authored by Gustavo Padovan's avatar Gustavo Padovan
Browse files

backlog-tree: fix patch count + show more info

parent 41ab0ae9
......@@ -8,8 +8,8 @@ from datetime import datetime
import jinja2
import argparse
#BASE_URL="https://chromium.googlesource.com/chromiumos/third_party/kernel/+/"
BASE_URL="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id="
BASE_URL="https://chromium.googlesource.com/chromiumos/third_party/kernel/+/"
#BASE_URL="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id="
def classify_commit(fs_dict, commit):
diff = repo.diff(commit[0], commit[0] + "^")
......@@ -25,14 +25,26 @@ def classify_commit(fs_dict, commit):
if entry not in partial_dict.keys():
partial_dict[entry] = [{}, 0]
partial_dict[entry][1] += 1
partial_dict = partial_dict[entry][0]
def generate_html(repo, fs_dict, title, cmd):
def count_commits_per_folder(fs_structure):
if not isinstance(fs_structure, dict):
return fs_structure
folder_commits = []
for entry, data in fs_structure.items():
commits = count_commits_per_folder(data[0])
fs_structure[entry][1] = len(commits)
[folder_commits.append(x) for x in commits if x not in folder_commits]
return folder_commits
def generate_html(repo, fs_dict, total_commits, title, cmd):
env = jinja2.Environment(loader=jinja2.FileSystemLoader('{}/templates'.format(sys.path[0])))
template = env.get_template('backlog-tree.html.j2')
return template.render(data=fs_dict, baseurl=BASE_URL, title=title, cmdline=cmd, now=datetime.now())
return template.render(data=fs_dict, baseurl=BASE_URL, total_commits=total_commits, title=title, cmdline=cmd, now=datetime.now())
if __name__ == "__main__":
parser = argparse.ArgumentParser()
......@@ -52,9 +64,11 @@ if __name__ == "__main__":
for line in csv.reader(sys.stdin, delimiter=','):
classify_commit(fs_dict, line)
total_commits = count_commits_per_folder(fs_dict)
with open(args.output + '.json', 'w') as json_file:
json.dump(fs_dict, json_file)
html = generate_html(repo, fs_dict, args.title, args.cmdline)
html = generate_html(repo, fs_dict, len(total_commits), args.title, args.cmdline)
with open(args.output + '.html', 'w') as html_file:
html_file.write(html)
......@@ -15,16 +15,16 @@
</head>
{% macro add_commit(commit) -%}
{% if commit | length > 4 %}
<span class="badge badge-primary m-1 p-2">
{{ commit[4] }}
</span>
{% endif %}
<a href="{{ baseurl }}{{ commit[0] }}">{{ commit[0] }} - {{ commit[1] }}</a>
{% if commit[2] != '' %}
{% if commit[2] == 'upstream' %}
<span class="badge badge-pill badge-success m-1 p-2">
{% elif commit[2] == 'unmergeable' %}
<span class="badge badge-pill badge-secondary m-1 p-2">
{% else %}
<span class="badge badge-pill badge-warning m-1 p-2">
{% endif %}
{{ commit[2] }}
</span>
{% endif %}
......@@ -49,6 +49,8 @@
{% endif %}
<p class="text-monospace m-3">Generated on {{ now }} </p>
<h4 class="ml-3 p-2">{{ total_commits }} commits in total</h4>
<ul>
{% for folder, content in data | dictsort recursive %}
<li>
......@@ -59,7 +61,7 @@
{{folder}}<span class="badge badge-dark m-1">{{ content[1] }}</span>
</a>
<span class="badge badge-primary p-1" style="width: {{ content[1] * 1.5 }}px;">&nbsp;</span>
<div class="collapse" id="{{ class_id }}">
<div class="collapse {% if content[0].items is not defined and loop.depth > 1 %}show{% endif %}" id="{{ class_id }}">
{% if content[0].items is defined %}
<ul>{{ loop(content[0] | dictsort) }}</ul>
{% else %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment