Commit with none file changed may cause graphs failed
Created by: sugarmo
Summary
If a repostory has none-file-changed commit, graph will not working on it.
Steps to reproduce
- Add a commit with no file changed into repostory. (Usually it's a submodule update)
- See how is it in graphs.
Expected behavior
See a beautiful graph
Observed behavior
It give me such a confusing graph:
Output of checks
There is my git log with the same args with grit used:
This commit's log does not have 5 but only 3 lines, because it had no file changed.
Then convert to JSON, it go wrong:
If there is a null
in converted JSON:
Graphs will directly run into fail. (Appears "load graphs failed", as I said in #4218 (closed))
The implement in log_parser.rb has such a piece of code:
log.each_slice(5) do |slice|
entry = {}
entry[:author_name] = slice[0]
entry[:author_email] = slice[1]
entry[:date] = slice[2]
if slice[4]
changes = slice[4].split(",")
entry[:additions] = changes[1].to_i unless changes[1].nil?
entry[:deletions] = changes[2].to_i unless changes[2].nil?
end
collection.push(entry)
end
As we know now, there is no guarantee for that each commit has 5 lines log.