51 lines
1.1 KiB
Ruby
51 lines
1.1 KiB
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
|
|
|
|
# 判断是否允许创建Pull Request
|
|
# 如果分支相同,并且项目相同则提示
|
|
def judge_pr_allow
|
|
|
|
end
|
|
|
|
end
|