module QCloudHive::Project
Public Class Methods
init(cmd , opts)
click to toggle source
# File lib/qcloudhive/project.rb, line 11 def Project.init(cmd , opts) L.debug "#{opts}" name = GetOptValue(cmd, opts, "name") project = CodeOA.createProject(name) if CodeOA.empty?(project) == true puts "工程#{name}已经在CodeOA上存在,但是没有任何提交记录,还是个空工程,将对其进行初始化" Project.initLocalProject(project) else if File.exist?(name) Error "ERROR! the project local dirctory exist, can not cover it. please check" end workingPath = Pathname.new(name).to_path+"/" if Dir.mkdir(workingPath) !=0 Error "创建目录#{name}失败" end Project.repoInit(workingPath, project.http_url_to_repo) end end
initLocalProject(project)
click to toggle source
# File lib/qcloudhive/project.rb, line 40 def Project.initLocalProject(project) name = project.name if File.exist?(name) Error "ERROR! the project local dirctory exist, can not cover it. please check" end workingPath = Pathname.new(name).to_path+"/" if Dir.mkdir(workingPath) !=0 Error "创建目录#{name}失败" end L.debug "#{project}" git = Git.init(workingPath) git.add_remote("origin",project.http_url_to_repo) DZCopyFile(Config.templateManifestPath+".", workingPath, true) git.add(:all=>true) git.commit_all("project init") git.push Rake::sh("rm -rf #{workingPath}") if Dir.mkdir(workingPath) !=0 Error "创建目录#{name}失败" end Project.repoInit(workingPath, project.http_url_to_repo) end
repoInit(workingPath, url)
click to toggle source
# File lib/qcloudhive/project.rb, line 29 def Project.repoInit(workingPath, url) Rake::sh "cd #{workingPath} && repo init -u #{url} \n repo sync" manifestPath = workingPath + ".repo/manifests/default.xml" L.debug "#{manifestPath}" if File.exist?(manifestPath) == false Error "初始化失败,没有manifest配置文件" end manifest = Manifest.new(manifestPath) Rake::sh "cd #{workingPath} && repo start #{manifest.default.revision} --all" end