Sha256: 9a3ed782cabb5b7b3133b83f6262f2b779a299b0bd84231df97916aaea716664

Contents?: true

Size: 1.74 KB

Versions: 25

Compression:

Stored size: 1.74 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

25 entries across 25 versions & 1 rubygems

Version Path
makit-0.0.57 lib/makit/cli/make.rb
makit-0.0.53 lib/makit/cli/make.rb
makit-0.0.52 lib/makit/cli/make.rb
makit-0.0.51 lib/makit/cli/make.rb
makit-0.0.50 lib/makit/cli/make.rb
makit-0.0.49 lib/makit/cli/make.rb
makit-0.0.47 lib/makit/cli/make.rb
makit-0.0.46 lib/makit/cli/make.rb
makit-0.0.45 lib/makit/cli/make.rb
makit-0.0.44 lib/makit/cli/make.rb
makit-0.0.42 lib/makit/cli/make.rb
makit-0.0.41 lib/makit/cli/make.rb
makit-0.0.35 lib/makit/cli/make.rb
makit-0.0.34 lib/makit/cli/make.rb
makit-0.0.33 lib/makit/cli/make.rb
makit-0.0.32 lib/makit/cli/make.rb
makit-0.0.31 lib/makit/cli/make.rb
makit-0.0.30 lib/makit/cli/make.rb
makit-0.0.29 lib/makit/cli/make.rb
makit-0.0.28 lib/makit/cli/make.rb