Class: Docman::GitCopyRepoContent

Inherits:
Command
  • Object
show all
Defined in:
lib/docman/commands/git_copy_repo_content_cmd.rb

Instance Attribute Summary

Attributes inherited from Command

#type

Instance Method Summary collapse

Methods inherited from Command

#add_action, #add_actions, #config, create, #describe, #initialize, #perform, #prefix, register_command, #replace_placeholder, #run_actions, #run_with_hooks

Methods included from Logging

#log, logger, #logger, #prefix, #properties_info, #with_logging

Constructor Details

This class inherits a constructor from Docman::Command

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/docman/commands/git_copy_repo_content_cmd.rb', line 11

def execute
  if (self['remove_target'])
    FileUtils.rm_r(Dir["#{@context['full_build_path']}/*"]) if File.directory? @context['full_build_path']
  end
  FileUtils.rm_r @context['temp_path'] if @context.need_rebuild? and File.directory? @context['temp_path']
  @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version, nil, nil)
  # FileUtils.rm_r(File.join(@context['temp_path'], '.git')) if File.directory?(File.join(@context['temp_path'], '.git'))
  FileUtils.mkdir_p(@context['full_build_path'])
  `rsync -a --exclude '.git' #{@context['temp_path']}/. #{@context['full_build_path']}`
  @version
end

#validate_commandObject



6
7
8
9
# File 'lib/docman/commands/git_copy_repo_content_cmd.rb', line 6

def validate_command
  raise "Please provide 'context'" if @context.nil?
  raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
end