class Makit::Cli::MakeCommand

Define the ‘make’ subcommand

def execute

def execute
  begin
    # make sure a local clone of the repository exists

    clone_dir = Directories::get_clone_directory(git_repository)
    if Dir.exist?(clone_dir)
      # attempt to the pull the latest changes

      begin
        PullCommand::pull(git_repository)
      rescue => e
        puts "warning: failed to pull repository: #{git_repository}"
      end
    else
      CloneCommand::clone(git_repository)
    end
  rescue => e
    $stderr.puts "failed to make repository: #{git_repository}"
    puts "Please check the URL and your network connection."
    puts e.message
    exit 1
  end
  # determine the latest commit id for the repository

  g = Git.open(clone_dir)
  latest_commit = g.log.first
  commit = latest_commit.sha
  begin
    #make_result = MakeCommand::make(git_repository, commit)

    make_result = Makit::make(git_repository, commit)
    puts make_result.summary
  rescue => e
    $stderr.puts "failed to make repository: #{git_repository} commit: #{commit}"
    puts e.message
    puts Makit::Humanize::get_make_result_summary make_result
    exit 1
  end
end