Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/henson/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
20 changes: 18 additions & 2 deletions spec/henson/source/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down