Class: MSPRelease::CLI::Build

Inherits:
Command
  • Object
show all
Includes:
Debian::Versions
Defined in:
lib/msp_release/cli/build.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

#exec

Instance Method Details

#runObject



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
88
89
90
91
92
93
94
95
96
# File 'lib/msp_release/cli/build.rb', line 62

def run
  git_url          = arguments[:git_url]
  release_spec_arg = arguments[:branch_name]

  do_build         = options[:build]
  tar_it           = options[:tar]
  clone_depth      = options[:shallow] ? CLONE_DEPTH : nil

  LOG.silent if options[:silent]
  LOG.verbose if options[:verbose]
  LOG.noisy if options[:noisy]

  branch_name = release_spec_arg || 'master'

  shallow_output = clone_depth.nil?? '' : ' (shallow)'

  options[:shallow_output] = shallow_output

  # checkout project
  tmp_dir = "vershunt-#{Time.now.to_i}.tmp"
  Git.clone(git_url, {:depth => clone_depth, :out_to => tmp_dir,
                      :branch => branch_name, :no_single_branch => true,
                      :exec => {:quiet => true}})

  project = Project.new_from_project_file(tmp_dir + "/" + Helpers::PROJECT_FILE)

  project.prepare_for_build(branch_name, options)

  if project.respond_to?(:build)
    project.build(options)
  else
    raise "I don't know how to build this project"
  end

end