Sha256: 09a753ad9787d350c7d276e76855836676fb595a855f00bce27889d526162fa3

Contents?: true

Size: 576 Bytes

Versions: 39

Compression:

Stored size: 576 Bytes

Contents

module Awsborn
  class GitBranch

    attr_reader :branch

    def initialize (branch)
      require 'git'
      @branch = branch
    end
    
    def file (path)
      path, file = File.split(path)

      repo = Git.open(root)
      tree = repo.branches[branch].gcommit.gtree
      path.each { |dir| tree = tree.subtrees[dir] }
      tree.blobs[file].contents
    end

    protected

    def root
      dir = File.expand_path('.')
      while dir != '/'
        return dir if File.directory?(File.join(dir, '.git'))
        dir = File.dirname(dir)
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
awsborn-0.7.0 lib/awsborn/git_branch.rb
awsborn-0.6.0 lib/awsborn/git_branch.rb
awsborn-0.5.5 lib/awsborn/git_branch.rb
awsborn-0.5.4 lib/awsborn/git_branch.rb
awsborn-0.5.3 lib/awsborn/git_branch.rb
awsborn-0.5.2 lib/awsborn/git_branch.rb
awsborn-0.5.1 lib/awsborn/git_branch.rb
awsborn-0.5.0 lib/awsborn/git_branch.rb
awsborn-0.4.0 lib/awsborn/git_branch.rb
awsborn-0.3.9 lib/awsborn/git_branch.rb
awsborn-0.3.8 lib/awsborn/git_branch.rb
awsborn-0.3.7 lib/awsborn/git_branch.rb
awsborn-0.3.6 lib/awsborn/git_branch.rb
awsborn-0.3.5 lib/awsborn/git_branch.rb
awsborn-0.3.4 lib/awsborn/git_branch.rb
awsborn-0.3.3 lib/awsborn/git_branch.rb
awsborn-0.3.2 lib/awsborn/git_branch.rb
awsborn-0.3.1 lib/awsborn/git_branch.rb
awsborn-0.3.0 lib/awsborn/git_branch.rb