Sha256: 432d01769ea3f8cf275d76d867ac3a98bd1ac8031770dd09167423ff98b315a8

Contents?: true

Size: 1.69 KB

Versions: 29

Compression:

Stored size: 1.69 KB

Contents

module Git

#*******************************************************************************
# Errors
  
class GitDirectoryError < StandardError 
end

#*******************************************************************************
# Base Git definition

class Base
 
  #-----------------------------------------------------------------------------
  # Constructor / Destructor
  
  def initialize(options = {})
    if working_dir = options[:working_directory]
      options[:repository] ||= File.join(working_dir, '.git')
      
      if File.file?(options[:repository])
        File.read(options[:repository]).each_line do |line|
          matches = line.match(/^\s*gitdir:\s*(.+)\s*/)
          if matches.length && matches[1]
            options[:repository] = matches[1]
            break
          end
        end        
      end
      
      if File.directory?(options[:repository])
        options[:index] ||= File.join(options[:repository], 'index')
      else
        raise GitDirectoryError.new("Git repository directory #{options[:repository]} not found for #{working_dir}")
      end
    end
    
    if options[:log]
      @logger = options[:log]
      @logger.info("Starting Git")
    else
      @logger = nil
    end
     
    @working_directory = options[:working_directory] ? Git::WorkingDirectory.new(options[:working_directory]) : nil
    @repository        = options[:repository] ? Git::Repository.new(options[:repository]) : nil 
    @index             = options[:index] ? Git::Index.new(options[:index], false) : nil
  end
    
  #-----------------------------------------------------------------------------
  # Commit extensions

  def add(path = '.', opts = {})
    self.lib.add(path, opts)
  end
end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
coral_core-0.2.25 lib/coral_core/util/git/base.rb
coral_core-0.2.24 lib/coral_core/util/git/base.rb
coral_core-0.2.19 lib/coral_core/util/git/base.rb
coral_core-0.2.18 lib/coral_core/util/git/base.rb
coral_core-0.2.17 lib/coral_core/util/git/base.rb
coral_core-0.2.16 lib/coral_core/util/git/base.rb
coral_core-0.2.15 lib/coral_core/util/git/base.rb
coral_core-0.2.14 lib/coral_core/util/git/base.rb
coral_core-0.2.13 lib/coral_core/util/git/base.rb
coral_core-0.2.12 lib/coral_core/util/git/base.rb
coral_core-0.2.11 lib/coral_core/util/git/base.rb
coral_core-0.2.10 lib/coral_core/util/git/base.rb
coral_core-0.2.9 lib/coral_core/util/git/base.rb
coral_core-0.2.8 lib/coral_core/util/git/base.rb
coral_core-0.2.7 lib/coral_core/util/git/base.rb
coral_core-0.2.6 lib/coral_core/util/git/base.rb
coral_core-0.2.5 lib/coral_core/util/git/base.rb
coral_core-0.2.4 lib/coral_core/util/git/base.rb
coral_core-0.2.3 lib/coral_core/util/git/base.rb
coral_core-0.2.2 lib/coral_core/util/git/base.rb