Class: MSPRelease::CLI::Checkout
- Includes:
- Debian::Versions
- Defined in:
- lib/msp_release/cli/checkout.rb
Constant Summary collapse
- CLONE_DEPTH =
When cloning repositories, limit to this many commits from each head
5
Instance Method Summary collapse
Methods included from Exec::Helpers
Instance Method Details
#run ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 135 136 137 138 139 140 |
# File 'lib/msp_release/cli/checkout.rb', line 74 def run git_url = arguments[:git_url] release_spec_arg = arguments[:branch_name] do_build = [:build] tar_it = [:tar] clone_depth = [:shallow] ? CLONE_DEPTH : nil LOG.verbose if [:noise] branch_name = release_spec_arg || 'master' pathspec = "origin/#{branch_name}" branch_is_release_branch = !! /^release-.+$/.match(branch_name) shallow_output = clone_depth.nil?? '' : ' (shallow)' if release_spec_arg && branch_is_release_branch LOG.debug("Checking out latest release commit from #{pathspec}#{shallow_output}") else LOG.debug("Checking out latest commit from #{pathspec}#{shallow_output}") end tmp_dir = "vershunt-#{Time.now.to_i}.tmp" Git.clone(git_url, {:depth => clone_depth, :out_to => tmp_dir, :exec => {:quiet => true}}) project = Project.new_from_project_file(tmp_dir + "/" + Helpers::PROJECT_FILE) distribution = [:distribution] || project.changelog.distribution src_dir = Dir.chdir(tmp_dir) do if pathspec != "origin/master" move_to(pathspec) end if branch_is_release_branch first_commit_hash, = find_first_release_commit(project) if first_commit_hash.nil? raise CLI::Exit, "Could not find a release commit on #{pathspec}" end exec "git reset --hard #{first_commit_hash}" else dev_version = Development. new_from_working_directory(branch_name, latest_commit_hash) project.changelog.amend(dev_version, distribution) end src_dir = project.source_package_name + "-" + project.changelog.version.to_s end FileUtils.mv(tmp_dir, src_dir) project = Project.new_from_project_file(src_dir + "/" + Helpers::PROJECT_FILE) LOG.debug("Checked out to #{src_dir}") if do_build LOG.debug("Building package...") build = Build.new(src_dir, project, :sign => [:sign]) result = build.perform_from_cli! if print_files? result.files.each {|f| stdout.puts(f) } end tar_it_up(project, result) if tar_it end end |