[#19] fixed check for commit comments
This commit is contained in:
parent
7736f69715
commit
ee5d4b5efd
|
@ -157,19 +157,25 @@ class Comment < ActiveRecord::Base
|
||||||
next unless issue
|
next unless issue
|
||||||
next if issue == item.try(:commentable) # dont create link to the same issue
|
next if issue == item.try(:commentable) # dont create link to the same issue
|
||||||
# dont create duplicate link to issue
|
# dont create duplicate link to issue
|
||||||
next if item.is_a?(Comment) && Comment.exists?(:automatic => true, :commentable_type => issue.class.name,
|
find_dup = {:automatic => true, :commentable_type => issue.class.name, :commentable_id => issue.id}
|
||||||
:commentable_id => issue.id, :created_from_issue_id => item.commentable_id)
|
if (item.commentable_type == 'Issue' &&
|
||||||
|
Comment.exists?(find_dup.merge :created_from_issue_id => item.commentable_id)) ||
|
||||||
|
(item.commentable_type == 'Grit::Commit' &&
|
||||||
|
Comment.exists?(find_dup.merge :created_from_commit_hash => item.commentable_id))
|
||||||
|
next
|
||||||
|
end
|
||||||
comment = linker.comments.new :body => 'automatic comment'
|
comment = linker.comments.new :body => 'automatic comment'
|
||||||
comment.commentable, comment.project, comment.automatic = issue, project, true
|
comment.commentable, comment.project, comment.automatic = issue, project, true
|
||||||
if item.is_a? Comment
|
comment.data = {:comment_id => item.id, :from_project_id => item.project.id}
|
||||||
comment.data = {:issue_serial_id => item.commentable.serial_id, :comment_id => item.id}
|
if item.is_a?(Comment) && item.commentable_type == 'Issue'
|
||||||
comment.created_from_issue_id = item.commentable_id
|
comment.created_from_issue_id = item.commentable_id
|
||||||
|
elsif item.is_a?(Comment) && item.commentable_type == 'Grit::Commit'
|
||||||
|
comment.created_from_commit_hash = item.commentable_id
|
||||||
elsif item.is_a? GitHook
|
elsif item.is_a? GitHook
|
||||||
repo_commit = git_hook.project.repo.commit element[0]
|
repo_commit = git_hook.project.repo.commit element[0]
|
||||||
next unless repo_commit
|
next unless repo_commit
|
||||||
comment.data = {commit_hash => commit[0]}
|
comment.data.merge! :commit_hash => commit[0]
|
||||||
end
|
end
|
||||||
comment.data.merge! :from_project_id => item.project.id
|
|
||||||
comment.save
|
comment.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue