module DTK::Client::PullFromRemoteMixin::PullFromRemote

Public Class Methods

id_field(module_type) click to toggle source
# File lib/commands/common/thor/pull_from_remote.rb, line 146
def self.id_field(module_type)
  "#{module_type}_id"
end
perform_locally(cmd_obj,module_type,module_id,module_name,remote_params) click to toggle source
# File lib/commands/common/thor/pull_from_remote.rb, line 114
def self.perform_locally(cmd_obj,module_type,module_id,module_name,remote_params)
  opts = remote_params
  response = cmd_obj.Helper(:git_repo).pull_changes(module_type,module_name,opts)

  # return response unless response.ok?
  if custom_message = response.data[:custom_message]
    puts custom_message
  elsif (response.data[:diffs].nil? || response.data[:diffs].empty?)
    puts "No changes to pull from remote.".colorize(:yellow) unless response['errors']
  else
    puts "Changes pulled from remote".colorize(:green)
  end

  response
end
perform_on_server(cmd_obj,module_type,module_id,module_name,remote_params) click to toggle source
# File lib/commands/common/thor/pull_from_remote.rb, line 130
def self.perform_on_server(cmd_obj,module_type,module_id,module_name,remote_params)
  #TODO: this does not handle different namespaces; so suggesting workaround for now
  raise DtkError, "Module must be cloned to perform this operation; execute 'clone' command and then retry."
  post_body = {
    id_field(module_type) => module_id,
    :remote_repo => remote_params[:remote_repo],
    :module_name => module_name
  }
  post_body.merge!(:version => remote_params[:version]) if remote_params[:version]
  response = post rest_url("#{module_type}/pull_from_remote"), post_body


  puts "You have successfully pulled code on server instance." if response.ok?
  response
end