Sha256: 90cd5e6db2003464891f1049c93bd2870ac08c45ae5be923cbe62bdc066cc527
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
# encoding: utf-8 #-- # Copyright (C) 2012 Gitorious AS # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. #++ module Dolt module Git class Tree attr_reader :path, :entries def initialize(path, entries) @path = path @entries = entries end def self.parse(path, ls_tree_payload) path = path == "" ? "./" : path entries = ls_tree_payload.split("\n").collect do |line| pieces = line.split(/\s+/) klass = pieces[1] == "blob" ? File : Dir klass.new(pieces[3], pieces[2], pieces[0]) end dirs = entries.reject { |e| e.file? }.sort_by(&:path) files = entries.reject { |e| e.dir? }.sort_by(&:path) new(path, dirs + files) end class Entry attr_reader :full_path, :path, :sha, :mode def initialize(path, sha, mode) @full_path = path @path = ::File.basename(path) @sha = sha @mode = mode end def file?; false; end def dir?; false; end end class File < Entry def file?; true; end end class Dir < Entry def dir?; true; end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dolt-0.1.1 | ./lib/dolt/git/tree.rb |