Sha256: d20a4af25bcddee82905545ced4dc6412729a875ce618204bc6475cc48a17ace

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

module Dev
class Scm
  attr_accessor :scm_type
  
  def initialize
    @scm_type="none"
    @scm_type="svn" if File.exists?(".svn")
    @scm_type="git" if File.exists?(".git")
  end
  
  def file_tracked?(file)
    if @scm_type=="git"
      call=Dev::SystemCall.new("git ls-files #{file} -error_unmatch")
      return true if call.status==0
    end
    false
  end
  
  def add_file(file)
    call=Dev::SystemCall.new("git add #{file}") if @scm_type=="git"
    
    if @scm_type=="svn"
      call=Dev::SystemCall.new("svn info #{file}")
      if(call.status != 0)
        call=Dev::SystemCall.new("svn add #{file} --parents")
        call.puts_summary
      end
    end
  end
  
  def add_file_glob(glob)
    Dir.glob(glob).each { |f|
      add_file(f)
    }
  end
  
  def self.export(remote,local,scm)
    puts_debug "Scm.export, scm=#{scm}"
    if remote.include?("svn:") || scm=="svn"
      local_tmp=local.gsub('@','-')
      call=Dev::SystemCall.new("svn export \"#{remote}\" \"#{local_tmp}\"")
      call.puts_summary
      if(local_tmp != local)
        sleep 2.5
        File.rename(local_tmp,local) if File.exist?(local_tmp)
        sleep 2.5
      end
    end
    if scm=="git"
      call=Dev::SystemCall.new("git clone #{remote} #{local}")
    end
  end
  
  def self.update(local)
  end
  
end # class Scm
end # module Dev

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dev-1.0.52 lib/dev/Scm.rb
dev-1.0.51 lib/dev/Scm.rb
dev-1.0.50 lib/dev/Scm.rb
dev-1.0.49 lib/dev/Scm.rb
dev-1.0.48 lib/dev/Scm.rb
dev-1.0.47 lib/dev/Scm.rb
dev-1.0.46 lib/dev/Scm.rb
dev-1.0.45 lib/dev/Scm.rb