Sha256: 624bdf3a41d798f3c40adea5bc137b6bcb59b7ec79cd1e9be531a637f7194dfd

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

module Nucleon
module Util
class Git < ::Grit::Repo

  #-----------------------------------------------------------------------------
  # Constructor / Destructor

  def initialize(path, options = {})
    epath   = File.expand_path(path)
    git_dir = File.join(epath, '.git')
    
    @bare = (options[:is_bare] ? true : false)
    
    Grit.debug = true if Nucleon.log_level == :debug
    
    if File.exist?(git_dir)
      self.working_dir = epath
      
      if File.directory?(git_dir)
        self.path = git_dir
      else
        git_dir = Util::Disk.read(git_dir)
        unless git_dir.nil?
          git_dir = git_dir.gsub(/^gitdir\:\s*/, '').strip
          self.path = git_dir if File.directory?(git_dir)
        end
      end
      
    elsif File.directory?(epath) && (options[:is_bare] || (epath =~ /\.git$/ && File.exist?(File.join(epath, 'HEAD'))))
      self.path = epath
      @bare = true
      
    else
      self.path = git_dir
    end
    
    self.git = ::Grit::Git.new(self.path)
    self.git.work_tree = epath
  end
end
end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
nucleon-0.1.9 lib/core/util/git.rb
nucleon-0.1.8 lib/core/util/git.rb
nucleon-0.1.7 lib/core/util/git.rb
nucleon-0.1.6 lib/core/util/git.rb
nucleon-0.1.5 lib/core/util/git.rb
nucleon-0.1.4 lib/core/util/git.rb
nucleon-0.1.3 lib/core/util/git.rb
nucleon-0.1.2 lib/core/util/git.rb
nucleon-0.1.1 lib/core/util/git.rb