require_relative "utils.rb" require_relative "git_helper.rb" require "git" require 'versionomy' module QCloudHive class QCloudHiveFeature end def QCloudHive.startFeature(cmd, opts) end def QCloudHive.listFeature(cmd, opts) end def QCloudHive.pushFeature(cmd, opts) Config.manifest.projects.each { |p| if not p.gitRepo.clean? Error("模块:#{p.path} 在本地有未提交的修改,请检查并提交后再进行PUSH操作") end } Config.manifest.projects.each { |p| currentBranch = p.gitRepo.branches[p.gitRepo.current_branch] currentFreature = ProjectFeature.new(p, currentBranch) if currentFreature.remoteBranch.nil? puts "#{p.path} 提交 #{currentBranch.name}" L.info("#{p.gitRepo} git repo xxxxxx") p.gitRepo.push('origin', currentBranch.name, {"--set-upstream"=>currentBranch.name}) else compareRet = currentFreature.compareRemote if compareRet == 1 puts "#{p.path} 提交 #{currentBranch.name}" L.info("#{p.gitRepo} git repo") p.gitRepo.push('origin', currentBranch.name, {"--set-upstream"=>currentBranch.name}) elsif compareRet == -1 puts "#{p.path} 没有进行push操作 远端有新的修改,请及时Pull⬇️⬇️⬇️".blue else end end } end def QCloudHive.commitFeature(cmd, opts) message = GetOptValue(cmd, opts, :i_message) Config.manifest.projects.each { |p| if p.exsitLocal? git = p.gitRepo if (not git.nil?) and (not git.clean?) L.info("#{git.dir} commit clean #{git.clean?}") git.add(:all=>true) git.commit_all(message) else L.info("#{git.dir} is clean") end end } end def QCloudHive.checkDependencies(cmd, opts) Config.manifest.projects.each { |p| L.info("#{p.path} exist #{p.exsitLocal?}") if p.exsitLocal? and (not p.podspec.nil?) L.info("#{p.path}") version = Versionomy.parse(p.podspec.version.version) versionNumber = version.major*1000*1000 + version.minor*1000 + version.tiny str = " #ifndef #{p.moduleName}ModuleVersion_h #define #{p.moduleName}ModuleVersion_h #define #{p.moduleName}ModuleVersionNumber #{versionNumber} FOUNDATION_EXTERN NSString * const #{p.moduleName}ModuleVersion; FOUNDATION_EXTERN NSString * const #{p.moduleName}ModuleName; #endif " file = Pathname(p.localPath).join("Pod/Classes/#{p.moduleName}Version.h") File.open(file, "w") { |f| f.write str } file = Pathname(p.localPath).join("Pod/Classes/#{p.moduleName}Version.m") File.open(file, "w") { |f| f.write " #import \"#{p.moduleName}Version.h\" NSString * const #{p.moduleName}ModuleVersion = @\"#{p.podspec.version.version}\"; NSString * const #{p.moduleName}ModuleName = @\"#{p.moduleName}\"; " } end } end end