class DoraBox::GitOperator
Public Class Methods
create_module_branch(base_module_version,module_name,branch_name)
click to toggle source
模块去创建分支
# File lib/doraBox/util/git_operator.rb, line 10 def self.create_module_branch(base_module_version,module_name,branch_name) module_path = File.join(WORKSPACE_PATH,"#{module_name}") # puts module_path # 判断模块文件夹是否存在 if File.exist?(module_path) # puts '模块文件夹存在' if Dir.chdir(module_path) system "git pull" # puts base_module_version system "git checkout #{base_module_version}" # 根据 tag 去创建 KA 定制项目的分支名,规则是 ka/项目名_定制版本号_公版分支 IO.popen("git checkout -b #{branch_name}") do |io| io.each do |line| puts line end end end else # 远程拉取仓库 module_repository_url = GIT_REPOSITORY_BASE_URL + "/#{module_name}" + ".git" puts module_repository_url if Dir.chdir(WORKSPACE_PATH) puts "正在clone #{module_name}仓库" system("git clone #{module_repository_url}") if Dir.chdir(module_path) # puts base_module_version # 根据 tag 去创建 KA 定制项目的分支名,规则是 ka/项目名_定制版本号_公版分支 IO.popen("git checkout #{base_module_version} && git checkout -b #{branch_name}") do |io| io.each do |line| puts line end end end end end end