Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
proyectos
.idea
.DS_Store
7 changes: 7 additions & 0 deletions bootstrap.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions bootstrap.js

Large diffs are not rendered by default.

83 changes: 42 additions & 41 deletions gitstats
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ class HTMLReportCreator(ReportCreator):
binarypath = os.path.dirname(os.path.abspath(__file__))
secondarypath = os.path.join(binarypath, '..', 'share', 'gitstats')
basedirs = [binarypath, secondarypath, '/usr/share/gitstats']
for file in (conf['style'], 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
for file in ('bootstrap.js','bootstrap.css','gitstats.css', 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
for base in basedirs:
src = base + '/' + file
if os.path.exists(src):
Expand All @@ -754,7 +754,7 @@ class HTMLReportCreator(ReportCreator):

self.printNav(f)

f.write('<dl>')
f.write('<div><div class="card-body"><dl>')
f.write('<dt>Project name</dt><dd>%s</dd>' % (data.projectname))
f.write('<dt>Generated</dt><dd>%s (in %d seconds)</dd>' % (datetime.datetime.now().strftime(format), time.time() - data.getStampCreated()))
f.write('<dt>Generator</dt><dd><a href="http://gitstats.sourceforge.net/">GitStats</a> (version %s), %s, %s</dd>' % (getversion(), getgitversion(), getgnuplotversion()))
Expand All @@ -764,7 +764,7 @@ class HTMLReportCreator(ReportCreator):
f.write('<dt>Total Lines of Code</dt><dd>%s (%d added, %d removed)</dd>' % (data.getTotalLOC(), data.total_lines_added, data.total_lines_removed))
f.write('<dt>Total Commits</dt><dd>%s (average %.1f commits per active day, %.1f per all days)</dd>' % (data.getTotalCommits(), float(data.getTotalCommits()) / len(data.getActiveDays()), float(data.getTotalCommits()) / data.getCommitDeltaDays()))
f.write('<dt>Authors</dt><dd>%s (average %.1f commits per author)</dd>' % (data.getTotalAuthors(), (1.0 * data.getTotalCommits()) / data.getTotalAuthors()))
f.write('</dl>')
f.write('</dl></div')

f.write('</body>\n</html>')
f.close()
Expand Down Expand Up @@ -795,7 +795,7 @@ class HTMLReportCreator(ReportCreator):
stampcur -= deltaweek

# top row: commits & bar
f.write('<table class="noborders"><tr>')
f.write('<div><div class="card-body"><table class="noborders"><tr>')
for i in range(0, WEEKS):
commits = 0
if weeks[i] in data.activity_by_year_week:
Expand All @@ -811,12 +811,12 @@ class HTMLReportCreator(ReportCreator):
f.write('</tr><tr>')
for i in range(0, WEEKS):
f.write('<td>%s</td>' % (WEEKS - i))
f.write('</tr></table>')
f.write('</tr></table></div>')

# Hour of Day
f.write(html_header(2, 'Hour of Day'))
hour_of_day = data.getActivityByHourOfDay()
f.write('<table><tr><th>Hour</th>')
f.write('<div><div class="card-body"><table><tr><th>Hour</th>')
for i in range(0, 24):
f.write('<th>%d</th>' % i)
f.write('</tr>\n<tr><th>Commits</th>')
Expand All @@ -838,8 +838,8 @@ class HTMLReportCreator(ReportCreator):
f.write('<td style="background-color: rgb(%d, 0, 0)">%.2f</td>' % (r, (100.0 * hour_of_day[i]) / totalcommits))
else:
f.write('<td>0.00</td>')
f.write('</tr></table>')
f.write('<img src="hour_of_day.png" alt="Hour of Day">')
f.write('</tr></table></div>')
f.write('<img src="hour_of_day.png" alt="Hour of Day" />')
fg = open(path + '/hour_of_day.dat', 'w')
for i in range(0, 24):
if i in hour_of_day:
Expand Down Expand Up @@ -872,7 +872,7 @@ class HTMLReportCreator(ReportCreator):

# Hour of Week
f.write(html_header(2, 'Hour of Week'))
f.write('<table>')
f.write('<div><div class="card-body"><table>')

f.write('<tr><th>Weekday</th>')
for hour in range(0, 24):
Expand All @@ -895,7 +895,7 @@ class HTMLReportCreator(ReportCreator):
f.write('<td></td>')
f.write('</tr>')

f.write('</table>')
f.write('</table></div>')

# Month of Year
f.write(html_header(2, 'Month of Year'))
Expand Down Expand Up @@ -938,16 +938,15 @@ class HTMLReportCreator(ReportCreator):

# Commits by timezone
f.write(html_header(2, 'Commits by Timezone'))
f.write('<table><tr>')
f.write('<div><div class="card-body"><table><tr>')
f.write('<th>Timezone</th><th>Commits</th>')
f.write('</tr>')
max_commits_on_tz = max(data.commits_by_timezone.values())
for i in sorted(data.commits_by_timezone.keys(), key = lambda n : int(n)):
commits = data.commits_by_timezone[i]
r = 127 + int((float(commits) / max_commits_on_tz) * 128)
f.write('<tr><th>%s</th><td style="background-color: rgb(%d, 0, 0)">%d</td></tr>' % (i, r, commits))
f.write('</table>')

f.write('</tr></table></div>')
f.write('</body></html>')
f.close()

Expand All @@ -962,12 +961,12 @@ class HTMLReportCreator(ReportCreator):
# Authors :: List of authors
f.write(html_header(2, 'List of Authors'))

f.write('<table class="authors sortable" id="authors">')
f.write('<div><div class="card-body"><table class="authors sortable" id="authors">')
f.write('<tr><th>Author</th><th>Commits (%)</th><th>+ lines</th><th>- lines</th><th>First commit</th><th>Last commit</th><th class="unsortable">Age</th><th>Active days</th><th># by commits</th></tr>')
for author in data.getAuthors(conf['max_authors']):
info = data.getAuthorInfo(author)
f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%d</td></tr>' % (author, info['commits'], info['commits_frac'], info['lines_added'], info['lines_removed'], info['date_first'], info['date_last'], info['timedelta'], len(info['active_days']), info['place_by_commits']))
f.write('</table>')
f.write('</table></div>')

allauthors = data.getAuthors()
if len(allauthors) > conf['max_authors']:
Expand Down Expand Up @@ -1018,7 +1017,7 @@ class HTMLReportCreator(ReportCreator):

# Authors :: Author of Month
f.write(html_header(2, 'Author of Month'))
f.write('<table class="sortable" id="aom">')
f.write('<div><div class="card-body"><table class="sortable" id="aom">')
f.write('<tr><th>Month</th><th>Author</th><th>Commits (%%)</th><th class="unsortable">Next top %d</th><th>Number of authors</th></tr>' % conf['authors_top'])
for yymm in reversed(sorted(data.author_of_month.keys())):
authordict = data.author_of_month[yymm]
Expand All @@ -1028,18 +1027,18 @@ class HTMLReportCreator(ReportCreator):
next = ', '.join(authors[1:conf['authors_top']+1])
f.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td><td>%s</td><td>%d</td></tr>' % (yymm, authors[0], commits, (100.0 * commits) / data.commits_by_month[yymm], data.commits_by_month[yymm], next, len(authors)))

f.write('</table>')
f.write('</table></div>')

f.write(html_header(2, 'Author of Year'))
f.write('<table class="sortable" id="aoy"><tr><th>Year</th><th>Author</th><th>Commits (%%)</th><th class="unsortable">Next top %d</th><th>Number of authors</th></tr>' % conf['authors_top'])
f.write('<div><div class="card-body"><table class="sortable" id="aoy"><tr><th>Year</th><th>Author</th><th>Commits (%%)</th><th class="unsortable">Next top %d</th><th>Number of authors</th></tr>' % conf['authors_top'])
for yy in reversed(sorted(data.author_of_year.keys())):
authordict = data.author_of_year[yy]
authors = getkeyssortedbyvalues(authordict)
authors.reverse()
commits = data.author_of_year[yy][authors[0]]
next = ', '.join(authors[1:conf['authors_top']+1])
f.write('<tr><td>%s</td><td>%s</td><td>%d (%.2f%% of %d)</td><td>%s</td><td>%d</td></tr>' % (yy, authors[0], commits, (100.0 * commits) / data.commits_by_year[yy], data.commits_by_year[yy], next, len(authors)))
f.write('</table>')
f.write('</table></div>')

# Domains
f.write(html_header(2, 'Commits by Domains'))
Expand Down Expand Up @@ -1071,14 +1070,14 @@ class HTMLReportCreator(ReportCreator):
f.write('<h1>Files</h1>')
self.printNav(f)

f.write('<dl>\n')
f.write('<div><div class="card-body"><dl>\n')
f.write('<dt>Total files</dt><dd>%d</dd>' % data.getTotalFiles())
f.write('<dt>Total lines</dt><dd>%d</dd>' % data.getTotalLOC())
try:
f.write('<dt>Average file size</dt><dd>%.2f bytes</dd>' % (float(data.getTotalSize()) / data.getTotalFiles()))
except ZeroDivisionError:
pass
f.write('</dl>\n')
f.write('</dl></div>\n')

# Files :: File count by date
f.write(html_header(2, 'File count by date'))
Expand All @@ -1101,7 +1100,7 @@ class HTMLReportCreator(ReportCreator):

# Files :: Extensions
f.write(html_header(2, 'Extensions'))
f.write('<table class="sortable" id="ext"><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
f.write('<div><div class="card-body"><table class="sortable" id="ext"><tr><th>Extension</th><th>Files (%)</th><th>Lines (%)</th><th>Lines/file</th></tr>')
for ext in sorted(data.extensions.keys()):
files = data.extensions[ext]['files']
lines = data.extensions[ext]['lines']
Expand All @@ -1110,7 +1109,7 @@ class HTMLReportCreator(ReportCreator):
except ZeroDivisionError:
loc_percentage = 0
f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (ext, files, (100.0 * files) / data.getTotalFiles(), lines, loc_percentage, lines / files))
f.write('</table>')
f.write('</table></div>')

f.write('</body></html>')
f.close()
Expand All @@ -1122,9 +1121,9 @@ class HTMLReportCreator(ReportCreator):
f.write('<h1>Lines</h1>')
self.printNav(f)

f.write('<dl>\n')
f.write('<div><div class="card-body"><dl>\n')
f.write('<dt>Total lines</dt><dd>%d</dd>' % data.getTotalLOC())
f.write('</dl>\n')
f.write('</dl></div>\n')

f.write(html_header(2, 'Lines of Code'))
f.write('<img src="lines_of_code.png" alt="Lines of Code">')
Expand All @@ -1144,13 +1143,13 @@ class HTMLReportCreator(ReportCreator):
f.write('<h1>Tags</h1>')
self.printNav(f)

f.write('<dl>')
f.write('<div><div class="card-body"><dl>')
f.write('<dt>Total tags</dt><dd>%d</dd>' % len(data.tags))
if len(data.tags) > 0:
f.write('<dt>Average commits per tag</dt><dd>%.2f</dd>' % (1.0 * data.getTotalCommits() / len(data.tags)))
f.write('</dl>')
f.write('</dl></div>')

f.write('<table class="tags">')
f.write('<div><div class="card-body"><table class="tags">')
f.write('<tr><th>Name</th><th>Date</th><th>Commits</th><th>Authors</th></tr>')
# sort the tags by date desc
tags_sorted_by_date_desc = map(lambda el : el[1], reversed(sorted(map(lambda el : (el[1]['date'], el[0]), data.tags.items()))))
Expand All @@ -1160,7 +1159,7 @@ class HTMLReportCreator(ReportCreator):
for i in reversed(self.authors_by_commits):
authorinfo.append('%s (%d)' % (i, data.tags[tag]['authors'][i]))
f.write('<tr><td>%s</td><td>%s</td><td>%d</td><td>%s</td></tr>' % (tag, data.tags[tag]['date'], data.tags[tag]['commits'], ', '.join(authorinfo)))
f.write('</table>')
f.write('</table></div>')

f.write('</body></html>')
f.close()
Expand Down Expand Up @@ -1379,25 +1378,27 @@ plot """
<head>
<meta charset="UTF-8">
<title>GitStats - %s</title>
<link rel="stylesheet" href="%s" type="text/css">
<meta name="generator" content="GitStats %s">
<link rel="stylesheet" href="%s" type="text/css" />
<link rel="stylesheet" href="bootstrap.css" type="text/css" />
<meta name="generator" content="GitStats %s" />
<script type="text/javascript" src="sortable.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
</head>
<body>
""" % (self.title, conf['style'], getversion()))

def printNav(self, f):
f.write("""
<div class="nav">
<ul>
<li><a href="index.html">General</a></li>
<li><a href="activity.html">Activity</a></li>
<li><a href="authors.html">Authors</a></li>
<li><a href="files.html">Files</a></li>
<li><a href="lines.html">Lines</a></li>
<li><a href="tags.html">Tags</a></li>
</ul>
</div>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item" aria-current="page"><a href="index.html">General</a></li>
<li class="breadcrumb-item" aria-current="page"><a href="activity.html">Activity</a></li>
<li class="breadcrumb-item" aria-current="page"><a href="authors.html">Authors</a></li>
<li class="breadcrumb-item" aria-current="page"><a href="files.html">Files</a></li>
<li class="breadcrumb-item" aria-current="page"><a href="lines.html">Lines</a></li>
<li class="breadcrumb-item" aria-current="page"><a href="tags.html">Tags</a></li>
</ol>
</nav>
""")

def usage():
Expand Down