Commit c9db6bb3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

prevent app crash for events without git resources

parent f1799a23
...@@ -63,5 +63,19 @@ module Event::PushTrait ...@@ -63,5 +63,19 @@ module Event::PushTrait
"pushed to" "pushed to"
end end
end end
def parent_commit
commits.first.prev_commit
rescue => ex
nil
end
def last_commit
commits.last
end
def push_with_commits?
md_ref? && commits.any? && parent_commit && last_commit
end
end end
end end
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
= time_ago_in_words(event.created_at) = time_ago_in_words(event.created_at)
ago. ago.
- if event.md_ref? - if event.push_with_commits?
- if event.commits.count > 1 - if event.commits.count > 1
= link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do = link_to compare_project_commits_path(event.project, :from => event.parent_commit.id, :to => event.last_commit.id) do
%strong #{event.commits.first.commit.id[0..7]}...#{event.commits.last.id[0..7]} %strong #{event.commits.first.id[0..7]}...#{event.last_commit.id[0..7]}
- project = event.project - project = event.project
%ul.unstyled.event_commits %ul.unstyled.event_commits
- if event.commits.size > 3 - if event.commits.size > 3
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment