lib/heirloom/directory/git_directory.rb in heirloom-0.5.0rc2 vs lib/heirloom/directory/git_directory.rb in heirloom-0.5.0rc3
- old
+ new
@@ -9,16 +9,25 @@
def initialize(args)
@path = args[:path]
end
def commit(sha = nil)
- repo = Repo.new @path
+ return false unless repo
+
if sha
commit = repo.commits(sha)
commit ? commit.first : false
else
repo.commits.first
end
+ end
+
+ private
+
+ def repo
+ Repo.new @path
+ rescue Grit::InvalidGitRepositoryError
+ false
end
end
end