Class: Add

Inherits:
Array show all
Defined in:
lib/tasks/add.rb

Instance Attribute Summary

Attributes inherited from Array

#env

Instance Method Summary collapse

Methods inherited from Array

#add, #add_passive, #add_quiet, #execute, #has_command?, #initialize, #log_debug_info, #to_html

Constructor Details

This class inherits a constructor from Array

Instance Method Details

#updateObject


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
# File 'lib/tasks/add.rb', line 12

def update
  if File.exist?(".git") && File.exist?(".gitignore")
    add_quiet "git add --all"
  elsif defined?(SOURCE)
    if File.exist?(".svn")
      #---
      list_output = `svn list -R`
      status_output = `svn status`
      status_output = status_output.gsub(/\\/, "/")
      #---
      SOURCE.each do |f|
        if File.exist?(f) && File.file?(f) && !list_output.include?(f) && (m = status_output.match(/^(?<action>.)\s+(?<file>#{f})$/i)) && (m[:file] == f && m[:action] == "?")
          add_quiet "svn add \"#{f}\" --parents"
        end
      end
    end
    if File.exist?(".git")
      SOURCE.each do |f|
        if File.exist?(f) && File.file?(f)
          status = Command.output("git status #{f} --short")
          add_quiet "git add #{f} -v" if status.include?("??") || status.include?(" M ")
        end
      end
    end
  end

  log_debug_info("Add") if defined?(DEBUG)
end