Permalink
Browse files

handle newlines in author / committer

This shouldn't technically be allowed but we've seen a few cases of
it in existing repositories on github.com so let's just deal with
it.
  • Loading branch information...
1 parent 568935d commit a9dbc43a2f8b82ce7698fa118466177a2929e45e @rtomayko rtomayko committed Jul 10, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/grit/commit.rb
View
@@ -148,8 +148,13 @@ def self.list_from_string(repo, text)
parents = []
parents << lines.shift.split.last while lines.first =~ /^parent/
- author, authored_date = self.actor(lines.shift)
- committer, committed_date = self.actor(lines.shift)
+ author_line = lines.shift
+ author_line << lines.shift if lines[0] !~ /^committer /
+ author, authored_date = self.actor(author_line)
+
+ committer_line = lines.shift
+ committer_line << lines.shift if lines[0] && lines[0] != '' && lines[0] !~ /^encoding/
+ committer, committed_date = self.actor(committer_line)
# not doing anything with this yet, but it's sometimes there
encoding = lines.shift.split.last if lines.first =~ /^encoding/

0 comments on commit a9dbc43

Please sign in to comment.