socialforge/app/helpers/pull_requests_helper.rb

18 lines
396 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
end