diff options
-rw-r--r-- | .sync.yml | 5 | ||||
-rw-r--r-- | .travis.yml | 18 | ||||
-rw-r--r-- | CHANGELOG.md | 71 | ||||
-rw-r--r-- | Gemfile | 26 | ||||
-rw-r--r-- | README.markdown | 1221 | ||||
-rw-r--r-- | examples/p4/create_client.pp | 4 | ||||
-rw-r--r-- | examples/p4/delete_client.pp | 4 | ||||
-rw-r--r-- | examples/p4/latest_client.pp | 6 | ||||
-rw-r--r-- | examples/p4/sync_client.pp | 8 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 80 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/svn.rb | 7 | ||||
-rw-r--r-- | lib/puppet/type/vcsrepo.rb | 14 | ||||
-rw-r--r-- | metadata.json | 2 | ||||
-rw-r--r-- | spec/acceptance/clone_repo_spec.rb | 24 | ||||
-rw-r--r-- | spec/acceptance/modules_753_spec.rb | 68 | ||||
-rw-r--r-- | spec/spec_helper_acceptance.rb | 22 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/git_spec.rb | 32 | ||||
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/svn_spec.rb | 43 |
18 files changed, 1038 insertions, 617 deletions
@@ -1,6 +1,11 @@ --- .travis.yml: script: "\"bundle exec rake spec SPEC_OPTS='--format documentation'\"" + extras: + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" Rakefile: unmanaged: true spec/spec_helper.rb: diff --git a/.travis.yml b/.travis.yml index 8cfaf23..727f6e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ --- +sudo: false language: ruby bundler_args: --without system_tests script: "bundle exec rake spec SPEC_OPTS='--format documentation'" @@ -6,12 +7,21 @@ matrix: fast_finish: true include: - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" - - rvm: 1.8.7 - env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + env: PUPPET_GEM_VERSION="~> 3.0" - rvm: 1.9.3 env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 2.0.0 + - rvm: 2.1.5 env: PUPPET_GEM_VERSION="~> 3.0" + - rvm: 2.1.5 + env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + allow_failures: + - rvm: 2.1.6 + env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes" notifications: email: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b8f7d1..ad10e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,55 +1,71 @@ -##2014-11-04 - Supported Release 1.2.0 -###Summary +# Change Log +All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.3.0] - 2015-05-19 Supported Release +### Summary +This release adds git provider remote handling, svn conflict resolution, and fixes the git provider when /tmp is mounted noexec. + +### Added +- `source` property now takes a hash of sources for the git provider's remotes +- Add `submodules` parameter to skip submodule initialization for git provider +- Add `conflict` to svn provider to resolve conflicts +- Add `branch` parameter to specify clone branch +- Readme rewrite + +### Fixed +- The git provider now works even if `/tmp` is noexec + +## [1.2.0] - 2014-11-04 Supported Release +### Summary This release includes some improvements for git, mercurial, and cvs providers, and fixes the bug where there were warnings about multiple default providers. -####Features +### Added - Update git and mercurial providers to set UID with `Puppet::Util::Execution.execute` instead of `su` - Allow git excludes to be string or array - Add `user` feature to cvs provider -####Bugfixes +### Fixed - No more warnings about multiple default providers! (MODULES-428) -##2014-07-14 - Supported Release 1.1.0 -###Summary -This release adds a Perforce provider* and corrects the git provider behavior +## [1.1.0] - 2014-07-14 Supported Release +### Summary +This release adds a Perforce provider\* and corrects the git provider behavior when using `ensure => latest`. -*(Only git provider is currently supported.) +\*(Only git provider is currently supported.) -####Features +### Added - New Perforce provider -####Bugfixes +### Fixed - (MODULES-660) Fix behavior with `ensure => latest` and detached HEAD - Spec test fixes -##2014-06-30 - Supported Release 1.0.2 -###Summary +## [1.0.2] - 2014-06-30 Supported Release +### Summary This supported release adds SLES 11 to the list of compatible OSs and documentation updates for support. -##2014-06-17 - Supported Release 1.0.1 -###Summary +## [1.0.1] - 2014-06-17 Supported Release +### Summary This release is the first supported release of vcsrepo. The readme has been greatly improved. -####Features +### Added - Updated and expanded readme to follow readme template -####Fixes +### Fixed - Remove SLES from compatability metadata - Unpin rspec development dependencies - Update acceptance level testing -##2014-06-04 - Version 1.0.0 -###Summary +## [1.0.0] - 2014-06-04 +### Summary This release focuses on a number of bugfixes, and also has some new features for Bzr and Git. -####Features +### Added - Bzr: - Call set_ownership - Git: @@ -57,7 +73,7 @@ new features for Bzr and Git. - Use -a and desired for HARD resets - Use rev-parse to get tag canonical revision -####Fixes +### Fixed - HG: - Only add ssh options when it's talking to the network - Git: @@ -68,14 +84,14 @@ new features for Bzr and Git. - SVN: - Fix svnlook behavior with plain directories -##2013-11-13 - Version 0.2.0 -###Summary +## 0.2.0 - 2013-11-13 +### Summary This release mainly focuses on a number of bugfixes, which should significantly improve the reliability of Git and SVN. Thanks to our many contributors for all of these fixes! -####Features +### Added - Git: - Add autorequire for Package['git'] - HG: @@ -88,7 +104,7 @@ our many contributors for all of these fixes! - CVS: - Allow for setting the CVS_RSH environment variable. -####Fixes +### Fixed - Handle Puppet::Util[::Execution].withenv for 2.x and 3.x properly. - Change path_empty? to not do full directory listing. - Overhaul spec tests to work with rspec2. @@ -108,3 +124,10 @@ our many contributors for all of these fixes! - Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'. - CVS: - Documented the "module" attribute. + +[1.3.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.2.0...1.3.0 +[1.2.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.1.0...1.2.0 +[1.1.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.0.2...1.1.0 +[1.0.2]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.0.1...1.0.2 +[1.0.1]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.0.0...1.0.1 +[1.0.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/0.2.0...1.0.0 @@ -1,20 +1,38 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" +def location_for(place, fake_version = nil) + if place =~ /^(git:[^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end + group :development, :unit_tests do - gem 'rake', :require => false - gem 'rspec-puppet', :require => false + gem 'rspec-core', '3.1.7', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', :require => false gem 'simplecov', :require => false gem 'puppet_facts', :require => false gem 'json', :require => false end group :system_tests do - gem 'beaker-rspec', :require => false + if beaker_version = ENV['BEAKER_VERSION'] + gem 'beaker', *location_for(beaker_version) + end + if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end gem 'serverspec', :require => false + gem 'beaker-puppet_install_helper', :require => false end + + if facterversion = ENV['FACTER_GEM_VERSION'] gem 'facter', facterversion, :require => false else diff --git a/README.markdown b/README.markdown index 6c6f0a5..badb1ce 100644 --- a/README.markdown +++ b/README.markdown @@ -1,577 +1,742 @@ -#vcsrepo +#vcsrepo
+
+####Table of Contents
+
+1. [Overview](#overview)
+2. [Module Description - What the module does and why it is useful](#module-description)
+3. [Setup - The basics of getting started with vcsrepo](#setup)
+ * [Setup requirements](#setup-requirements)
+ * [Beginning with vcsrepo](#beginning-with-vcsrepo)
+4. [Usage - Configuration options and additional functionality](#usage)
+ * [Git](#git)
+ * [Bazaar](#bazaar)
+ * [CVS](#cvs)
+ * [Mercurial](#mercurial)
+ * [Perforce](#perforce)
+ * [Subversion](#subversion)
+5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
+ * [Type: vcsrepo](#type-vcsrepo)
+ * [Providers](#providers)
+ * [Features](#features)
+ * [Parameters](#parameters)
+5. [Limitations - OS compatibility, etc.](#limitations)
+6. [Development - Guide for contributing to the module](#development)
+
+##Overview
+
+The vcsrepo module lets you use Puppet to easily deploy content from your version control system (VCS).
+
+##Module Description
+
+The vcsrepo module provides a single type with providers to support the following version control systems:
+
+* [Git](#git)
+* [Bazaar](#bazaar)
+* [CVS](#cvs)
+* [Mercurial](#mercurial)
+* [Perforce](#perforce)
+* [Subversion](#subversion)
+
+**Note:** `git` is the only vcs provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported).
+
+##Setup
+
+###Setup Requirements
+
+The `vcsrepo` module does not install any VCS software for you. You must install a VCS before you can use this module.
+
+Like Puppet in general, the `vcsrepo` module does not automatically create parent directories for the files it manages. Make sure to set up any needed directory structures before you get started.
+
+###Beginning with vcsrepo
+
+To create and manage a blank repository, define the type `vcsrepo` with a path to your repository and supply the `provider` parameter based on the [VCS you're using](#usage).
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+}
+~~~
+
+##Usage
+
+**Note:** `git` is the only vcsrepo provider officially [supported by Puppet Labs](https://forge.puppetlabs.com/supported).
+
+###Git
+
+####Create a blank repository
+
+To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+}
+~~~
+
+If you're managing a central or official repository, you might want to make it a bare repository. To do this, set `ensure` to 'bare':
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => bare,
+ provider => git,
+}
+~~~
+
+####Clone/pull a repository
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+}
+~~~
+
+By default, `vcsrepo` will use the HEAD of the source repository's master branch. To use another branch or a specific commit, set `revision` to either a branch name or a commit SHA or tag.
+
+Branch name:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => 'development',
+}
+~~~
+
+SHA:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
+}
+~~~
+
+Tag:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => '1.1.2rc1',
+}
+~~~
+
+To check out a branch as a specific user, supply the `user` parameter:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31',
+ user => 'someUser',
+}
+~~~
+
+To keep the repository at the latest revision, set `ensure` to 'latest'.
+
+**WARNING:** this overwrites any local changes to the repository:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ revision => 'master',
+}
+~~~
+
+To clone the repository but skip initializing submodules, set `submodules` to 'false':
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => git,
+ source => 'git://example.com/repo.git',
+ submodules => false,
+}
+~~~
+
+####Use multiple remotes with a repository
+In place of a single string, you can set `source` to a hash of one or more name => URL pairs:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => git,
+ remote => 'origin'
+ source => {
+ 'origin' => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git',
+ 'other_remote' => 'https://github.com/other_user/puppetlabs-vcsrepo.git'
+ },
+}
+~~~
+
+**Note:** if you set `source` to a hash, one of the names you specify must match the value of the `remote` parameter. That remote serves as the upstream of your managed repository. +
+####Connect via SSH
+
+To connect to your source repository via SSH (e.g., 'username@server:…'), we recommend managing your SSH keys with Puppet and using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure they are present before the `vcsrepo` resource is applied.
+
+To use SSH keys associated with a user, specify the username in the `user` parameter:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => git,
+ source => 'git://username@example.com/repo.git',
+ user => 'toto', #uses toto's $HOME/.ssh setup
+ require => File['/home/toto/.ssh/id_rsa'],
+}
+~~~ +
+###Bazaar
+
+####Create a blank repository
+
+To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => bzr,
+}
+~~~
+
+####Branch from an existing repository
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => bzr,
+ source => '/some/path',
+}
+~~~
+
+To branch from a specific revision, set `revision` to a valid [Bazaar revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec):
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => bzr,
+ source => '/some/path',
+ revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x',
+}
+~~~
+
+####Connect via SSH
+
+To connect to your source repository via SSH (e.g., `'bzr+ssh://...'` or `'sftp://...,'`), we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied:
+ +~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => bzr,
+ source => 'bzr+ssh://bzr.example.com/some/path',
+ user => 'toto', #uses toto's $HOME/.ssh setup
+ require => File['/home/toto/.ssh/id_rsa'],
+}
+~~~ +
+###CVS
+
+####Create a blank repository
+
+To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => cvs,
+}
+~~~
+
+####Checkout/update from a repository
+
+~~~
+vcsrepo { '/path/to/workspace':
+ ensure => present,
+ provider => cvs,
+ source => ':pserver:anonymous@example.com:/sources/myproj',
+}
+~~~
+
+To get a specific module on the current mainline, supply the `module` parameter:
+
+~~~
+vcsrepo {'/vagrant/lockss-daemon-source':
+ ensure => present,
+ provider => cvs,
+ source => ':pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss',
+ module => 'lockss-daemon',
+}
+~~~
+
+To set the GZIP compression levels for your repository history, use the `compression` parameter:
+
+~~~
+vcsrepo { '/path/to/workspace':
+ ensure => present,
+ provider => cvs,
+ compression => 3,
+ source => ':pserver:anonymous@example.com:/sources/myproj',
+}
+~~~
+
+To get a specific revision, set `revision` to the revision number.
+
+~~~
+vcsrepo { '/path/to/workspace':
+ ensure => present,
+ provider => cvs,
+ compression => 3,
+ source => ':pserver:anonymous@example.com:/sources/myproj',
+ revision => '1.2',
+}
+~~~ + +You can also set `revision` to a tag:
+ +~~~
+vcsrepo { '/path/to/workspace':
+ ensure => present,
+ provider => cvs,
+ compression => 3,
+ source => ':pserver:anonymous@example.com:/sources/myproj',
+ revision => 'SOMETAG',
+}
+~~~ +
+####Connect via SSH
+
+To connect to your source repository via SSH, we recommend using the [`require`](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied:
+ +~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => cvs,
+ source => ':pserver:anonymous@example.com:/sources/myproj',
+ user => 'toto', #uses toto's $HOME/.ssh setup
+ require => File['/home/toto/.ssh/id_rsa'],
+}
+~~~
+
+###Mercurial
+
+####Create a blank repository
+
+To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => hg,
+}
+~~~
+
+####Clone/pull & update a repository
+
+To get the default branch tip:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => hg,
+ source => 'http://hg.example.com/myrepo',
+}
+~~~
+
+For a specific changeset, use `revision`:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => hg,
+ source => 'http://hg.example.com/myrepo',
+ revision => '21ea4598c962',
+}
+~~~
+
+You can also set `revision` to a tag:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => hg,
+ source => 'http://hg.example.com/myrepo',
+ revision => '1.1.2',
+}
+~~~
+
+To check out as a specific user:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => hg,
+ source => 'http://hg.example.com/myrepo',
+ user => 'user',
+}
+~~~
+
+To specify an SSH identity key:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => hg,
+ source => 'ssh://hg@hg.example.com/myrepo',
+ identity => '/home/user/.ssh/id_dsa1,
+}
+~~~
+
+To specify a username and password for HTTP Basic authentication:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => hg,
+ source => 'http://hg.example.com/myrepo',
+ basic_auth_username => 'hgusername',
+ basic_auth_password => 'hgpassword',
+}
+~~~
+
+####Connect via SSH
+
+To connect to your source repository via SSH (e.g., `'ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied:
+ +~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => hg,
+ source => 'ssh://hg.example.com//path/to/myrepo',
+ user => 'toto', #uses toto's $HOME/.ssh setup
+ require => File['/home/toto/.ssh/id_rsa'],
+}
+~~~
+
+###Perforce
+ +####Create an empty workspace + +To set up the connection to your Perforce service, set `p4config` to the location of a valid Perforce [config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles) stored on the node: + +~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => p4,
+ p4config => '/root/.p4config'
+}
+~~~
+ +**Note:** If you don't include the `P4CLIENT` setting in your config file, the provider generates a workspace name based on the digest of `path` and the node's hostname (e.g., `puppet-91bc00640c4e5a17787286acbe2c021c`): + +####Create/update and sync a Perforce workspace
+
+To sync a depot path to head, set `ensure` to 'latest':
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => p4,
+ source => '//depot/branch/...'
+}
+~~~
+
+To sync to a specific changelist, specify its revision number with the `revision` parameter:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => p4,
+ source => '//depot/branch/...',
+ revision => '2341'
+}
+~~~
+
+You can also set `revision` to a label:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => p4,
+ source => '//depot/branch/...',
+ revision => 'my_label'
+}
+~~~
+
+###Subversion
+
+####Create a blank repository
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => svn,
+}
+~~~
+
+####Check out from an existing repository
+
+Provide a `source` pointing to the branch or tag you want to check out:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => svn,
+ source => 'svn://svnrepo/hello/branches/foo',
+}
+~~~
+
+You can also designate a specific revision:
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => svn,
+ source => 'svn://svnrepo/hello/branches/foo',
+ revision => '1234',
+}
+~~~
+
+####Use a specific Subversion configuration directory
+
+Use the `configuration` parameter to designate the directory that contains your Subversion configuration files (typically, '/path/to/.subversion'):
+
+~~~
+vcsrepo { '/path/to/repo':
+ ensure => present,
+ provider => svn,
+ source => 'svn://svnrepo/hello/branches/foo',
+ configuration => '/path/to/.subversion',
+}
+~~~
+
+####Connect via SSH
+
+To connect to your source repository via SSH (e.g., `'svn+ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied:
+ +~~~
+vcsrepo { '/path/to/repo':
+ ensure => latest,
+ provider => svn,
+ source => 'svn+ssh://svnrepo/hello/branches/foo',
+ user => 'toto', #uses toto's $HOME/.ssh setup
+ require => File['/home/toto/.ssh/id_rsa'],
+}
+~~~
+
+##Reference
+
+###Type: vcsrepo
+
+The vcsrepo module adds only one type with several providers. Each provider abstracts a different VCS, and each provider includes a set of features according to its needs.
+
+####Providers
+
+**Note:** Not all features are available with all providers.
+
+#####`git` - Supports the Git VCS.
+
+Features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `submodules`, `user` +
+Parameters: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`
+
+#####`bzr` - Supports the Bazaar VCS.
+
+Features: `reference_tracking`
+
+Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source` +
+#####`cvs` - Supports the CVS VCS.
+
+Features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`
+ +Parameters: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider` +
+#####`hg` - Supports the Mercurial VCS.
+
+Features: `reference_tracking`, `ssh_identity`, `user` +
+Parameters: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` +
+#####`p4` - Supports the Perforce VCS.
+
+Features: `p4config`, `reference_tracking` +
+Parameters: `ensure`, `excludes`, `force`, `group`, `owner`, `p4config`, `path`, `provider`, `revision`, `source` +
+#####`svn` - Supports the Subversion VCS.
+
+Features: `basic_auth`, `configuration`, `conflict`, `filesystem_types`, `reference_tracking` + +Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`
+
+####Features
+
+**Note:** Not all features are available with all providers.
+
+* `bare_repositories` - Differentiates between bare repositories and those with working copies. (Available with `git`.)
+* `basic_auth` - Supports HTTP Basic authentication. (Available with `svn`.) +* `conflict` - Lets you decide how to resolve any conflicts between the source repository and your working copy. (Available with `svn`.)
+* `configuration` - Lets you specify the location of your configuration files. (Available with `svn`.)
+* `cvs_rsh` - Understands the `CVS_RSH` environment variable. (Available with `cvs`.)
+* `depth` - Supports shallow clones. (Available with `git`.)
+* `filesystem_types` - Supports multiple types of filesystem. (Available with `svn`.)
+* `gzip_compression` - Supports explicit GZip compression levels. (Available with `cvs`.)
+* `modules` - Lets you choose a specific repository module. (Available with `cvs`.)
+* `multiple_remotes` - Tracks multiple remote repositories. (Available with `git`.)
+* `reference_tracking` - Lets you track revision references that can change over time (e.g., some VCS tags and branch names). (Available with all providers)
+* `ssh_identity` - Lets you specify an SSH identity file. (Available with `git` and `hg`.)
+* `user` - Can run as a different user. (Available with `git`, `hg` and `cvs`.)
+* `p4config` - Supports setting the `P4CONFIG` environment. (Available with `p4`.)
+* `submodules` - Supports repository submodules which can be optionally initialized. (Available with `git`.)
+
+####Parameters
+
+All parameters are optional, except where specified otherwise. + +##### `basic_auth_password` -[![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-vcsrepo) +Specifies the password for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. -####Table of Contents +##### `basic_auth_username` -1. [Overview](#overview) -2. [Module Description - What the module does and why it is useful](#module-description) -3. [Setup - The basics of getting started with vcsrepo](#setup) - * [Beginning with vcsrepo](#beginning-with-vcsrepo) -4. [Usage - Configuration options and additional functionality](#usage) - * [Bazaar](#bazaar) - * [CVS](#cvs) - * [Git](#git) - * [Mercurial](#mercurial) - * [Perforce](#perforce) - * [Subversion](#subversion) -5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) - * [Type: vcsrepo](#type-vcsrepo) - * [Providers](#providers) - * [Features](#features) - * [Parameters](#parameters) - * [Features and Parameters by Provider](#features-and-parameters-by-provider) -5. [Limitations - OS compatibility, etc.](#limitations) -6. [Development - Guide for contributing to the module](#development) +Specifies the username for HTTP Basic authentication. (Requires the `basic_auth` feature.) Valid options: a string. Default: none. -##Overview +##### `compression` -The vcsrepo module allows you to use Puppet to easily deploy content from your version control system (VCS). +Sets the GZIP compression level for the repository history. (Requires the `gzip_compression` feature.) Valid options: an integer between 0 and 6. Default: none. -##Module Description +##### `configuration` -This module provides a single type with providers for each VCS, which can be used to describe: +Sets the configuration directory to use. (Requires the `configuration` feature.) Valid options: a string containing an absolute path. Default: none. -* A working copy checked out from a (remote or local) source, at an - arbitrary revision -* A blank working copy not associated with a source (when it makes - sense for the VCS being used) -* A blank central repository (when the distinction makes sense for the VCS - being used) +##### `conflict` -##Setup +Tells Subversion how to resolve any conflicts between the source repository and your working copy. (Requires the `conflict` feature.) Valid options: 'base', 'mine-full', 'theirs-full', and 'working'. Default: none. -Before you begin using vcsrepo, it's worth keeping in mind that this module will not install VCS software for you. If you are going to use this module, you must have already installed your preferred VCS. +##### `cvs_rsh` -Also, this module, like Puppet generally, will not create parent directories for you. You will need to have your parent directories in place before you begin. +Provides a value for the `CVS_RSH` environment variable. (Requires the `cvs_rsh` feature.) Valid options: a string. Default: none. -###Beginning with vcsrepo +##### `depth` -To get started with the vcsrepo module, you must simply define the type `vcsrepo` with a path to your repository and the [type of VCS](#Usage) you're using in `provider` (in the below example, Git). +Sets the number of commits to include when creating a shallow clone. (Requires the `depth` feature.) Valid options: an integer. Default: none. - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - } +##### `ensure` -##Usage +Specifies whether the repository should exist. Valid options: 'present', 'bare', 'absent', and 'latest'. Default: 'present'. -The vcsrepo module works with the following VCSs: +##### `excludes` -* [Git (git)](#git)* -* [Bazaar (bzr)](#bazaar) -* [CVS (cvs)](#cvs) -* [Mercurial (hg)](#mercurial) -* [Perforce (p4)](#perforce) -* [Subversion (svn)](#subversion) +Lists any files the repository shouldn't track (similar to .gitignore). Valid options: a string (separate multiple values with the newline character). Default: none. -**Note:** Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. +##### `force` +Specifies whether to delete any existing files in the repository path if creating a new repository. **Use with care.** Valid options: 'true' and 'false'. Default: 'false'. -###Git +##### `fstype` -#####To create a blank repository +Sets the filesystem type. (Requires the `filesystem_types` feature.) Valid options: 'fsfs' or 'bdb'. Default: none. -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. +##### `group` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - } +Specifies a group to own the repository files. Valid options: a string containing a group name or GID. Default: none. -If you're defining `vcsrepo` for a central or official repository, you may want to make it a bare repository. You do this by setting `ensure` to 'bare' rather than 'present'. +##### `identity` - vcsrepo { "/path/to/repo": - ensure => bare, - provider => git, - } +Specifies an identity file to use for SSH authentication. (Requires the `ssh_identity` feature.) Valid options: a string containing an absolute path. Default: none. -#####To clone/pull a repository +##### `module` -To get the current HEAD on the master branch, +Specifies the repository module to manage. (Requires the `modules` feature.) Valid options: a string containing the name of a CVS module. Default: none. - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => "git://example.com/repo.git", - } +##### `owner` -To get a specific revision or branch (can be a commit SHA, tag, or branch name), +Specifies a user to own the repository files. Valid options: a string containing a username or UID. Default: none. - **SHA** +##### `p4config` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - } +Specifies a config file that contains settings for connecting to the Perforce service. (Requires the `p4config` feature.) Valid options: a string containing the absolute path to a valid [Perforce config file](http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.configuration.html#configuration.settings.configfiles). Default: none. -**Tag** +##### `path` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '1.1.2rc1', - } +Specifies a location for the managed repository. Valid options: a string containing an absolute path. Default: the title of your declared resource. -**Branch name** +##### `provider` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => 'development', - } +*Required.* Specifies the backend to use for this vcsrepo resource. Valid options: 'bzr', 'cvs', 'git', 'hg', 'p4', and 'svn'. -To check out a branch as a specific user, +##### `remote` - vcsrepo { "/path/to/repo": - ensure => present, - provider => git, - source => 'git://example.com/repo.git', - revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', - user => 'someUser', - } +Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) Valid options: a string containing one of the remote names specified in `source`. Default: 'origin'. -To keep the repository at the latest revision (**WARNING:** this will always overwrite local changes to the repository), +##### `revision` - vcsrepo { "/path/to/repo": - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - revision => 'master', - } +Sets the revision of the repository. Valid options vary by provider: -To clone the repository but skip initialiazing submodules, +* `git` - a string containing a Git branch name, or a commit SHA or tag +* `bzr` - a string containing a Bazaar [revision spec](http://wiki.bazaar.canonical.com/BzrRevisionSpec) +* `cvs` - a string containing a CVS [tag or revision number](http://www.thathost.com/wincvs-howto/cvsdoc/cvs_4.html) +* `hg` - a string containing a Mercurial [changeset ID](http://mercurial.selenic.com/wiki/ChangeSetID) or [tag](http://mercurial.selenic.com/wiki/Tag) +* `p4` - a string containing a Perforce [change number, label name, client name, or date spec](http://www.perforce.com/perforce/r12.1/manuals/cmdref/o.fspecs.html) +* `svn` - a string containing a Subversion [revision number](http://svnbook.red-bean.com/en/1.7/svn.basic.in-action.html#svn.basic.in-action.revs), [revision keyword, or revision date](http://svnbook.red-bean.com/en/1.7/svn.tour.revs.specifiers.html) - vcsrepo { "/path/to/repo": - ensure => latest, - provider => git, - source => 'git://example.com/repo.git', - submodules => false, - } +Default: none. -#####Sources that use SSH +##### `source` -When your source uses SSH, such as 'username@server:…', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. +Specifies a source repository to serve as the upstream for your managed repository. Default: none. Valid options vary by provider: -For SSH keys associated with a user, enter the username in the `user` parameter. Doing so will use that user's keys. +* `git` - a string containing a [Git repository URL](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a) or a hash of name => URL mappings. See also [`remote`](#remote). +* `bzr` - a string containing a Bazaar branch location +* `cvs` - a string containing a CVS root +* `hg` - a string containing the local path or URL of a Mercurial repository +* `p4` - a string containing a Perforce depot path +* `svn` - a string containing a Subversion repository URL - user => 'toto' # will use toto's $HOME/.ssh setup +Default: none. -#####Further Examples +##### `submodules` -For more examples using Git, see `examples/git/`. +Specifies whether to initialize and update each submodule in the repository. (Requires the `submodules` feature.) Valid options: 'true' and 'false'. Default: 'true'. -###Bazaar +##### `user` -#####Create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - } - -#####Branch from an existing repository - -Provide the `source` location to branch from an existing repository. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - source => 'lp:myproj', - } - -For a specific revision, use `revision` with a valid revisionspec -(see `bzr help revisionspec` for more information on formatting a revision). - - vcsrepo { "/path/to/repo": - ensure => present, - provider => bzr, - source => 'lp:myproj', - revision => 'menesis@pov.lt-20100309191856-4wmfqzc803fj300x', - } - -#####Sources that use SSH - -When your source uses SSH, for instance 'bzr+ssh://...' or 'sftp://...,' -you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -#####Further examples - -For more examples using Bazaar, see `examples/bzr/`. - -###CVS - -#####To create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => cvs, - } - -#####To checkout/update from a repository - -To get the current mainline, - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - source => ":pserver:anonymous@example.com:/sources/myproj", - } - -To get a specific module on the current mainline, - - vcsrepo {"/vagrant/lockss-daemon-source": - ensure => present, - provider => cvs, - source => ":pserver:anonymous@lockss.cvs.sourceforge.net:/cvsroot/lockss", - module => "lockss-daemon", - } - - -You can use the `compression` parameter to set the GZIP compression levels for your repository history. - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj", - } - -For a specific tag, use `revision`. - - vcsrepo { "/path/to/workspace": - ensure => present, - provider => cvs, - compression => 3, - source => ":pserver:anonymous@example.com:/sources/myproj", - revision => "SOMETAG", - } - -#####Sources that use SSH - -When your source uses SSH, you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -#####Further examples - -For for more examples using CVS, see `examples/cvs/`. - -###Mercurial - -#####To create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - } - -#####To clone/pull & update a repository - -To get the default branch tip, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - } - -For a specific changeset, use `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - revision => '21ea4598c962', - } - -You can also set `revision` to a tag. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - revision => '1.1.2', - } - -To check out as a specific user, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "http://hg.example.com/myrepo", - user => 'user', - } - -To specify an SSH identity key, - - vcsrepo { "/path/to/repo": - ensure => present, - provider => hg, - source => "ssh://hg@hg.example.com/myrepo", - identity => "/home/user/.ssh/id_dsa, - } - -To specify a username and password for HTTP Basic authentication, - - vcsrepo { "/path/to/repo": - ensure => latest, - provider => hg, - source => 'http://hg.example.com/myrepo', - basic_auth_username => 'hgusername', - basic_auth_password => 'hgpassword', - } - -#####Sources that use SSH - -When your source uses SSH, such as 'ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -#####Further Examples - -For more examples using Mercurial, see `examples/hg/`. - -###Perforce - -#####To create an empty Workspace - -To create an empty Workspace, define a `vcsrepo` without a `source` or `revision`. The -Environment variables P4PORT, P4USER, etc... are used to define the Perforce server -connection settings. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4 - } - -If no `P4CLIENT` environment name is provided a workspace generated name is calculated -based on the Digest of path and hostname. For example: - - puppet-91bc00640c4e5a17787286acbe2c021c - -A Perforce configuration file can be used by setting the `P4CONFIG` environment or -defining `p4config`. If a configuration is defined, then the environment variable for -`P4CLIENT` is replaced. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - p4config => '.p4config' - } - -#####To create/update and sync a Perforce workspace - -To sync a depot path to head, ensure `latest`: - - vcsrepo { "/path/to/repo": - ensure => latest, - provider => p4, - source => '//depot/branch/...' - } - -For a specific changelist, ensure `present` and specify a `revision`: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => '2341' - } - -You can also set `revision` to a label: - - vcsrepo { "/path/to/repo": - ensure => present, - provider => p4, - source => '//depot/branch/...', - revision => 'my_label' - } - -#####To authenticate against the Perforce server - -Either set the environment variables `P4USER` and `P4PASSWD` or use a configuration file. -For secure servers set the `P4PASSWD` with a valid ticket generated using `p4 login -p`. - -#####Further Examples - -For examples you can run, see `examples/p4/` - -###Subversion - -#####To create a blank repository - -To create a blank repository suitable for use as a central repository, -define `vcsrepo` without `source` or `revision`. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - } - -#####To check out from a repository - -Provide a `source` pointing to the branch/tag you want to check out from a repository. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - } - -You can also provide a specific revision. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - revision => '1234', - } - -#####Using a specific Subversion configuration directory - -To use a specific configuration directory, provide a `configuration` parameter which should be a directory path on the local system where your svn configuration files are. Typically, it is '/path/to/.subversion'. - - vcsrepo { "/path/to/repo": - ensure => present, - provider => svn, - source => "svn://svnrepo/hello/branches/foo", - configuration => "/path/to/.subversion", - } - -#####Sources that use SSH - -When your source uses SSH, such as 'svn+ssh://...', you can manage your SSH keys with Puppet using the [require](http://docs.puppetlabs.com/references/stable/metaparameter.html#require) metaparameter in `vcsrepo` to ensure they are present. - -####Further examples - -For more examples using Subversion, see `examples/svn/`. - -##Reference - -###Type: vcsrepo - -The vcsrepo module is slightly unusual in that it is simply a type and providers. Each provider abstracts a different VCS, and a series of features are available to each provider based on its specific needs. - -####Providers - -**Note**: Not all features are available with all providers. - -* `git` - Supports the Git VCS. (Contains features: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`.) -* `bar` - Supports the Bazaar VCS. (Contains features: `reference_tracking`.) -* `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `user`.) -* `dummy` - -* `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.) -* `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.) -* `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.) - -####Features - -**Note**: Not all features are available with all providers. - -* `bare_repositories` - The provider differentiates between bare repositories and those with working copies. (Available with `git`.) -* `basic_auth` - The provider supports HTTP Basic Authentication. (Available with `svn`.) -* `configuration` - The provider supports setting the configuration path.(Available with `svn`.) -* `cvs_rsh` - The provider understands the CVS_RSH environment variable. (Available with `cvs`.) -* `depth` - The provider can do shallow clones. (Available with `git`.) -* `filesystem_types` - The provider supports different filesystem types. (Available with `svn`.) -* `gzip_compression` - The provider supports explicit GZip compression levels. (Available with `cvs`.) -* `modules` - The provider allows specific repository modules to be chosen. (Available with `cvs`.) -* `multiple_remotes` - The repository tracks multiple remote repositories. (Available with `git`.) -* `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.) -* `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.) -* `user` - The provider can run as a different user. (Available with `git`, `hg` and `cvs`.) -* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.) -* `submodules` - The provider supports repository submodules which can be optionally initialized. (Available with `git`.) - -####Parameters - -* `basic_auth_password` - Specifies the HTTP Basic Authentication password. (Requires the `basic_auth` feature.) -* `basic_auth_username` - Specifies the HTTP Basic Authentication username. (Requires the `basic_auth` feature.) -* `compression` - Set the GZIP compression levels for your repository history. (Requires the `gzip_compression` feature.) -* `configuration` - Sets the configuration directory to use. (Requires the `configuration` feature.) -* `cvs_rsh` - The value to be used for the CVS_RSH environment variable. (Requires the `cvs_rsh` feature.) -* `depth` - The value to be used to do a shallow clone. (Requires the `depth` feature.) -* `ensure` - Determines the state of the repository. Valid values are 'present', 'bare', 'absent', 'latest'. -* `excludes` - Lists any files to be excluded from the repository. Can be an array or string. -* `force` - Forces repository creation. Valid values are 'true' and 'false'. **WARNING** Forcing will destroy any files in the path. -* `fstype` - Sets the filesystem type. (Requires the `filesystem_types` feature.) -* `group` - Determines the group/gid that owns the repository files. -* `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.) -* `module` - Specifies the repository module to manage. (Requires the `modules` feature.) -* `owner` - Specifies the user/uid that owns the repository files. -* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. -* `provider` - Specifies the backend to use for this vcsrepo resource. -* `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) -* `revision` - Sets the revision of the repository. Values can match /^\S+$/. -* `source` - Specifies the source URI for the repository. -* `user` - Specifies the user to run as for repository operations. -* `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration. - -####Features and Parameters by Provider - -#####`git` -**Features**: `bare_repositories`, `depth`, `multiple_remotes`, `reference_tracking`, `ssh_identity`, `user`, `submodules` - -**Parameters**: `depth`, `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `remote`, `revision`, `source`, `user`, `submodules` - -#####`bzr` -**Features**: `reference_tracking` - -**Parameters**: `ensure`, `excludes`, `force`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -#####`cvs` -**Features**: `cvs_rsh`, `gzip_compression`, `modules`, `reference_tracking`, `revision` - -**Parameters**: `compression`, `cvs_rsh`, `ensure`, `excludes`, `force`, `group`, `module`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -#####`hg` -**Features**: `reference_tracking`, `ssh_identity`, `user` - -**Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -#####`p4` -**Features**: `reference_tracking`, `filesystem_types`, `p4config` - -**Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config` - -#####`svn` -**Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking` - -**Parameters**: `basic_auth_password`, `basic_auth_username`, `configuration`, `ensure`, `excludes`, `force`, `fstype`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `user` - -##Limitations - -Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs. - -This module has been built on and tested against Puppet 2.7 and higher. - -The module has been tested on: - -RedHat Enterprise Linux 5/6 -Debian 6/7 -CentOS 5/6 -Ubuntu 12.04 -Gentoo -Arch Linux -FreeBSD - -Testing on other platforms has been light and cannot be guaranteed. - -##Development - -Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. - -We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. - -You can read the complete module contribution guide on the Puppet Labs wiki. +Specifies the user to run as for repository operations. (Requires the `user` feature.) Valid options: a string containing a username or UID. Default: none.
+
+##Limitations
+
+Git is the only VCS provider officially [supported](https://forge.puppetlabs.com/supported) by Puppet Labs.
+
+This module has been tested with Puppet 2.7 and higher.
+
+The module has been tested on:
+
+* CentOS 5/6/7 +* Debian 6/7 +* Oracle 5/6/7
+* Red Hat Enterprise Linux 5/6/7
+* Scientific Linux 5/6/7 +* SLES 10/11/12 +* Ubuntu 10.04/12.04/14.04
+
+Testing on other platforms has been light and cannot be guaranteed.
+
+##Development
+
+Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
+
+We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
+
+You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) diff --git a/examples/p4/create_client.pp b/examples/p4/create_client.pp index 0f8233a..3cf9160 100644 --- a/examples/p4/create_client.pp +++ b/examples/p4/create_client.pp @@ -1,4 +1,4 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => present, - provider => 'p4', + ensure => present, + provider => 'p4', } diff --git a/examples/p4/delete_client.pp b/examples/p4/delete_client.pp index 1e305f1..82c9c95 100644 --- a/examples/p4/delete_client.pp +++ b/examples/p4/delete_client.pp @@ -1,4 +1,4 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => absent, - provider => 'p4', + ensure => absent, + provider => 'p4', } diff --git a/examples/p4/latest_client.pp b/examples/p4/latest_client.pp index a7caeb6..106ef9e 100644 --- a/examples/p4/latest_client.pp +++ b/examples/p4/latest_client.pp @@ -1,5 +1,5 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => latest, - provider => 'p4', - source => '//depot/...', + ensure => latest, + provider => 'p4', + source => '//depot/...', } diff --git a/examples/p4/sync_client.pp b/examples/p4/sync_client.pp index fc0e29c..33e4731 100644 --- a/examples/p4/sync_client.pp +++ b/examples/p4/sync_client.pp @@ -1,6 +1,6 @@ vcsrepo { '/tmp/vcstest/p4_client_root': - ensure => present, - provider => 'p4', - source => '//depot/...', - revision => '30', + ensure => present, + provider => 'p4', + source => '//depot/...', + revision => '30', } diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 4603029..8074950 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) commands :git => 'git' - has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :submodules + has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :branch, :submodules def create if @resource.value(:revision) and @resource.value(:ensure) == :bare @@ -14,13 +14,16 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) if !@resource.value(:source) init_repository(@resource.value(:path)) else - clone_repository(@resource.value(:source), @resource.value(:path)) + clone_repository(default_url, @resource.value(:path)) + update_remotes + if @resource.value(:revision) checkout end if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true update_submodules end + end update_owner_and_excludes end @@ -72,7 +75,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") } end #TODO Would this ever reach here if it is bare? - if @resource.value(:ensure) != :bare + if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true update_submodules end update_owner_and_excludes @@ -82,9 +85,25 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) bare_git_config_exists? && !working_copy_exists? end + # If :source is set to a hash (for supporting multiple remotes), + # we search for the URL for :remote. If it doesn't exist, + # we throw an error. If :source is just a string, we use that + # value for the default URL. + def default_url + if @resource.value(:source).is_a?(Hash) + if @resource.value(:source).has_key?(@resource.value(:remote)) + @resource.value(:source)[@resource.value(:remote)] + else + fail("You must specify the URL for #{@resource.value(:remote)} in the :source hash") + end + else + @resource.value(:source) + end + end + def working_copy_exists? if @resource.value(:source) and File.exists?(File.join(@resource.value(:path), '.git', 'config')) - File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{@resource.value(:source)}/).any? + File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{default_url}/).any? else File.directory?(File.join(@resource.value(:path), '.git')) end @@ -94,18 +113,54 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) working_copy_exists? || bare_exists? end - def update_remote_origin_url - current = git_with_identity('config', "remote.#{@resource.value(:remote)}.url") - unless @resource.value(:source).nil? - if current.nil? or current.strip != @resource.value(:source) - git_with_identity('config', "remote.#{@resource.value(:remote)}.url", @resource.value(:source)) + def update_remote_url(remote_name, remote_url) + do_update = false + current = git_with_identity('config', '-l') + + unless remote_url.nil? + # Check if remote exists at all, regardless of URL. + # If remote doesn't exist, add it + if not current.include? "remote.#{remote_name}.url" + git_with_identity('remote','add', remote_name, remote_url) + return true + + # If remote exists, but URL doesn't match, update URL + elsif not current.include? "remote.#{remote_name}.url=#{remote_url}" + git_with_identity('remote','set-url', remote_name, remote_url) + return true + else + return false + end + end + + end + + def update_remotes + do_update = false + + # If supplied source is a hash of remote name and remote url pairs, then + # we loop around the hash. Otherwise, we assume single url specified + # in source property + if @resource.value(:source).is_a?(Hash) + @resource.value(:source).keys.sort.each do |remote_name| + remote_url = @resource.value(:source)[remote_name] + at_path { do_update |= update_remote_url(remote_name, remote_url) } end + else + at_path { do_update |= update_remote_url(@resource.value(:remote), @resource.value(:source)) } + end + + # If at least one remote was added or updated, then we must + # call the 'git remote update' command + if do_update == true + at_path { git_with_identity('remote','update') } end + end def update_references at_path do - update_remote_origin_url + update_remotes git_with_identity('fetch', @resource.value(:remote)) git_with_identity('fetch', '--tags', @resource.value(:remote)) update_owner_and_excludes @@ -129,6 +184,9 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) args.push('--branch', @resource.value(:revision).to_s) end end + if @resource.value(:branch) + args.push('--branch', @resource.value(:branch).to_s) + end if @resource.value(:ensure) == :bare args << '--bare' end @@ -363,7 +421,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) # @!visibility private def git_with_identity(*args) if @resource.value(:identity) - Tempfile.open('git-helper') do |f| + Tempfile.open('git-helper', Puppet[:statedir]) do |f| f.puts '#!/bin/sh' f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -oConnectTimeout=120 -i #{@resource.value(:identity)} $*" f.close diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index a1b1714..905d5ad 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -7,7 +7,7 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) :svnadmin => 'svnadmin', :svnlook => 'svnlook' - has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration + has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration, :conflict def create if !@resource.value(:source) @@ -92,6 +92,11 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) else buildargs.push('update', '-r', desired) end + + if @resource.value(:conflict) + args.push('--accept', @resource.value(:conflict)) + end + at_path do svn(*args) end diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb index 3bf4029..e5dfbb5 100644 --- a/lib/puppet/type/vcsrepo.rb +++ b/lib/puppet/type/vcsrepo.rb @@ -40,12 +40,18 @@ Puppet::Type.newtype(:vcsrepo) do feature :depth, "The provider can do shallow clones" + feature :branch, + "The name of the branch" + feature :p4config, "The provider understands Perforce Configuration" feature :submodules, "The repository contains submodules which can be optionally initialized" + feature :conflict, + "The provider supports automatic conflict resolution" + ensurable do attr_accessor :latest @@ -204,6 +210,10 @@ Puppet::Type.newtype(:vcsrepo) do desc "The value to be used to do a shallow clone." end + newparam :branch, :required_features => [:branch] do + desc "The name of the branch to clone." + end + newparam :p4config, :required_features => [:p4config] do desc "The Perforce P4CONFIG environment." end @@ -214,6 +224,10 @@ Puppet::Type.newtype(:vcsrepo) do defaultto true end + newparam :conflict do + desc "The action to take if conflicts exist between repository and working copy" + end + autorequire(:package) do ['git', 'git-core'] end diff --git a/metadata.json b/metadata.json index 242583a..ef74e86 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-vcsrepo", - "version": "1.2.0", + "version": "1.3.0", "author": "Puppet Labs", "summary": "Puppet module providing a type to manage repositories from various version control systems", "license": "GPLv2", diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 2cca061..c234550 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -38,6 +38,30 @@ describe 'clones a remote repo' do end end + context 'using a https source on github' do + it 'clones a repo' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/httpstestrepo": + ensure => present, + provider => git, + source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/httpstestrepo/.git") do + it { is_expected.to be_directory } + end + + describe file("#{tmpdir}/httpstestrepo/.git/HEAD") do + it { is_expected.to contain 'ref: refs/heads/master' } + end + end + context 'using a commit SHA' do let (:sha) do shell("git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1").stdout.chomp diff --git a/spec/acceptance/modules_753_spec.rb b/spec/acceptance/modules_753_spec.rb new file mode 100644 index 0000000..e4e332b --- /dev/null +++ b/spec/acceptance/modules_753_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones a remote repo' do + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + context 'clone with single remote' do + it 'clones from default remote' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", + } + EOS + + apply_manifest(pp, :catch_failures => true) + + end + + it "git config output should contain the remote" do + shell("/usr/bin/git config -l -f #{tmpdir}/vcsrepo/.git/config") do |r| + expect(r.stdout).to match(/remote.origin.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/) + end + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + end + + context 'clone with multiple remotes' do + it 'clones from default remote and adds 2 remotes to config file' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => {"origin" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", "test1" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git"}, + } + EOS + + apply_manifest(pp, :catch_failures => true) + + end + + it "git config output should contain the remotes" do + shell("/usr/bin/git config -l -f #{tmpdir}/vcsrepo/.git/config") do |r| + expect(r.stdout).to match(/remote.origin.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/) + expect(r.stdout).to match(/remote.test1.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/) + end + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + end + +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 9ef826a..97c43e8 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,25 +1,7 @@ require 'beaker-rspec' +require 'beaker/puppet_install_helper' -unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - # This will install the latest available package on el and deb based - # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { :default_action => 'gem_install' } - - if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end - - hosts.each do |host| - unless host.is_pe? - on hosts, "mkdir -p #{hosts.first['distmoduledir']}" - end - - # We ask the host to interpolate it's distmoduledir because we don't - # actually know it on Windows until we've let it redirect us (depending - # on whether we're running as a 32/64 bit process on 32/64 bit Windows - moduledir = on(host, "echo #{host['distmoduledir']}").stdout.chomp - on host, "mkdir -p #{moduledir}" - end -end - +run_puppet_install_helper RSpec.configure do |c| # Project root diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 29c6b3b..a240b50 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -35,6 +35,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -48,6 +49,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', '--origin', 'not_origin', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("not_origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -62,6 +64,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', '--depth', '1', '--branch', resource.value(:revision),resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -75,6 +78,7 @@ branches Dir.expects(:chdir).with('/tmp/test').at_least_once.yields provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -84,6 +88,7 @@ branches resource.delete(:revision) provider.expects(:git).with('clone', resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remotes) provider.create end end @@ -100,6 +105,7 @@ branches resource[:ensure] = :bare resource.delete(:revision) provider.expects(:git).with('clone', '--bare', resource.value(:source), resource.value(:path)) + provider.expects(:update_remotes) provider.create end end @@ -171,6 +177,7 @@ branches provider.destroy provider.expects(:git).with('clone',resource.value(:source), resource.value(:path)) provider.expects(:update_submodules) + provider.expects(:update_remote_url).with("origin", resource.value(:source)).returns false provider.expects(:git).with('branch', '-a').returns(branch_a_list(resource.value(:revision))) provider.expects(:git).with('checkout', '--force', resource.value(:revision)) provider.create @@ -211,6 +218,7 @@ branches context "when its SHA is not different than the current SHA" do it "should return the ref" do provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') + provider.expects(:update_remotes) expect(provider.revision).to eq(resource.value(:revision)) end end @@ -218,6 +226,7 @@ branches context "when its SHA is different than the current SHA" do it "should return the current SHA" do provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('othersha') + provider.expects(:update_remotes) expect(provider.revision).to eq(resource.value(:revision)) end end @@ -226,6 +235,7 @@ branches it "should return the revision" do provider.stubs(:git).with('branch', '-a').returns(" remotes/origin/#{resource.value(:revision)}") provider.expects(:git).with('rev-parse', "origin/#{resource.value(:revision)}").returns("newsha") + provider.expects(:update_remotes) expect(provider.revision).to eq(resource.value(:revision)) end end @@ -234,7 +244,7 @@ branches it "should fail" do provider.expects(:git).with('branch', '-a').returns(branch_a_list) provider.expects(:git).with('rev-parse', '--revs-only', resource.value(:revision)).returns('') - + provider.expects(:update_remotes) expect { provider.revision }.to raise_error(Puppet::Error, /not a local or remote ref$/) end end @@ -242,12 +252,26 @@ branches context "when the source is modified" do it "should update the origin url" do resource[:source] = 'git://git@foo.com/bar.git' - provider.expects(:git).with('config', 'remote.origin.url').returns('old') - provider.expects(:git).with('config', 'remote.origin.url', 'git://git@foo.com/bar.git') + provider.expects(:git).with('config', '-l').returns("remote.origin.url=git://git@foo.com/foo.git\n") + provider.expects(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/bar.git') + provider.expects(:git).with('remote','update') provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') expect(provider.revision).to eq(resource.value(:revision)) end end + + context "when multiple sources are modified" do + it "should update the urls" do + resource[:source] = {"origin" => "git://git@foo.com/bar.git", "new_remote" => "git://git@foo.com/baz.git"} + provider.expects(:git).at_least_once.with('config', '-l').returns("remote.origin.url=git://git@foo.com/bar.git\n", "remote.origin.url=git://git@foo.com/foo.git\n") + provider.expects(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/bar.git') + provider.expects(:git).with('remote', 'add', 'new_remote', 'git://git@foo.com/baz.git') + provider.expects(:git).with('remote','update') + provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha') + expect(provider.revision).to eq(resource.value(:revision)) + end + end + end context "setting the revision property" do @@ -291,7 +315,7 @@ branches it "should use 'git fetch --tags'" do resource.delete(:source) expects_chdir - provider.expects(:git).with('config', 'remote.origin.url').returns('') + provider.expects(:git).with('config', '-l').returns("remote.origin.url=git://git@foo.com/foo.git\n") provider.expects(:git).with('fetch', 'origin') provider.expects(:git).with('fetch', '--tags', 'origin') provider.update_references diff --git a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb index 494da52..77f0e03 100644 --- a/spec/unit/puppet/provider/vcsrepo/svn_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/svn_spec.rb @@ -83,10 +83,22 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do before do @revision = '30' end - it "should use 'svn update'" do - expects_chdir - provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision) - provider.revision = @revision + context 'with conflict' do + it "should use 'svn update'" do + resource[:conflict] = 'theirs-full' + expects_chdir + provider.expects(:svn).with('--non-interactive', 'update', + '-r', @revision, + '--accept', resource.value(:conflict)) + provider.revision = @revision + end + end + context 'without conflict' do + it "should use 'svn update'" do + expects_chdir + provider.expects(:svn).with('--non-interactive', 'update', '-r', @revision) + provider.revision = @revision + end end end @@ -94,11 +106,24 @@ describe Puppet::Type.type(:vcsrepo).provider(:svn) do before do @revision = '30' end - it "should use 'svn switch'" do - resource[:source] = 'an-unimportant-value' - expects_chdir - provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value') - provider.revision = @revision + context 'with conflict' do + it "should use 'svn switch'" do + resource[:source] = 'an-unimportant-value' + resource[:conflict] = 'theirs-full' + expects_chdir + provider.expects(:svn).with('--non-interactive', 'switch', + '-r', @revision, 'an-unimportant-value', + '--accept', resource.value(:conflict)) + provider.revision = @revision + end + end + context 'without conflict' do + it "should use 'svn switch'" do + resource[:source] = 'an-unimportant-value' + expects_chdir + provider.expects(:svn).with('--non-interactive', 'switch', '-r', @revision, 'an-unimportant-value') + provider.revision = @revision + end end end |