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
ca489427
Commit
ca489427
authored
Jul 16, 2020
by
Gustavo Padovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contribution-stats: add html output
parent
22f8b2d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
README.md
README.md
+1
-0
contribution-stats.py
contribution-stats.py
+16
-1
templates/contribution-stats.html.j2
templates/contribution-stats.html.j2
+15
-0
No files found.
README.md
View file @
ca489427
...
...
@@ -34,6 +34,7 @@ Options:
*
`-s, --summary`
: show only a summary with the numbers for each person, but no details
*
`-o, --output`
: output result to a file instead of stdout
*
`--html`
: output as html with link to commits
### Generating HTML tree view
...
...
contribution-stats.py
View file @
ca489427
#! /usr/bin/env python
import
argparse
import
csv
import
jinja2
import
os
import
sys
import
re
...
...
@@ -73,6 +74,14 @@ def print_all(results, args):
if
f
is
not
sys
.
stdout
:
f
.
close
()
def
generate_html
(
results
,
args
):
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
'{}/templates'
.
format
(
sys
.
path
[
0
])))
template
=
env
.
get_template
(
'contribution-stats.html.j2'
)
content
=
template
.
render
(
results
=
results
,
contributors
=
contributors
,
summary
=
args
.
summary
)
with
open
(
args
.
html
,
'w'
)
as
html_file
:
html_file
.
write
(
content
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
set_defaults
(
func
=
lambda
x
:
parser
.
print_help
())
...
...
@@ -80,6 +89,8 @@ if __name__ == "__main__":
help
=
"enable details for each section"
)
parser
.
add_argument
(
'-o'
,
'--output'
,
metavar
=
"FILE"
,
help
=
"output to a file instead of stdout"
)
parser
.
add_argument
(
'--html'
,
metavar
=
"FILE"
,
help
=
"output to a html instead of stdout"
)
args
=
parser
.
parse_args
(
sys
.
argv
[
1
:])
repo
=
Repository
(
os
.
getcwd
())
...
...
@@ -111,6 +122,7 @@ if __name__ == "__main__":
add_commit
(
tag
[
1
],
m
[
1
],
commit
)
results
=
[]
# XXX order dicts here
results
.
append
((
"Authored ({}):"
.
format
(
total_commits
(
authored
)),
authored
))
results
.
append
((
"Maintainer Committed ({}):"
.
format
(
total_commits
(
committed
)),
committed
))
results
.
append
((
"Signed-off-by ({}):"
.
format
(
total_commits
(
signed
)),
signed
))
...
...
@@ -118,4 +130,7 @@ if __name__ == "__main__":
for
tag
in
OTHER_TAGS
:
results
.
append
((
"{} ({}):"
.
format
(
tag
[
0
],
total_commits
(
tag
[
1
])),
tag
[
1
]))
print_all
(
results
,
args
)
if
args
.
html
:
generate_html
(
results
,
args
)
else
:
print_all
(
results
,
args
)
templates/contribution-stats.html.j2
0 → 100644
View file @
ca489427
{% for r in results %}
<h4>{{ r[0] }}</h4>
{% for email, data in r[1].items() %}
<strong>{{ contributors[email] }} {{ email }} ({{ data[0]}}):</strong><br />
{% if not summary %}
<ul>
{% for commit in data[1] %}
<li>
<a href="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id={{ commit[0] }}">{{ commit[1] }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
{% endfor %}
\ No newline at end of file
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