Class: KCommercial::KCPipeline::FeatureSender
- Inherits:
-
Object
- Object
- KCommercial::KCPipeline::FeatureSender
- Defined in:
- lib/KCommercialPipeline/core/feature_send.rb
Instance Method Summary collapse
- #check ⇒ Object
- #compare_trunk_diff ⇒ Object
- #data_to_markdown(diffs) ⇒ Object
- #diff_to_data(diffs) ⇒ Object
- #last_release_branch ⇒ Object
- #mentioned_list ⇒ Object
- #notify_kim(content) ⇒ Object
- #robot_keys ⇒ Object
Instance Method Details
#check ⇒ Object
9 10 11 |
# File 'lib/KCommercialPipeline/core/feature_send.rb', line 9 def check compare_trunk_diff end |
#compare_trunk_diff ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/KCommercialPipeline/core/feature_send.rb', line 21 def compare_trunk_diff last_rb_name = last_release_branch raise "未发现合法rb分支,任务结束!" if last_rb_name.nil? || last_rb_name.empty? diffs = KCBranchDiffs.new("develop", last_release_branch).diffs #读取配置正则 regular = KimConfig.configs["common_regulars"]["feat_regular"] unless regular.size > 0 regular = "^(\\[[a-zA-Z0-9]+\\])?feat(\\(.*\\))?:.*" end feats = diffs.find_all { |c| c. =~ /#{regular}/ } content = data_to_markdown(feats) notify_kim(content) end |
#data_to_markdown(diffs) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/KCommercialPipeline/core/feature_send.rb', line 44 def data_to_markdown(diffs) if diffs.empty? KCommercial::UI.info("本周暂无需求入版") title = "温馨提示:本周#{KimConfig.configs["common_cfg"]["app_name"]}可能暂无需求入版..." <<EOF # #{title} EOF else title = "温馨提示:本周#{KimConfig.configs["common_cfg"]["app_name"]}可能有<font color = red size =4 >#{diffs.count}个</font>feature 待封版" labels = ['feature', 'commit', 'author', "date"] table = MarkdownTables.make_table(labels, diff_to_data(diffs), is_rows: true, align: %w[l c c l]) <<EOF # #{title} #{table} EOF end end |
#diff_to_data(diffs) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/KCommercialPipeline/core/feature_send.rb', line 62 def diff_to_data(diffs) datas = [] KCommercial::UI.info("本周可能#{diffs.count}个需求入版") diffs.each do |c| data = [] msg = (c..split("\n\n")[0] || "").gsub("\n","").gsub(':',':') data << msg data << c.ori_commit_id || "" data << c.. || "" unless mentioned_list.include?(c..) mentioned_list << c.. end data << c.date || "" datas << data end datas end |
#last_release_branch ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/KCommercialPipeline/core/feature_send.rb', line 35 def last_release_branch branchs = BranchTool.all_release_branchs_sorted || [] unless branchs.size == 0 last_branch = branchs[-1] last_branch.name || "" end end |
#mentioned_list ⇒ Object
13 14 15 |
# File 'lib/KCommercialPipeline/core/feature_send.rb', line 13 def mentioned_list @mentioned_list ||= KimConfig.configs["FeatureSend"]["kim"]["mentioned_list"] || [] end |
#notify_kim(content) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/KCommercialPipeline/core/feature_send.rb', line 79 def notify_kim(content) kim_model = KimModel.new(MessageType::Markdown, "", content, "", mentioned_list) robot_keys.each do |robot_key| kim = Kim.new(robot_key, kim_model) kim.notifi_kim end end |