class Docman::CleanChangedCmd

Public Instance Methods

execute() click to toggle source

TODO: Keep files feature

# File lib/docman/commands/clean_changed_cmd.rb, line 12
def execute
  if File.directory? @context['full_build_path']
    if @context.need_rebuild?
      return false if @context['type'] == 'dir'
      return false if @context['type'] == 'single' and @context['build_type'] == :copy_builder and not GitUtil.repo?(@context['full_build_path'])
      return false if @context['type'] == 'root' and @context['build_type'] == :dir_builder and not GitUtil.repo?(@context['full_build_path'])
      return false if @context['type'] == 'root' and @context['build_type'] == :direct_builder and GitUtil.repo?(@context['full_build_path'])
      return false if @context['type'] == 'root_chain' and @context['build_type'] == :direct_builder and GitUtil.repo?(@context['full_build_path'])
      return false if @context['type'] == 'root_chain' and @context['build_type'] == :git_root_chain_builder and GitUtil.repo?(@context['full_build_path'])
      if @context['type'] == 'repo'
        if @context['build_type'] == :direct_builder
          return false if GitUtil.repo?(@context['full_build_path'])
        end
      end
      log("Remove #{@context['full_build_path']}")
      FileUtils.rm_rf @context['full_build_path']
    end
  end
end
validate_command() click to toggle source
# File lib/docman/commands/clean_changed_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