Module: Dev::Executables::Commands::Pull

Included in:
Dev::Executable
Defined in:
lib/dev/executables/commands/pull.rb

Instance Method Summary collapse

Instance Method Details

#pull(app = nil) ⇒ nil

Esegue il commit e il push del repository dell’app specificata.

Parameters:

  • app (String) (defaults to: nil)

    l’app per cui il push delle modifiche.

Returns:

  • (nil)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dev/executables/commands/pull.rb', line 12

def pull(app = nil)
  if app.present?
    apps = [ app ]
  else
    apps = project.apps
  end

  apps.each do |current_app|
    @project.current_app = current_app
    if @project.valid_app?
      @project.chdir_app
      current_branch = `git rev-parse --abbrev-ref HEAD`
      
      print "Preparing to pull app "
      print current_app.teal
      print " on branch "
      print current_branch.teal
      puts

      print "\tPulling.. "
      remote_message = exec "git pull origin #{current_branch}"
      if remote_message.include?('fatal') or remote_message.include?('rejected') or remote_message.include?('error')
        print "X\n".red
        puts "\t\tSomething went wrong, take a look at the output from git remote:".indianred
        puts "\t\t#{remote_message.split("\n").map(&:squish).join("\n\t\t")}".indianred
        puts
      else
        print "√\n".green
        puts "\t\tDone. Output from git remote:".cadetblue
        puts "\t\t#{remote_message.split("\n").map(&:squish).join("\n\t\t")}".cadetblue
        puts
      end
    end
  end
end