Sha256: 76ad8aad8f2beed706a5ad435c86636d4598f876aefe18da8d6b55dd3ffebbc1

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

module Git
	def self.repo? path
		begin
			self.open path
			return true
		rescue
			return false
		end
	end

	class Branches
		def current
			select{ |b| b.current? }.first
		end
	end

	class Branch
		def current?
			current	
		end

		def up_to_date?
			ahead_count == 0 && behind_count == 0
		end

		def ahead
			origin = self.remotes(:origin)
			return [] if origin.nil?
			@base.log.between(origin.full, self.name)
		end

		def behind
			origin = self.remotes(:origin)
			return [] if origin.nil?
			@base.log.between(self.name, origin.full)
		end

		def ahead_count
			@ahead_count ||= ahead.count
		end

		def behind_count
			@behind_count ||= behind.count
		end

		def remotes(remote_name = nil)
			result = @base.branches.remote.select{|b| b.name == self.name }
			return result.select{|b| b.full.include? remote_name.to_s }.first unless remote_name.nil?
			return result 
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git-status-all-1.1.3 lib/git/status_all/git.rb
git-status-all-1.1.2 lib/git/status_all/git.rb
git-status-all-1.1.0 lib/git/status_all/git.rb