Skip to content

Commit 98e3f45

Browse files
Added stability value to the blame output.
1 parent d99e8cb commit 98e3f45

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

gitinspector/blame.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def __init__(self, hard):
174174
def output_html(self):
175175
blame_xml = "<div><div class=\"box\">"
176176
blame_xml += "<p>" + _(BLAME_INFO_TEXT) + ".</p><div><table id=\"blame\" class=\"git\">"
177-
blame_xml += "<thead><tr> <th>{0}</th> <th>{1}</th> <th>{2}</th> </tr></thead>".format(_("Author"),
178-
_("Rows"), _("% in comments"))
177+
blame_xml += "<thead><tr> <th>{0}</th> <th>{1}</th> <th>{2}</th> <th>{3}</th> </tr></thead>".format(_("Author"),
178+
_("Rows"), _("Stability"), _("% in comments"))
179179
blame_xml += "<tbody>"
180180
chart_data = ""
181181
blames = sorted(__blame__.get_summed_blames().items())
@@ -195,6 +195,8 @@ def output_html(self):
195195
blame_xml += "<td>" + entry[0] + "</td>"
196196

197197
blame_xml += "<td>" + str(entry[1].rows) + "</td>"
198+
blame_xml += "<td>" + ("{0:.1f}".format(100.0 * entry[1].rows /
199+
self.changes.get_authorinfo_list()[entry[0]].insertions) + "</td>")
198200
blame_xml += "<td>" + "{0:.2f}".format(100.0 * entry[1].comments / entry[1].rows) + "</td>"
199201
blame_xml += "<td style=\"display: none\">" + work_percentage + "</td>"
200202
blame_xml += "</tr>"
@@ -203,7 +205,7 @@ def output_html(self):
203205
if blames[-1] != entry:
204206
chart_data += ", "
205207

206-
blame_xml += "<tfoot><tr> <td colspan=\"3\">&nbsp;</td> </tr></tfoot></tbody></table>"
208+
blame_xml += "<tfoot><tr> <td colspan=\"4\">&nbsp;</td> </tr></tfoot></tbody></table>"
207209
blame_xml += "<div class=\"chart\" id=\"blame_chart\"></div></div>"
208210
blame_xml += "<script type=\"text/javascript\">"
209211
blame_xml += " $.plot($(\"#blame_chart\"), [{0}], {{".format(chart_data)
@@ -229,11 +231,12 @@ def output_text(self):
229231
terminal.clear_row()
230232

231233
print(textwrap.fill(_(BLAME_INFO_TEXT) + ":", width=terminal.get_size()[0]) + "\n")
232-
terminal.printb(_("Author").ljust(21) + _("Rows").rjust(10) + _("% in comments").rjust(20))
234+
terminal.printb(_("Author").ljust(21) + _("Rows").rjust(10) + _("Stability").rjust(15) + _("% in comments").rjust(20))
233235

234236
for i in sorted(__blame__.get_summed_blames().items()):
235237
print(i[0].ljust(20)[0:20], end=" ")
236238
print(str(i[1].rows).rjust(10), end=" ")
239+
print("{0:.1f}".format(100.0 * i[1].rows / self.changes.get_authorinfo_list()[i[0]].insertions).rjust(14), end=" ")
237240
print("{0:.2f}".format(100.0 * i[1].comments / i[1].rows).rjust(19))
238241

239242
def output_xml(self):
@@ -246,8 +249,11 @@ def output_xml(self):
246249
name_xml = "\t\t\t\t<name>" + i[0] + "</name>\n"
247250
gravatar_xml = "\t\t\t\t<gravatar>" + gravatar.get_url(author_email) + "</gravatar>\n"
248251
rows_xml = "\t\t\t\t<rows>" + str(i[1].rows) + "</rows>\n"
252+
stability_xml = ("\t\t\t\t<stability>" + "{0:.1f}".format(100.0 * i[1].rows /
253+
self.changes.get_authorinfo_list()[i[0]].insertions) + "</stability>\n")
249254
percentage_in_comments_xml = ("\t\t\t\t<percentage-in-comments>" + "{0:.2f}".format(100.0 * i[1].comments / i[1].rows) +
250255
"</percentage-in-comments>\n")
251-
blame_xml += "\t\t\t<author>\n" + name_xml + gravatar_xml + rows_xml + percentage_in_comments_xml + "\t\t\t</author>\n"
256+
blame_xml += ("\t\t\t<author>\n" + name_xml + gravatar_xml + rows_xml + stability_xml +
257+
percentage_in_comments_xml + "\t\t\t</author>\n")
252258

253259
print("\t<blame>\n" + message_xml + "\t\t<authors>\n" + blame_xml + "\t\t</authors>\n\t</blame>")

0 commit comments

Comments
 (0)