Skip to content

Commit

Permalink
Merge pull request #140 from mmasaki/git_recursive
Browse files Browse the repository at this point in the history
Add "recursive" attribute to git resource
  • Loading branch information
ryotarai committed Jul 6, 2015
2 parents dc038d2 + b6947a3 commit c61b48a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/itamae/resource/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Git < Base
define_attribute :destination, type: String, default_name: true
define_attribute :repository, type: String, required: true
define_attribute :revision, type: String
define_attribute :recursive, default: false

def pre_action
case @current_action
Expand All @@ -29,7 +30,10 @@ def action_sync(options)
if run_specinfra(:check_file_is_directory, attributes.destination)
run_command_in_repo(['git', 'fetch', 'origin'])
else
run_command(['git', 'clone', attributes.repository, attributes.destination])
cmd = ['git', 'clone']
cmd << '--recursive' if attributes.recursive
cmd << attributes.repository << attributes.destination
run_command(cmd)
new_repository = true
end

Expand Down
4 changes: 4 additions & 0 deletions spec/integration/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
its(:stdout) { should match(/3116e170b89dc0f7315b69c1c1e1fd7fab23ac0d/) }
end

describe command('cd /tmp/git_repo_submodule/empty_repo && cat README.md') do
its(:stdout) { should match(/Empty Repo/) }
end

describe file('/tmp/created_by_itamae_user') do
it { should be_file }
it { should be_owned_by 'itamae' }
Expand Down
5 changes: 5 additions & 0 deletions spec/integration/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@
revision "v0.1.0"
end

git "/tmp/git_repo_submodule" do
repository "https://github.com/mmasaki/fake_repo_including_submodule.git"
recursive true
end

#####

execute "echo -n $HOME > /tmp/created_by_itamae_user" do
Expand Down

0 comments on commit c61b48a

Please sign in to comment.