class Fastlane::Helper::GitlabLintLineParser
Attributes
git_commit[RW]
gitlab_changes_files[RW]
lines[RW]
lint_line_jsons[RW]
Public Class Methods
new(lint_line_jsons, gitlab_changes_files, git_commit)
click to toggle source
# File lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb, line 128 def initialize(lint_line_jsons, gitlab_changes_files, git_commit) @lint_line_jsons = lint_line_jsons @gitlab_changes_files = gitlab_changes_files @git_commit = git_commit end
Public Instance Methods
parse()
click to toggle source
从 lint_line_jsons
中【过滤出】gitlab_changes_files 存在修改的 <代码行>
-
1)
lint_line_jsons
: swiftlint.result.json 文件中扫描出的不符合规范的 <代码行> -
2)
gitlab_changes_files
: MR git commit 对应的所有改动的 <代码行>
# File lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb, line 140 def parse return @lines if @lines @lines = [] lint_line_jsons.each do |lint| lint_file = lint['file'] #=> 绝对路径: /Users/xiongzenghui/ci-jenkins/workspace/xxx-iOS-module/ZHDiagnosisTool/ZHDiagnosisTool/Classes/Core/ProviderContext.swift lint_line = lint['line'] # 从 【lint_line_jsons 所有行】中过滤出【gitlab_changes_files 变动行】lint 记录 gitlab_changes_files.each do |c| diff_new_path = c.new_path #=> 相对路径: ZHDiagnosisTool/Classes/Core/ProviderContext.swift diff_old_path = c.old_path next unless lint_file.include?(diff_new_path) #=> 增量 diff next unless c.line_numbers.include?(lint_line) #=> change line 发生 lint 事件 # fix path 相对路径 lint['new_path'] = diff_new_path lint['old_path'] = diff_old_path lint['commit'] = git_commit @lines.push(GitlabLintLine.new(lint)) end end @lines end