Sha256: 3d5907b8bd36ad3278676b5634c555f6316b70dfd67345ff73fc1346270b9b69

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 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|
	  if(!f.include?("/obj/"))
        add_file(f)
	  end
    }
  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 15
        File.rename(local_tmp,local) if File.exist?(local_tmp)
        sleep 15
      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

4 entries across 4 versions & 1 rubygems

Version Path
dev-1.0.57 lib/dev/Scm.rb
dev-1.0.56 lib/dev/Scm.rb
dev-1.0.55 lib/dev/Scm.rb
dev-1.0.54 lib/dev/Scm.rb