Class: Pindo::Command::Repo::Clone

Inherits:
Pindo::Command::Repo show all
Defined in:
lib/pindo/command/repo/clone.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pindo::Command

run

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from Githelper

#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag

Methods included from Executable

capture_command, #executable, execute_command, which, which!

Constructor Details

#initialize(argv) ⇒ Clone

Returns a new instance of Clone.



31
32
33
34
35
36
37
# File 'lib/pindo/command/repo/clone.rb', line 31

def initialize(argv)

    @args_repo_name = argv.shift_argument
    super(argv)
    @additional_args = argv.remainder!

end

Class Method Details

.optionsObject



24
25
26
27
28
# File 'lib/pindo/command/repo/clone.rb', line 24

def self.options
  [

  ].concat(super)
end

Instance Method Details

#runObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/pindo/command/repo/clone.rb', line 61

def run

    new_branch = "master"
    if !@code_git_url.nil? && !@repo_name.nil?
        puts
        puts "Repo Name: #{@repo_name}"
        puts "Repo Url: #{@code_git_url}"
        puts "New Branch: #{new_branch}"

        getcode_to_dir(reponame:@repo_name, remote_url:@code_git_url, path:Dir.pwd, new_branch:new_branch, new_tag:nil)

    end
end

#validate!Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pindo/command/repo/clone.rb', line 41

def validate!
    super
    temp_config_file = "./config.json"
    @repo_name = @args_repo_name if @args_repo_name
    if @args_repo_name.nil? && @repo_name.nil?
        if File::exist?(temp_config_file)
            temp_config_file_fullname=File::expand_path(temp_config_file)
            temp_config_json=JSON.parse(File.read(temp_config_file_fullname))
            if temp_config_json['project_info'] && temp_config_json['project_info']['launch_project'] && temp_config_json['project_info']['launch_project']['project_git_url']
                @code_git_url = temp_config_json['project_info']['launch_project']['project_git_url']
                temp_url = String.new(@code_git_url)
                index = temp_url.rindex('/')
                temp_url = temp_url.slice(index + 1, temp_url.length)
                @repo_name = temp_url.gsub!(/\.git/, "")
            end
        end
    end
end