Commit 41ab0ae9 authored by Gustavo Padovan's avatar Gustavo Padovan
Browse files

backlog-tree: use argparse and take commit list as stdin

parent d4830463
......@@ -30,7 +30,7 @@ To use it run the below from within your kernel directory:
git log --pretty='format:%h,"%s",,' <revision range> | <path to>/
Argument options:
* `-h, --help`: show help
* `-s, --summary`: sort output according to the number of commits instead of alphabetic order
......@@ -41,29 +41,29 @@ Options:
### Generating HTML tree view
Export the output of the git cmdline below to a csv file
The `stdin` input is a csv list with the following format:
git log --pretty='format:%h,"%s",,' <revision range>
`hash,commit subject, comments, status`
then pass your csv file as arg:`
*comments* and *status* are optional.
``` <csv file> <name> <git cmdline> <git HEAD>
git log --pretty='format:%h,"%s",,' <revision range> | ../kernel-scripts/
*csv file*: your csv file generated from the git log with the `--pretty='format:%h,"%s"`
or pass your csv file as as stdin:
*name*: the name for the output file, do not put a extension on it.
*git cmdline*: the cmd line used to generate the csv file
cat commits.csv | ../kernel-scripts/
*git HEAD*: the current git HEAD used
Argument options:
It will output \<name>.html and \<name>.json
* `-h, --help`: show help
* `-o, --output`: basename for the json and HTML output files (default is 'tree')
* `-c, --cmdline`: the cmd line used to generate the list of patches
* `-t, --title`: title for the HTML report
### scripts/ folder
The `scripts/` folder has some ready to use scripts to generate the analysis for some trees.
......@@ -6,7 +6,7 @@ import json
import os
from datetime import datetime
import jinja2
import argparse
......@@ -28,29 +28,33 @@ def classify_commit(fs_dict, commit):
partial_dict[entry][1] += 1
partial_dict = partial_dict[entry][0]
def generate_html(repo, fs_dict, title, cmd, head):
def generate_html(repo, fs_dict, 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, head=head,
return template.render(data=fs_dict, baseurl=BASE_URL, title=title, cmdline=cmd,
if __name__ == "__main__":
repo = git.Repository(os.getcwd())
parser = argparse.ArgumentParser()
parser.set_defaults(func=lambda x: parser.print_help())
parser.add_argument('-t','--title', type=str, default="Kernel commits - tree view",
help="title for the HTML report")
parser.add_argument('-c','--cmdline', type=str,
help="the command line used to generate the list of patches")
parser.add_argument('-o', '--output', metavar="FILE", default="tree",
help="basename for the json and HTML output files")
name = sys.argv[2]
cmdline = sys.argv[3]
head = sys.argv[4]
args = parser.parse_args(sys.argv[1:])
repo = git.Repository(os.getcwd())
fs_dict = {}
with open(sys.argv[1], newline='') as cvslog:
reader = csv.reader(cvslog, delimiter=',' )
for line in reader:
for line in csv.reader(sys.stdin, delimiter=','):
classify_commit(fs_dict, line)
with open(name + '.json', 'w') as json_file:
with open(args.output + '.json', 'w') as json_file:
json.dump(fs_dict, json_file)
html = generate_html(repo, fs_dict, name, cmdline, head)
with open(name + '.html', 'w') as html_file:
html = generate_html(repo, fs_dict, args.title, args.cmdline)
with open(args.output + '.html', 'w') as html_file:
......@@ -44,8 +44,9 @@
<h1 class="m-3">{{ title }}</h1>
{% if cmdline %}
<h4><code class="badge badge-dark ml-3 p-2">{{ cmdline }}</code></h4>
<p class="m-3">HEAD: <code>{{ head }}</code></p>
{% endif %}
<p class="text-monospace m-3">Generated on {{ now }} </p>
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