Class: Build::RepoModuleSource
- Inherits:
-
RepoModule
- Object
- Repo
- RepoModule
- Build::RepoModuleSource
- Defined in:
- lib/core_blur/repo_module_source.rb
Instance Attribute Summary
Attributes inherited from RepoModule
#build_item, #framework_name, #pod_name, #pod_version, #pod_version_final, #podspec_content, #podspec_json_path, #project_id, #snapshot, #third
Attributes inherited from Repo
#branch, #gitlab_helper, #http_url, #last_commit, #page_url, #path, #pusher, #repo_path, #size, #size_format, #ssh_url, #user_email, #user_name
Instance Method Summary collapse
- #force_cover_validate(repo_cocoapods_source) ⇒ Object
- #git_tag ⇒ Object
- #lock_branch_if_need ⇒ Object
- #update_podspec ⇒ Object
- #validate ⇒ Object
Methods inherited from RepoModule
#analyzer, #build_binary, #get_commit_msg, #git_clone, #git_commit, #initialize, #update_binary
Methods inherited from Repo
#clear, #discard_pull, #git_add_stag, #git_checkout, #git_clone, #git_commit, #git_fetch, #git_pull, #git_push, #git_push_f, #git_push_tags, #git_reset_hard, #git_status, #git_tag_delete_local, #git_tag_delete_origin, #git_tag_local, #git_tag_origin, #initialize, #push_code
Constructor Details
This class inherits a constructor from Build::RepoModule
Instance Method Details
#force_cover_validate(repo_cocoapods_source) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/core_blur/repo_module_source.rb', line 43 def force_cover_validate(repo_cocoapods_source) if build_item.force_cover puts "不校验commit信息是否包含上次,原因:force_cover = false" return end unless ssh_url.is_gitlab_url puts "不校验commit信息是否包含上次,原因:当前组件仓库非gitlab url, url = #{ssh_url}" return end pod_name_path = "#{repo_cocoapods_source.path}/#{pod_name}" unless File.directory?(pod_name_path) puts "不校验commit信息是否包含上次,原因:repo_cocoapods_source没有当前组件文件夹" return end pod_version_path = "#{pod_name_path}/#{pod_version_final}" unless File.directory?(pod_version_path) puts "不校验commit信息是否包含上次,原因:repo_cocoapods_source组件文件夹没有当前版本文件夹" return end podspec_json_path = "#{pod_version_path}/#{pod_name}.podspec.json" unless File.exist?(podspec_json_path) puts "不校验commit信息是否包含上次,原因:repo_cocoapods_source组件文件夹没有podspec.json文件" return end json = File.read(podspec_json_path) podspec_content = JSON.parse(json) commit_id = podspec_content["commitID"] committer = podspec_content["committer"] commit_msg = podspec_content["commitMsg"] commit_time = podspec_content["commitTime"] unless commit_id puts "不校验commit信息是否包含上次,原因:repo_cocoapods_source的podspec.json 读取commitID为空" return end contain = self.gitlab_helper.branch_contain_commit(project_id, branch, commit_id) puts "\n⏩ (#{File.basename(self.path)})上次发布的commit信息是:" puts "#{commit_id} #{commit_msg} #{commit_msg} #{commit_time}" if contain puts "校验commit信息是否包含上次:校验通过" else error = "当前发布分支#{branch}不包含上次发布的#{committer}提交, 请先合并分支再打包或手动选择强制覆盖" pusher.push("❌ 打包失败", error) Process.exit(-1) end end |
#git_tag ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'lib/core_blur/repo_module_source.rb', line 146 public def git_tag unless self.third super end if self.third and build_item.force_cover super end end |
#lock_branch_if_need ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/core_blur/repo_module_source.rb', line 29 def lock_branch_if_need if build_item.snapshot puts "当前源码仓库为SNAPSHOT包,无需锁死分支" return end if third puts "当前打包为三方库,无需锁死分支" return end puts "当前源码仓库(ID:#{project_id})打包模式为正式包,需锁死分支 #{branch}" gitlab_helper.lock_branch(project_id, branch) setting_url = "#{page_url}/-/settings/repository#js-protected-branches-settings" pusher.push("【✅组件分支已锁死无法提交】", "配置地址 #{setting_url}") end |
#update_podspec ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/core_blur/repo_module_source.rb', line 88 def update_podspec podspec_path = "#{self.path}/#{self.pod_name}.podspec" @podspec_json_path = "#{podspec_path}.json" if File.exist?(podspec_path) # 生成json文件 command = "pod ipc spec #{podspec_path} >> #{podspec_json_path}" res = system command unless res == true error = "命令执行失败: #{command}" pusher.push("❌ 打包失败", error) Process.exit(-1) end FileUtils.rm_rf(podspec_path) end unless File.exist?(podspec_json_path) error = "podspec文件不存在" pusher.push("❌ 打包失败", error) Process.exit(-1) end podspec = Podspec.new(podspec_json_path) podspec_content = podspec.podspec_content podspec_content.delete("license") podspec_content["source"]["git"] = ssh_url unless self.third podspec_content["version"] = pod_version_final podspec_content["source"]["tag"] = pod_version_final end if pod_name == "CocoaHTTPServer" podspec_content["pod_target_xcconfig"] = {'GCC_PREPROCESSOR_DEFINITIONS' => ['$(inherited)', 'DD_LEGACY_MACROS=1']} elsif pod_name == "Protobuf" podspec_content["pod_target_xcconfig"] = {'GCC_PREPROCESSOR_DEFINITIONS' => ['$(inherited)', 'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1']} end if pod_name == "MLeaksFinder" podspec_content["public_header_files"] << "MLeaksFinder/MLeaksMessenger.h" end podspec_content["address"] = http_url podspec_content["committer"] = last_commit.committer podspec_content["commitID"] = last_commit.commit_id podspec_content["commitMsg"] = last_commit.commit_msg podspec_content["commitTime"] = last_commit.commit_time podspec_content["desc"] = "这是一份自动生成的文件, 请勿手动修改" @podspec_content = podspec_content __update_framework_name(podspec_content) new_file = File.new(podspec_json_path, "w+") if new_file new_file.syswrite(JSON.pretty_generate(podspec_content)) end end |
#validate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/core_blur/repo_module_source.rb', line 10 def validate super if self.branch.start_with?("release_") branch_version = self.branch.gsub("release_", "") if branch_version != self.pod_version error = "以release_开头的分支,后边应该跟版本号,且打包的版本号与跟的版本号一致,例如当前#{self.branch}, 打包版本应该是#{branch_version}" pusher.push("❌ 打包失败", error) Process.exit(-1) end end version_pure_number = self.pod_version.gsub(".","").is_number? if self.branch != "master" and self.branch != self.pod_version and not self.third #特殊处理 if version_pure_number and not self.branch.start_with?("release_") error = "三段式的版本号打包,应使用release_开头的分支来打包,且打包的版本号与跟的版本号一致,例如当前#{self.pod_version},打包分支应该是release_#{self.pod_version}" pusher.push("❌ 打包失败", error) Process.exit(-1) end end end |