Sha256: 1d84b1f861108f6054577e21b0b876eed407c0d58c1701963afb46c24ede8cb1

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

module Dev
class Scm
  attr_accessor :scm_type
  
  def initialize
    @scm_type="none"
	call=Dev::SystemCall.new("svn info")
	@scm_type="svn" if call.output.include?("Last Changed Date:")
    @scm_type="svn" if File.exists?(".svn")
	call=Dev::SystemCall.new("git status")
	@scm_type="git" if call.output.include?("#")
    @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"
	  afile=file
	  afile="#{file}@" if afile.include?('@')

	  `svn info "#{afile}"`
	  status=$?.exitstatus 
	  if(status != 0)
        call=Dev::SystemCall.new("svn add \"#{afile}\" --parents")
        call.puts_summary
      end
    end
  end
  
  def add_file_glob(glob)
    Dir.glob(glob).each { |f|
	  if(!f.include?("/obj/") && 
	     !f.include?("/bin/") &&
		 !f.include?("/TestOutput/") &&
		 f.index("obj/") != 0 &&
		 f.index("bin/") != 0 )
        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

3 entries across 3 versions & 1 rubygems

Version Path
dev-1.0.202 lib/dev/Scm.rb
dev-1.0.201 lib/dev/Scm.rb
dev-1.0.200 lib/dev/Scm.rb