45 lines
1017 B
Ruby
45 lines
1017 B
Ruby
module PullRequestsHelper
|
|
|
|
# 获取diff内容行号
|
|
def diff_line_num content
|
|
content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.nil? ? "" : content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i
|
|
end
|
|
|
|
# 处理内容
|
|
def diff_content content
|
|
content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'')
|
|
end
|
|
|
|
def get_user_name user_id
|
|
User.find(user_id).try(:login)
|
|
end
|
|
|
|
# 获取接受PullRequest用户的信息
|
|
def accept_user pull_request_id
|
|
PullRequest.where(:pull_request_id => pull_request_id).first
|
|
end
|
|
|
|
def get_state state
|
|
case state
|
|
when "open","reopened"
|
|
l(:label_state_open)
|
|
when "closed"
|
|
l(:label_state_closed)
|
|
when "merged"
|
|
l(:label_state_merged)
|
|
end
|
|
end
|
|
|
|
def type_count type, requests_opened_count, requests_merged_count, requests_closed_count
|
|
case type
|
|
when nil, "1"
|
|
requests_opened_count
|
|
when "2"
|
|
requests_merged_count
|
|
when "3"
|
|
requests_closed_count
|
|
end
|
|
end
|
|
|
|
end
|