Sha256: 0d666842577845efdec2e84cf662d2f5d09f2bc0fbd3f83962e7da7a7c679a94

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

require "git-hack/version"
require "git"
Dir["#{File.dirname(__FILE__)}/**/*.rb"].each { |f| require f }

module GitHack
	include PathCommon
	include SaveExecute
	def self.current
		@current || get_dir('.')
	end
	def self.commit
		current.commit	
	end
	private
	# get_dir(path) 检查给定目录是否在git受控目录中
	# 本身是git目录返回 GitProject
	# 本身不是,但上层是返回GitProject,并设置dir
	# 本身不是,上层也不是则返回RawDir
	def self.get_dir(path)
		return GitRepo.new(path) if is_git(path)		
		return get_dir(File.join(path,"/../"))
	end
	def self.is_git(path)
		File.directory?(File.join(path,"/.git"))
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git-hack-0.0.6 lib/git-hack.rb
git-hack-0.0.5 lib/git-hack.rb