diff --git a/lib/henson/source/git.rb b/lib/henson/source/git.rb index ee7c653..50c9843 100644 --- a/lib/henson/source/git.rb +++ b/lib/henson/source/git.rb @@ -53,7 +53,11 @@ def initialize name, repo, opts = {} end def fetched? - File.directory? fetch_path + if @ref_type == :ref + return has_ref?(@target_revision) + else + File.directory? fetch_path + end end def fetch! diff --git a/spec/henson/source/git_spec.rb b/spec/henson/source/git_spec.rb index 127b7dd..655a8c1 100644 --- a/spec/henson/source/git_spec.rb +++ b/spec/henson/source/git_spec.rb @@ -10,8 +10,24 @@ expect(Henson::Source::Git.new("foo", :bar => :baz)).to_not be_fetched end - it "returns false if the repo does not have the correct revision" - it "returns true if cloned and the correct revision" + let(:git) do + lambda { |opts = {}| + Henson::Source::Git.new "osx_defaults", + "https://github.com/wfarr/puppet-osx_defaults", + opts + } + end + it "returns false if the repo does not have the correct revision" do + lgit = git.(:ref => "0123456") + lgit.fetch! + expect(lgit).to_not be_fetched + end + it "returns true if cloned and the correct revision" do + lgit = git.(:ref => "ff5e337") + lgit.fetch! + expect(lgit).to be_fetched + end + end describe "#fetch!" do