summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-12-23 01:03:57 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-12-23 01:03:57 +0100
commitdb2c15369c365340aeaf4e431e8838714b40396b (patch)
tree26ca045a337132370b67cc8f2ed4010e3087dfa5 /app/models/commit.rb
parentb47173da6a0fea0982d009f91e2c4d042f9b5c37 (diff)
parent68c43d59f09a66cca0da1b9a50c11421d52eac9a (diff)
downloadgitlab-ce-db2c15369c365340aeaf4e431e8838714b40396b.tar.gz
Merge branch 'master' into discussions
Conflicts: app/assets/stylesheets/main.scss app/models/project.rb app/views/notes/_common_form.html.haml app/views/notes/_per_line_form.html.haml lib/gitlab/markdown.rb spec/models/note_spec.rb
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 200c915a335..f11b7fe0202 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -87,14 +87,10 @@ class Commit
last = project.commit(from.try(:strip))
if first && last
- commits = [first, last].sort_by(&:created_at)
- younger = commits.first
- older = commits.last
-
- result[:same] = (younger.id == older.id)
- result[:commits] = project.repo.commits_between(younger.id, older.id).map {|c| Commit.new(c)}
- result[:diffs] = project.repo.diff(younger.id, older.id) rescue []
- result[:commit] = Commit.new(older)
+ result[:same] = (first.id == last.id)
+ result[:commits] = project.repo.commits_between(last.id, first.id).map {|c| Commit.new(c)}
+ result[:diffs] = project.repo.diff(last.id, first.id) rescue []
+ result[:commit] = Commit.new(first)
end
result
@@ -163,6 +159,8 @@ class Commit
while !lines.first.start_with?("diff --git") do
lines.shift
end
+ lines.pop if lines.last =~ /^[\d.]+$/ # Git version
+ lines.pop if lines.last == "-- " # end of diff
lines.join("\n")
end
end