Commit dd0ca323 by Nguyen Vo Huy Hoang

Merge branch 'hotfix/REPORT-format-link-pr' into 'master'

WORKFLOW-REPORT format link pr and issues

See merge request !17
parents 64d64a25 7f4c4bba
Pipeline #1627 failed with stages
in 0 seconds
......@@ -131,9 +131,11 @@ module WorkflowReport
result[3] << arr_issue.map { |issue| issue.time_entries.where("time_entries.spent_on BETWEEN ? AND ?", date_from, date_to).sum(:hours) }.sum.round(2)
request = ''
arr_issue.each do |issue|
if issue.tracker_id == USER_STORY_TRACKER_ID
jp = issue.custom_values.find_by(custom_field_id: JP_REQUEST_FIELD_ID)&.value
request = jp if jp.present?
end
end
result[2] << request
end
......@@ -204,8 +206,9 @@ module WorkflowReport
pr = { pr_comments: 0, pr_review_comments: 0, pr_commits: 0, pr_changed_files: 0, pr_additions: 0, pr_deletions: 0 }
if pull_request.present?
prs = pull_request.split("\r\n").compact
prs.each do |link|
prs = URI.extract(pull_request)
pr_urls = prs.grep(/\A#{URI::regexp(['http', 'https'])}\z/)
pr_urls.each do |link|
begin
pr_link_arr = URI(link.strip).path.split('/').reject!(&:empty?)
next unless pr_link_arr.length >= 4
......@@ -220,7 +223,7 @@ module WorkflowReport
pr[:pr_changed_files] += pr_detail.changed_files
end
rescue StandardError => e
error_links << "##{root_id} Error occurred during the build with the PR link:\r\n - #{link} \r\n - #{e.message.gsub(/(?<=access_token=).*/, '123')}"
error_links << "##{root_id} Error occurred during the build with the PR link:\r\n - #{link} \r\n - #{e.message.gsub(/(?<=access_token).*/, " #{pr_link_arr[1]}")}"
end
end
end
......@@ -237,7 +240,11 @@ module WorkflowReport
jp_request = jp_request.strip
result[32][row] = jp_request
begin
jp_request_arr = URI(jp_request).path.split('/').reject(&:blank?)
jp_request_arr = if jp_request =~ URI.regexp
URI(jp_request).path.split('/').reject(&:blank?)
else
[]
end
if jp_request_arr.length >= 4 && jp_request_arr[3].to_i.positive?
issue_detail = github.issues.find user: jp_request_arr[0], repo: jp_request_arr[1], number: jp_request_arr[3]
result[33][row] = issue_detail.success? ? issue_detail.comments : ''
......@@ -245,7 +252,7 @@ module WorkflowReport
result[33][row] = '' if result[33][row].nil?
end
rescue StandardError => e
error_links << "##{root_id} Error occurred during the build with the ISSUE link:\r\n - #{jp_request} \r\n - #{e.message.gsub(/(?<=access_token=).*/, '123')}"
error_links << "##{root_id} Error occurred during the build with the ISSUE link:\r\n - #{jp_request} \r\n - #{e.message.gsub(/(?<=access_token).*/, " #{jp_request_arr[1]}")}"
result[33][row] = '' if result[33][row].nil?
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment