Class: AppCommand::GitPull

Inherits:
Convoy::ActionCommand::Base
  • Object
show all
Defined in:
lib/routes/git_pull.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/routes/git_pull.rb', line 5

def execute

    @opts = command_options
    @args = arguments
    @git = App::Git.new

    opts_validate
    opts_routing

end

#git_pullObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/routes/git_pull.rb', line 30

def git_pull

    @git.check_for_same_branch(App::Git::SAME_BRANCH_WARNING)
    branch_code = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
    branch_db = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB))
    if App::Terminal::prompt_yes_no("#{App::Terminal::format_action('pull')} the following repos:", [
        "#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE)))} will pull #{App::Terminal::format_branch(branch_code)} \xe2\x86\x92 #{App::Terminal::format_branch("origin/#{branch_code}")}",
        "#{App::Terminal::format_directory(@git.get_repo_shorthand(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_DB)))}   will pull #{App::Terminal::format_branch(branch_db)} \xe2\x86\x92 #{App::Terminal::format_branch("origin/#{branch_db}")}"
    ])
        @git.check_for_uncommitted_files(true)
        @git.repo_loop.each do |repo_dir|
            unless App::Terminal::command_capture("git pull origin #{@git.current_branch_for_repo(repo_dir)}", repo_dir)
                App::Terminal::warning('Something went wrong', "Not sure what the reason was, but doing a #{App::Terminal::format_command('git pull')} on #{App::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))} was unsuccessful.")
            end
        end
        @git.check_for_stash(true)
    end

end

#opts_routingObject



24
25
26
27
28
# File 'lib/routes/git_pull.rb', line 24

def opts_routing

    git_pull

end

#opts_validateObject



16
17
18
19
20
21
22
# File 'lib/routes/git_pull.rb', line 16

def opts_validate

    if @args[0].nil?
        @args[0] = @git.current_branch_for_repo(App::Config.param(App::Config::WORKSTATION_PATH_TO_BP_CODE))
    end

end