diff options
author | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2012-09-21 11:22:53 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2012-09-21 11:22:53 +0300 |
commit | 4cc169d3cacea7e4325bb5632cc8878a7c3f41fe (patch) | |
tree | 23b40276b4ff28bfa85d3755c25b5f3d8885c732 /app/models/commit.rb | |
parent | 49fe8fed11d5a8b73e15b507b214ea10b61524a5 (diff) | |
download | gitlab-ce-4cc169d3cacea7e4325bb5632cc8878a7c3f41fe.tar.gz |
Improve commits compare. Added tags to autocomplete. Dont look for commits if from & to are empty
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 15afedcb101..73583e9e7b7 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -82,20 +82,24 @@ class Commit end def compare(project, from, to) - first = project.commit(to.try(:strip)) - last = project.commit(from.try(:strip)) - result = { commits: [], diffs: [], - commit: nil + commit: nil, + same: false } + return result unless from && to + + first = project.commit(to.try(:strip)) + 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) |