[refs #265] Fix git push and delete branch partials and logic
This commit is contained in:
parent
f54d889f74
commit
7e53a6c511
|
@ -68,17 +68,18 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
||||||
project = Project.find_by_name(record.repo)
|
project = Project.find_by_name(record.repo)
|
||||||
|
|
||||||
last_commits = project.git_repository.repo.log(branch_name, nil).first(3)
|
last_commits = project.git_repository.repo.log(branch_name, nil).first(3)
|
||||||
first_commiter = User.find_by_email(last_commits[0].author.email) if last_commits.size > 0
|
first_commiter = User.find_by_email(last_commits[0].author.email) unless last_commits.blank?
|
||||||
last_commits = last_commits.collect do |commit| #:author => 'author'
|
last_commits = last_commits.collect do |commit| #:author => 'author'
|
||||||
[commit.sha, commit.message]
|
[commit.sha, commit.message]
|
||||||
end
|
end
|
||||||
|
|
||||||
if change_type == 'delete'
|
if change_type == 'delete'
|
||||||
kind = 'git_delete_branch_notification'
|
kind = 'git_delete_branch_notification'
|
||||||
options = {:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email, :project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type}
|
options = {:project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type}
|
||||||
else
|
else
|
||||||
kind = 'git_new_push_notification'
|
kind = 'git_new_push_notification'
|
||||||
options = {:project_id => project.id, :project_name => project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type}
|
options = {:project_id => project.id, :project_name => project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type}
|
||||||
|
options.merge!({:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email}) if first_commiter
|
||||||
end
|
end
|
||||||
|
|
||||||
project.owner_and_admin_ids.each do |recipient|
|
project.owner_and_admin_ids.each do |recipient|
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
.top
|
.top
|
||||||
.image
|
%span.date= activity_feed.created_at
|
||||||
=# image_tag(gravatar_url(activity_feed.user.email, 30))
|
%br
|
||||||
.text
|
%span.subject Branch #{ branch_name } has been deleted
|
||||||
%span.name
|
|
||||||
=# link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
|
|
||||||
%br
|
|
||||||
%span.date= activity_feed.created_at
|
|
||||||
%br
|
|
||||||
%span.subject Branch #{ branch_name } has been deleted
|
|
||||||
.both
|
.both
|
||||||
.fulltext
|
.fulltext
|
||||||
Into project #{ link_to(project_name, project_path(project_id)) }
|
Into project #{ link_to(project_name, project_path(project_id)) }
|
||||||
|
|
|
@ -1,15 +1,22 @@
|
||||||
.top
|
- if defined? user_email
|
||||||
.image
|
.top
|
||||||
= image_tag(gravatar_url(user_email, 30))
|
.image
|
||||||
.text
|
= image_tag(gravatar_url(user_email, 30))
|
||||||
%span.name
|
.text
|
||||||
= link_to user_name, user_path(user_id)
|
%span.name
|
||||||
%br
|
= link_to user_name, user_path(user_id)
|
||||||
%span.date= activity_feed.created_at
|
|
||||||
%br
|
%br
|
||||||
%span.subject Branch #{ branch_name } has been #{ change_type }d
|
%span.date= activity_feed.created_at
|
||||||
.both
|
%br
|
||||||
|
%span.subject Branch #{ branch_name } has been #{ change_type }d
|
||||||
|
.both
|
||||||
.fulltext
|
.fulltext
|
||||||
|
- unless defined? user_email
|
||||||
|
%span.date= activity_feed.created_at
|
||||||
|
%br
|
||||||
|
Branch #{ branch_name } has been #{ change_type }d
|
||||||
|
%br
|
||||||
|
%br
|
||||||
Into project #{ link_to(project_name, project_path(project_id)) }
|
Into project #{ link_to(project_name, project_path(project_id)) }
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
Loading…
Reference in New Issue