新增:commit message关联issue操作状态
This commit is contained in:
parent
ba7f36c34c
commit
e8112212bb
|
@ -25,6 +25,12 @@ class CommitLogsController < ApplicationController
|
|||
commit_log.project_trends.create(user_id: user.id, project_id: project&.id, action_type: "create") if user.id !=2
|
||||
# 统计数据新增
|
||||
CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id)
|
||||
|
||||
# 触发变更issue状态的job
|
||||
close_issue_content = message.to_s.scan(/\b(Close|Closes|Closed|Closing|close|closes|closed|closing)\s*(#\d+(,\s*#\d+)*)?\b/)
|
||||
ChangeIssueStatusByMessageJob.perform_later(project, user, close_issue_content[0][1], 5) if close_issue_content[0].present? && close_issue_content[0][1].present?
|
||||
solve_issue_content = message.to_s.scan(/\b(Fix|Fixes|Fixed|Fixing|fix|fixes|fixed|fixing|Resolve|Resolves|Resolved|Resolving|resolve|resolves|resolved|resolving|Implement|Implements|Implemented|Implementing|implement|implements|implemented|implementing)\s*(#\d+(,\s*#\d+)*)?\b/)
|
||||
ChangeIssueStatusByMessageJob.perform_later(project, user, solve_issue_content[0][1], 3) if solve_issue_content[0].present? && solve_issue_content[0][1].present?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -77,4 +77,12 @@ module GitHelper
|
|||
cha_path = path.present? ? path.split(";") : []
|
||||
cha_path.reject(&:blank?)[0].try(:strip)
|
||||
end
|
||||
|
||||
def expain_issue_commit(commit_message)
|
||||
respace_arr= commit_message.to_s.scan(/#(\d+)/).map{|s|[s[0], "##{s[0]}"]}.uniq.sort_by{|s|-s[0].to_i}
|
||||
respace_arr.each do |item|
|
||||
issue = Issue.find_by_id(item[0].to_i)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
class ChangeIssueStatusByMessageJob < ApplicationJob
|
||||
queue_as :notify
|
||||
|
||||
# Close, Closes, Closed, Closing, close, closes, closed, closing
|
||||
# Fix, Fixes, Fixed, Fixing, fix, fixes, fixed, fixing
|
||||
# Resolve, Resolves, Resolved, Resolving, resolve, resolves, resolved, resolving
|
||||
# Implement, Implements, Implemented, Implementing, implement, implements, implemented, implementing
|
||||
# 以上关键词后接 issue_id 例如:Closes #234 Closes #123, #245, #992
|
||||
|
||||
def perform(project, user, tag_issue_id_content, status_id=1)
|
||||
Rails.logger.info "需要操作的issue_id内容为 #{tag_issue_id_content}"
|
||||
tag_issue_id_content = tag_issue_id_content.gsub(/\s+/, '')
|
||||
tag_issue_id_content.to_s.split(",").each do |tag_issue|
|
||||
issue_id = tag_issue.gsub('#', '')
|
||||
issue = project.issues.issue_issue.where(project_issues_index: issue_id).where.not(id: issue_id).take || Issue.issue_issue.find_by_id(issue_id)
|
||||
next unless issue.present? # issue不存在 跳过
|
||||
next if issue.project.present? && !user.admin? && !project.member?(user) # issue归属项目,用户没有修改issue的权限,跳过
|
||||
next if issue.pm_project_id.present? && project.owner.is_a?(Organization) && !project.owner.is_member?(user.id) # issue是组织下工作项,不具备组织的访问权限,跳过
|
||||
issue_project = issue.project || Project.new(id: 0, user_id: 0, name: 'pm_mm', identifier: 'pm_mm', is_public:true)
|
||||
if issue.pm_project_id.present?
|
||||
Api::Pm::Issues::UpdateService.call(issue_project, issue, {status_id: status_id}, user)
|
||||
else
|
||||
Api::V1::Issues::UpdateService.call(issue_project, issue, {status_id: status_id}, user)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue