Sha256: 6e1c937589d76f2c7d0ca24382e6500f216015efbe9c9fe385cadfb9fe9f2c2d

Contents?: true

Size: 1.79 KB

Versions: 28

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require "clamp"
#require "git"
require "socket"
require_relative "../humanize"

module Makit
  module Cli
    # Define the 'make' subcommand
    class MakeCommand < Clamp::Command
      parameter "GIT_REPOSITORY", "The git repository URL or NAME", attribute_name: :git_repository, required: true
      #option ["-f", "--force"], "FORCE", "Force the command to be run, even if a result already exists", attribute_name: :force

      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
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
makit-0.0.56 lib/makit/cli/make.rb
makit-0.0.55 lib/makit/cli/make.rb
makit-0.0.54 lib/makit/cli/make.rb
makit-0.0.48 lib/makit/cli/make.rb
makit-0.0.40 lib/makit/cli/make.rb
makit-0.0.39 lib/makit/cli/make.rb
makit-0.0.38 lib/makit/cli/make.rb
makit-0.0.37 lib/makit/cli/make.rb
makit-0.0.36 lib/makit/cli/make.rb
makit-0.0.26 lib/makit/cli/make.rb
makit-0.0.25 lib/makit/cli/make.rb
makit-0.0.24 lib/makit/cli/make.rb
makit-0.0.23 lib/makit/cli/make.rb
makit-0.0.22 lib/makit/cli/make.rb
makit-0.0.21 lib/makit/cli/make.rb
makit-0.0.20 lib/makit/cli/make.rb
makit-0.0.19 lib/makit/cli/make.rb
makit-0.0.16 lib/makit/cli/make.rb
makit-0.0.13 lib/makit/cli/make.rb
makit-0.0.12 lib/makit/cli/make.rb