opscode/chef — pull request #1561 by sawanoboly (2014-06-26 06:01:57+00:00)
Title: Add environment resource attributer to scm resources

Allow run git command with environment variables.

For example, A remote repository which provides by https using self-signed cert.

```
git '/var/tmp/example' do
repository 'https://unsecure.example.com/example.git'
reference 'master'
action :sync
environment "GIT_SSL_NO_VERIFY" => "1"
end
```

Result of unit test below.

```
$ bundle exec rspec spec/unit/provider/git_spec.rb spec/unit/resource/git_spec.rb
DL is deprecated, please use Fiddle
Run options:
include {:focus=>true}
exclude {:provider=>#, :arch=>#, :requires_root_or_running_windows=>true, :requires_root=>true, :ruby_20_only=>true, :ruby_19_only=>true, :ruby_18_only=>true, :selinux_only=>true, :system_windows_service_gem_only=>true, :solaris_only=>true, :windows_domain_joined_only=>true, :windows32_only=>true, :windows64_only=>true, :win2k3_only=>true, :windows_only=>true, :volatile=>true, :external=>true}

All examples were filtered out; ignoring {:focus=>true}

Chef::Provider::Git
creates a current_resource with the currently deployed revision when a clone exists in the destination dir
keeps the node and resource passed to it on initialize
responds to :revision_slug as an alias for target_revision
runs a clone command with escaped destination
compiles a clone command using --depth for shallow cloning
compiles a clone command with a remote other than ``origin''
runs a checkout command with default options
runs an enable_submodule command
does nothing for enable_submodules if resource.enable_submodules #=> false
runs a sync command with default options
runs a sync command with the user and group specified in the resource
configures remote tracking branches when remote is ``origin''
configures remote tracking branches when remote is not ``origin''
raises an error if the git clone command would fail because the enclosing directory doesn't exist
does a checkout by cloning the repo and then enabling submodules
does not call checkout if enable_checkout is false
does a checkout by cloning the repo and then enabling submodules when the directory entries are listed as %w{.. .}
should not checkout if the destination exists or is a non empty directory
syncs the code by updating the source when the repo has already been checked out
marks the resource as updated when the repo is updated and gets a new version
does not fetch any updates if the remote revision matches the current revision
clones the repo instead of fetching it if the deploy directory doesn't exist
clones the repo instead of fetching updates if the deploy directory is empty
does an export by cloning the repo then removing the .git directory
determining the revision of the currently deployed checkout
sets the current revision to nil if the deploy dir does not exist
determines the current revision when there is one
gives the current revision as nil when there is no current revision
resolving revisions to a SHA
returns resource.revision as is if revision is already a full SHA
converts resource.revision from a tag to a SHA
converts resource.revision from an annotated tag to the tagged SHA (not SHA of tag)
raises an invalid remote reference error if you try to deploy from ``origin'' and assertions are run
raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run
does not raise an error if the revision can't be resolved when assertions are not run
does not raise an error when the revision is valid and assertions are run.
gives the latest HEAD revision SHA if nothing is specified
with an ssh wrapper
without a timeout set
clones a repo with default git options
with a timeout set
clones a repo with amended git options
configuring remote tracking branches
checks if a remote with this name already exists
runs the config with the user and group specified in the resource
when a remote with a given name hasn't been configured yet
adds a new remote
when a remote with a given name has already been configured
updates remote url when the url is different
doesn't update remote url when the url is the same
resets remote url when it has multiple values
calling add_remotes
adds a new remote for each entry in additional remotes hash
calling multiple_remotes?
when check remote command returns with status 2
returns true
when check remote command returns with status 0
returns false
when check remote command returns with status 0
returns false
calling remote_matches?
when output of the check remote command matches the repository url
returns true
when output of the check remote command doesn't match the repository url
returns false

Chef::Resource::Git
is a kind of Scm Resource
uses the git provider
uses aliases revision as branch
aliases revision as reference

Finished in 0.04756 seconds
53 examples, 0 failures
```