Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kernel-scripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Gustavo Padovan
kernel-scripts
Commits
41ab0ae9
Commit
41ab0ae9
authored
Jul 20, 2020
by
Gustavo Padovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backlog-tree: use argparse and take commit list as stdin
parent
d4830463
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
31 deletions
+36
-31
README.md
README.md
+15
-15
generate-html-tree.py
generate-html-tree.py
+18
-14
templates/backlog-tree.html.j2
templates/backlog-tree.html.j2
+3
-2
No files found.
README.md
View file @
41ab0ae9
...
...
@@ -30,40 +30,40 @@ To use it run the below from within your kernel directory:
git log --pretty='format:%h,"%s",,' <revision range> | <path to>/contribution-stats.py
```
O
ptions:
Argument o
ptions:
*
`-h, --help`
: show help
*
`-s, --summary`
: sort output according to the number of commits instead of alphabetic order
*
`-n, --numbered`
: suppress commit description and provide a commit count summary only
*
`-e, --email`
: show the email address of each contributor
*
`-e, --email`
: show the email address of each contributor
*
`-o FILE, --output FILE`
: output result to a file instead of stdout
*
`--html FILE`
: output as html with link to commits
### 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.
```
g
enerate-html-tree.py <csv file> <name> <git cmdline> <git HEAD>
g
it log --pretty='format:%h,"%s",,' <revision range> | ../kernel-scripts/generate-html-tree.py
```
*csv file*: your csv file generated from the git log with the `
--pretty='format:%h,"%s"
`
*name*: the name for the output file, do not put a extension on it.
or pass your csv file as as stdin:
*git cmdline*: the cmd line used to generate the csv file
```
cat commits.csv | ../kernel-scripts/generate-html-tree.py
```
*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.
generate-html-tree.py
View file @
41ab0ae9
...
...
@@ -6,7 +6,7 @@ import json
import
os
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="
...
...
@@ -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
,
now
=
datetime
.
now
())
return
template
.
render
(
data
=
fs_dict
,
baseurl
=
BASE_URL
,
title
=
title
,
cmdline
=
cmd
,
now
=
datetime
.
now
())
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
:
classify_commit
(
fs_dict
,
line
)
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
:
html_file
.
write
(
html
)
templates/backlog-tree.html.j2
View file @
41ab0ae9
...
...
@@ -44,8 +44,9 @@
<body>
<h1
class=
"m-3"
>
{{ title }}
</h1>
<h4><code
class=
"badge badge-dark ml-3 p-2"
>
{{ cmdline }}
</code></h4>
<p
class=
"m-3"
>
HEAD:
<code>
{{ head }}
</code></p>
{% if cmdline %}
<h4><code
class=
"badge badge-dark ml-3 p-2"
>
{{ cmdline }}
</code></h4>
{% endif %}
<p
class=
"text-monospace m-3"
>
Generated on {{ now }}
</p>
<ul>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment