diff --git a/CHANGELOG.md b/CHANGELOG.md index af464eb..a325710 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,343 +1,343 @@ # Change log All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). ## [v3.1.1](https://github.com/puppetlabs/puppetlabs-vcsrepo/tree/v3.1.1) (2020-06-25) [Full Changelog](https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/v3.1.0...v3.1.1) ### Fixed - prevent ANSI color escape sequences from messing up git output [\#458](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/458) ([kenyon](https://github.com/kenyon)) - Unset GIT\_SSH\_COMMAND before exec'ing git command [\#435](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/435) ([mzagrabe](https://github.com/mzagrabe)) ## [v3.1.0](https://github.com/puppetlabs/puppetlabs-vcsrepo/tree/v3.1.0) (2019-12-10) [Full Changelog](https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/v3.0.0...v3.1.0) ### Added - \(FM-8234\) Port to Litmus [\#429](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/429) ([sheenaajay](https://github.com/sheenaajay)) - pdksync - Add support on Debian10 [\#428](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/428) ([lionce](https://github.com/lionce)) - feature\(git\): add keep local changes option [\#425](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/425) ([jfroche](https://github.com/jfroche)) ### Fixed - feat: do not chown excluded files [\#432](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/432) ([jfroche](https://github.com/jfroche)) ## [v3.0.0](https://github.com/puppetlabs/puppetlabs-vcsrepo/tree/v3.0.0) (2019-06-13) [Full Changelog](https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.4.0...v3.0.0) ### Changed - pdksync - \(MODULES-8444\) - Raise lower Puppet bound [\#413](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/413) ([david22swan](https://github.com/david22swan)) ### Added - \(FM-8035\) Add RedHat 8 support [\#419](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/419) ([eimlav](https://github.com/eimlav)) - \(MODULES-8738\) Allow Sensitive value for basic\_auth\_password [\#416](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/416) ([eimlav](https://github.com/eimlav)) - \(MODULES-8140\) - Add SLES 15 support [\#399](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/399) ([eimlav](https://github.com/eimlav)) ### Fixed - MODULES-8910 fix for failing git install using RepoForge instead of epel [\#414](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/414) ([Lavinia-Dan](https://github.com/Lavinia-Dan)) - \(maint\) Add HTML anchor tag [\#404](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/404) ([clairecadman](https://github.com/clairecadman)) - pdksync - \(FM-7655\) Fix rubygems-update for ruby \< 2.3 [\#401](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/401) ([tphoney](https://github.com/tphoney)) ## [2.4.0](https://github.com/puppetlabs/puppetlabs-vcsrepo/tree/2.4.0) (2018-09-28) [Full Changelog](https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.3.0...2.4.0) ### Added - pdksync - \(FM-7392\) - Puppet 6 Testing Changes [\#394](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/394) ([pmcmaw](https://github.com/pmcmaw)) - pdksync - \(MODULES-6805\) metadata.json shows support for puppet 6 [\#393](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/393) ([tphoney](https://github.com/tphoney)) - pdksync - \(MODULES-7658\) use beaker4 in puppet-module-gems [\#390](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/390) ([tphoney](https://github.com/tphoney)) - \(MODULES-7467\) Update Vcsrepo to support Ubuntu 18.04 [\#382](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/382) ([david22swan](https://github.com/david22swan)) ### Fixed - \(MODULES-7009\) Do not run HTTPS tests on old OSes [\#384](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/384) ([tphoney](https://github.com/tphoney)) - Improve Git performance when using SHA revisions [\#380](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/380) ([vpierson](https://github.com/vpierson)) - \[FM-6957\] Removing unsupported OS from Vcsrepo [\#378](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/378) ([david22swan](https://github.com/david22swan)) - Avoid popup on macOS when developer tools aren't installed [\#367](https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/367) ([girardc79](https://github.com/girardc79)) ## 2.3.0 This release uses the PDK convert functionality which in return makes the module PDK compliant. It also includes a few features and a roll up of maintenance changes. ### Added - Added trust_server_cert support to Git provider ([MODULES-5889](https://tickets.puppet.com/browse/MODULES-5889)). - Do not ignore incorrect HTTP Basic auth property specifications. - Adds some basic unit tests ([MODULES-5889](https://tickets.puppet.com/browse/MODULES-5889)). ### Fixed - Addressing Rubocop errors throughout the module. - Change expected exception type from Puppet::Error to RuntimeError. - A typo in the CHANGELOG.md. - A roll up of minor changes via modulesync_configs. ### Removed - `gem update bundler` as the module runs into ([MODULES-6339](https://tickets.puppet.com/browse/MODULES-6339)). ## Supported Release [2.2.0] ### Summary This is to enable Rubocop within the module. ### Added - Rubocop has been enabled and will now run against all future pull requests. ### Fixed - Entire module has been put through the rubocop process and now matches the expected standards. ## Supported Release [2.1.0] ### Summary This is to provide a clean release from which to run Rubocop. ### Added - Debian 9 as supported platform ### Fixed - CVS working copy detection ([MODULES-5704](https://tickets.puppet.com/browse/MODULES-5704)) - typo error for sshed-git-source - Update to existence test, Use 'svn info' instead of 'svn status'. 'svn status' does not return proper exit codes, while 'svn info' does. - working_copy_exists in svn provider. Change method 'working_copy_exists' to use 'svn info' instead of 'svn status'. 'svn status' does not return proper exit codes, while 'svn info' does. ([MODULES-5615](https://tickets.puppet.com/browse/MODULES-5615)) - tests associated with hg - hg provider: remove escaped quotes - authentication fix ### Removed - Support for Ubuntu 10.04 and 12.04, existing compatibility is unaffected ([MODULES-5501](https://tickets.puppet.com/browse/MODULES-5501)) - Support for Debian 6 and SLES 10, existing compatibility is unaffected - Commented out test ([MODULES-5162](https://tickets.puppet.com/browse/MODULES-5162)) ## Supported Release [2.0.0] ### Summary This is a major release that **drops support for Puppet 3** and addresses an issue with the subversion provider. ### Added - Documentation for using an non-standard ssh port ([MODULES-1910](https://tickets.puppet.com/browse/MODULES-1910)) - Autorequire for the subversion package in the vcsrepo type ([MODULES-4722](https://tickets.puppetlabs.com/browse/MODULES-4722)) - Puppet 5 support in metadata ([MODULES-5144](https://tickets.puppet.com/browse/MODULES-5144)) ### Changed - Lower bound of Puppet requirement to 4.7.0 ([MODULES-4823](https://tickets.puppetlabs.com/browse/MODULES-4823)) ### Fixed - Solaris `SSH_AUTH_SOCKET` issue - Issue with subversion provider ([MODULES-4280](https://tickets.puppetlabs.com/browse/MODULES-4280)) - `force` parameter to return a boolean instead of a string ([MODULES-4864](https://tickets.puppetlabs.com/browse/MODULES-4864)) ## [1.5.0] - 2016-12-19 Supported Release ### Summary Release featuring some refactoring and improvements around git's `ensurable`. ### Bugfixes - `ensure => absent` fix ### Features - `:source` property added - Improved `ensure` handling for git provider - General refactoring for all providers - Various test improvements ## [1.4.0] - 2015-09-06 Supported Release ### Summary Small release for a new feature and added compatibility. ### Features - Git repositories can be cloned as mirror or bare repos. - Added STDERR to Puppet's output. - Added Debian 8 and Ubuntu 16.04 compatibility. ## [1.3.2] - 2015-12-08 Supported Release ### Summary Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. ## [1.3.1] - 2015-07-28 Supported Release ### Summary This release includes a number of bugfixes and test updates. ### Fixed - Fix for detached HEAD on git 2.4+. - Git provider doesn't ignore revision property when depth is used (MODULES-2131). - Tests fixed. - Check if submodules == true before calling update_submodules. ## [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. - Added `submodules` parameter to skip submodule initialization for the git provider. - Added `conflict` to the svn provider to resolve conflicts. - Added `branch` parameter to specify clone branch. - Readme rewritten. ### 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. ### 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 ### Fixed - No more warnings about multiple default providers! (MODULES-428) ## [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.) ### Added - New Perforce provider. ### Fixed - Fix behavior with `ensure => latest` and detached HEAD. (MODULES-660) - Spec test fixes. ## [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. ## [1.0.1] - 2014-06-17 Supported Release ### Summary This release is the first supported release of vcsrepo. The readme has been greatly improved. ### Added - Updated and expanded readme to follow readme template. ### Fixed - Remove SLES from compatability metadata. - Unpin rspec development dependencies. - Update acceptance level testing. ## [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. ### Added - Bzr: - Call set_ownership. - Git: - Add ability for shallow clones. - Use -a and desired for HARD resets. - Use rev-parse to get tag canonical revision. ### Fixed - HG: - Only add ssh options when it's talking to the network. - Git: - Fix for issue with detached HEAD. - `force => true` will now destroy and recreate repo. - Actually use the remote parameter. - - Use origin/master instead of origin/HEAD when on master. + - Use origin/main instead of origin/HEAD when on main. - SVN: - Fix svnlook behavior with plain directories. ## 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! ### Added - Git: - Add autorequire for `Package['git']`. - HG: - Allow user and identity properties. - Bzr: - "ensure => latest" support. - SVN: - Added configuration parameter. - - Add support for master svn repositories. + - Add support for main svn repositories. - CVS: - Allow for setting the CVS_RSH environment variable. ### 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. - Git: - Improve Git SSH usage documentation. - Add ssh session timeouts to prevent network issues from blocking runs. - Fix git provider checkout of a remote ref on an existing repo. - Allow unlimited submodules (thanks to --recursive). - Use git checkout --force instead of short -f everywhere. - Update git provider to handle checking out into an existing (empty) dir. - SVN: - Handle force property. - Adds support for changing upstream repo url. - Check that the URL of the WC matches the URL from the manifest. - Changed from using "update" to "switch". - Handle revision update without source switch. - Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'. - CVS: - Documented the "module" attribute. [2.3.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.2.0...2.3.0 [2.2.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.1.0...2.2.0 [2.1.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.0.0...2.1.0 [2.0.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.5.0...2.0.0 [1.5.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.4.0...1.5.0 [1.4.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.2...1.4.0 [1.3.2]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.1...1.3.2 [1.3.1]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.0...1.3.1 [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 \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a9fb3a..9c171f9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,271 +1,271 @@ # Contributing to Puppet modules So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing that very thing while setting expectations around code quality as well as a few tips for making the process as easy as possible. ### Table of Contents 1. [Getting Started](#getting-started) 1. [Commit Checklist](#commit-checklist) 1. [Submission](#submission) 1. [More about commits](#more-about-commits) 1. [Testing](#testing) - [Running Tests](#running-tests) - [Writing Tests](#writing-tests) 1. [Get Help](#get-help) ## Getting Started - Fork the module repository on GitHub and clone to your workspace - Make your changes! ## Commit Checklist ### The Basics - [x] my commit is a single logical unit of work - [x] I have checked for unnecessary whitespace with "git diff --check" - [x] my commit does not include commented out code or unneeded files ### The Content - [x] my commit includes tests for the bug I fixed or feature I added - [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality - [x] my code passes existing test suites ### The Commit Message - [x] the first line of my commit message includes: - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line" - [x] a short description (50 characters is the soft limit, excluding ticket number(s)) - [x] the body of my commit message: - [x] is meaningful - [x] uses the imperative, present tense: "change", not "changed" or "changes" - [x] includes motivation for the change, and contrasts its implementation with the previous behavior ## Submission ### Pre-requisites - Make sure you have a [GitHub account](https://github.com/join) - [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. ### Push and PR - Push your changes to your fork - [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization ## More about commits 1. Make separate commits for logically separate changes. Please break your commits down into logically consistent units which include new or changed tests relevant to the rest of the change. The goal of doing this is to make the diff easier to read for whoever is reviewing your code. In general, the easier your diff is to read, the more likely someone will be happy to review it and get it into the code base. If you are going to refactor a piece of code, please do so as a separate commit from your feature or bug fix changes. We also really appreciate changes that include tests to make sure the bug is not re-introduced, and that the feature is not accidentally broken. Describe the technical detail of the change(s). If your description starts to get too long, that is a good sign that you probably need to split up your commit into more finely grained pieces. Commits which plainly describe the things which help reviewers check the patch and future developers understand the code are much more likely to be merged in with a minimum of bike-shedding or requested changes. Ideally, the commit message would include information, and be in a form suitable for inclusion in the release notes for the version of Puppet that includes them. Please also check that you are not introducing any trailing whitespace or other "whitespace errors". You can do this by running "git diff --check" on your changes before you commit. 2. Sending your patches To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of - directly on "master". + directly on "main". It makes things much easier to keep track of, especially if you decide to work on another thing before your first change is merged in. GitHub has some pretty good [general documentation](http://help.github.com/) on using their site. They also have documentation on [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/). In general, after pushing your topic branch up to your repository on GitHub, you can switch to the branch in the GitHub UI and click "Pull Request" towards the top of the page in order to open a pull request. 3. Update the related JIRA issue. If there is a JIRA issue associated with the change you submitted, then you should update the ticket to include the location of your branch, along with any other commentary you may wish to make. # Testing ## Getting Started Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages, or Gems, are required to build, develop, and test this software. Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to install all dependencies needed for this project in the project root by running ```shell % bundle install --path .bundle/gems Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/.. Using rake (10.1.0) Using builder (3.2.2) -- 8><-- many more --><8 -- Using rspec-system-puppet (2.2.0) Using serverspec (0.6.3) Using rspec-system-serverspec (1.0.0) Using bundler (1.3.5) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. ``` NOTE: some systems may require you to run this command with sudo. If you already have those gems installed, make sure they are up-to-date: ```shell % bundle update ``` ## Running Tests With all dependencies in place and up-to-date, run the tests: ### Unit Tests ```shell % bundle exec rake spec ``` This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on. rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json), rspec tests define them in [.fixtures.yml](./fixtures.yml). ### Acceptance Tests Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under [VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system. Run the tests by issuing the following command ```shell % bundle exec rake spec_clean % bundle exec rspec spec/acceptance ``` This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) and then run all the tests under [spec/acceptance](./spec/acceptance). ## Writing Tests ### Unit Tests When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs] but here's a tiny sample: Sample manifest: ```puppet file { "a test file": ensure => present, path => "/etc/sample", } ``` Sample test: ```ruby it 'does a thing' do expect(subject).to contain_file("a test file").with({:path => "/etc/sample"}) end ``` ### Acceptance Tests Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it twice to check for idempotency or errors, then run expectations. ```ruby it 'does an end-to-end thing' do pp = <<-EOF file { 'a test file': ensure => present, path => "/etc/sample", content => "test string", } apply_manifest(pp, :catch_failures => true) apply_manifest(pp, :catch_changes => true) end describe file("/etc/sample") do it { is_expected.to contain "test string" } end ``` # If you have commit access to the repository Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that all changes go through a code review process.** The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch. # Get Help ### On the web * [Puppet help messageboard](http://puppet.com/community/get-help) * [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) ### On chat * Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli * IRC (freenode) #puppet-dev, #voxpupuli [rspec-puppet]: http://rspec-puppet.com/ [rspec-puppet_docs]: http://rspec-puppet.com/documentation/ [beaker]: https://github.com/puppetlabs/beaker [beaker-rspec]: https://github.com/puppetlabs/beaker-rspec diff --git a/HISTORY.md b/HISTORY.md index af4b7ae..de33204 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,275 +1,275 @@ ## 2.3.0 This release uses the PDK convert functionality which in return makes the module PDK compliant. It also includes a few features and a roll up of maintenance changes. ### Added - Added trust_server_cert support to Git provider ([MODULES-5889](https://tickets.puppet.com/browse/MODULES-5889)). - Do not ignore incorrect HTTP Basic auth property specifications. - Adds some basic unit tests ([MODULES-5889](https://tickets.puppet.com/browse/MODULES-5889)). ### Fixed - Addressing Rubocop errors throughout the module. - Change expected exception type from Puppet::Error to RuntimeError. - A typo in the CHANGELOG.md. - A roll up of minor changes via modulesync_configs. ### Removed - `gem update bundler` as the module runs into ([MODULES-6339](https://tickets.puppet.com/browse/MODULES-6339)). ## Supported Release [2.2.0] ### Summary This is to enable Rubocop within the module. ### Added - Rubocop has been enabled and will now run against all future pull requests. ### Fixed - Entire module has been put through the rubocop process and now matches the expected standards. ## Supported Release [2.1.0] ### Summary This is to provide a clean release from which to run Rubocop. ### Added - Debian 9 as supported platform ### Fixed - CVS working copy detection ([MODULES-5704](https://tickets.puppet.com/browse/MODULES-5704)) - typo error for sshed-git-source - Update to existence test, Use 'svn info' instead of 'svn status'. 'svn status' does not return proper exit codes, while 'svn info' does. - working_copy_exists in svn provider. Change method 'working_copy_exists' to use 'svn info' instead of 'svn status'. 'svn status' does not return proper exit codes, while 'svn info' does. ([MODULES-5615](https://tickets.puppet.com/browse/MODULES-5615)) - tests associated with hg - hg provider: remove escaped quotes - authentication fix ### Removed - Support for Ubuntu 10.04 and 12.04, existing compatibility is unaffected ([MODULES-5501](https://tickets.puppet.com/browse/MODULES-5501)) - Support for Debian 6 and SLES 10, existing compatibility is unaffected - Commented out test ([MODULES-5162](https://tickets.puppet.com/browse/MODULES-5162)) ## Supported Release [2.0.0] ### Summary This is a major release that **drops support for Puppet 3** and addresses an issue with the subversion provider. ### Added - Documentation for using an non-standard ssh port ([MODULES-1910](https://tickets.puppet.com/browse/MODULES-1910)) - Autorequire for the subversion package in the vcsrepo type ([MODULES-4722](https://tickets.puppetlabs.com/browse/MODULES-4722)) - Puppet 5 support in metadata ([MODULES-5144](https://tickets.puppet.com/browse/MODULES-5144)) ### Changed - Lower bound of Puppet requirement to 4.7.0 ([MODULES-4823](https://tickets.puppetlabs.com/browse/MODULES-4823)) ### Fixed - Solaris `SSH_AUTH_SOCKET` issue - Issue with subversion provider ([MODULES-4280](https://tickets.puppetlabs.com/browse/MODULES-4280)) - `force` parameter to return a boolean instead of a string ([MODULES-4864](https://tickets.puppetlabs.com/browse/MODULES-4864)) ## [1.5.0] - 2016-12-19 Supported Release ### Summary Release featuring some refactoring and improvements around git's `ensurable`. ### Bugfixes - `ensure => absent` fix ### Features - `:source` property added - Improved `ensure` handling for git provider - General refactoring for all providers - Various test improvements ## [1.4.0] - 2015-09-06 Supported Release ### Summary Small release for a new feature and added compatibility. ### Features - Git repositories can be cloned as mirror or bare repos. - Added STDERR to Puppet's output. - Added Debian 8 and Ubuntu 16.04 compatibility. ## [1.3.2] - 2015-12-08 Supported Release ### Summary Small release for support of newer PE versions. This increments the version of PE in the metadata.json file. ## [1.3.1] - 2015-07-28 Supported Release ### Summary This release includes a number of bugfixes and test updates. ### Fixed - Fix for detached HEAD on git 2.4+. - Git provider doesn't ignore revision property when depth is used (MODULES-2131). - Tests fixed. - Check if submodules == true before calling update_submodules. ## [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. - Added `submodules` parameter to skip submodule initialization for the git provider. - Added `conflict` to the svn provider to resolve conflicts. - Added `branch` parameter to specify clone branch. - Readme rewritten. ### 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. ### 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 ### Fixed - No more warnings about multiple default providers! (MODULES-428) ## [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.) ### Added - New Perforce provider. ### Fixed - Fix behavior with `ensure => latest` and detached HEAD. (MODULES-660) - Spec test fixes. ## [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. ## [1.0.1] - 2014-06-17 Supported Release ### Summary This release is the first supported release of vcsrepo. The readme has been greatly improved. ### Added - Updated and expanded readme to follow readme template. ### Fixed - Remove SLES from compatability metadata. - Unpin rspec development dependencies. - Update acceptance level testing. ## [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. ### Added - Bzr: - Call set_ownership. - Git: - Add ability for shallow clones. - Use -a and desired for HARD resets. - Use rev-parse to get tag canonical revision. ### Fixed - HG: - Only add ssh options when it's talking to the network. - Git: - Fix for issue with detached HEAD. - `force => true` will now destroy and recreate repo. - Actually use the remote parameter. - - Use origin/master instead of origin/HEAD when on master. + - Use origin/main instead of origin/HEAD when on main. - SVN: - Fix svnlook behavior with plain directories. ## 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! ### Added - Git: - Add autorequire for `Package['git']`. - HG: - Allow user and identity properties. - Bzr: - "ensure => latest" support. - SVN: - Added configuration parameter. - - Add support for master svn repositories. + - Add support for main svn repositories. - CVS: - Allow for setting the CVS_RSH environment variable. ### 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. - Git: - Improve Git SSH usage documentation. - Add ssh session timeouts to prevent network issues from blocking runs. - Fix git provider checkout of a remote ref on an existing repo. - Allow unlimited submodules (thanks to --recursive). - Use git checkout --force instead of short -f everywhere. - Update git provider to handle checking out into an existing (empty) dir. - SVN: - Handle force property. - Adds support for changing upstream repo url. - Check that the URL of the WC matches the URL from the manifest. - Changed from using "update" to "switch". - Handle revision update without source switch. - Fix svn provider to look for '^Revision:' instead of '^Last Changed Rev:'. - CVS: - Documented the "module" attribute. [2.3.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.2.0...2.3.0 [2.2.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.1.0...2.2.0 [2.1.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/2.0.0...2.1.0 [2.0.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.5.0...2.0.0 [1.5.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.4.0...1.5.0 [1.4.0]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.2...1.4.0 [1.3.2]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.1...1.3.2 [1.3.1]: https://github.com/puppetlabs/puppetlabs-vcsrepo/compare/1.3.0...1.3.1 [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 diff --git a/README.md b/README.md index c8b4ff8..aceea8a 100644 --- a/README.md +++ b/README.md @@ -1,772 +1,772 @@ # 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) 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 Inc.](https://forge.puppet.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. Set up any needed directory structures before you start. ### 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). ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => git, } ~~~ ## Usage **Note:** `git` is the only vcsrepo provider officially [supported by Puppet Inc.](https://forge.puppet.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`: ~~~ puppet 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': ~~~ puppet vcsrepo { '/path/to/repo': ensure => bare, provider => git, } ~~~ #### Clone/pull a repository ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', } ~~~ To clone your repository as bare or mirror, you can set `ensure` to 'bare' or 'mirror': ~~~ puppet vcsrepo { '/path/to/repo': ensure => mirror, 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. +By default, `vcsrepo` will use the HEAD of the source repository's main branch. To use another branch or a specific commit, set `revision` to either a branch name or a commit SHA or tag. Branch name: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', revision => 'development', } ~~~ SHA: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', } ~~~ Tag: ~~~ puppet 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: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', user => 'someUser', } ~~~ To keep local changes while changing revision, use the `keep_local_changes`: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', revision => '0c466b8a5a45f6cd7de82c08df2fb4ce1e920a31', keep_local_changes => true, user => 'someUser', } ~~~ To keep the repository at the latest revision, set `ensure` to 'latest'. **WARNING:** This overwrites any local changes to the repository. ~~~ puppet vcsrepo { '/path/to/repo': ensure => latest, provider => git, source => 'git://example.com/repo.git', - revision => 'master', + revision => 'main', } ~~~ To clone the repository but skip initializing submodules, set `submodules` to 'false': ~~~ puppet vcsrepo { '/path/to/repo': ensure => latest, provider => git, source => 'git://example.com/repo.git', submodules => false, } ~~~ To clone the repository and trust the server certificate (sslVerify=false), set `trust_server_cert` to 'true': ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', trust_server_cert => true, } ~~~ #### 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: ~~~ puppet 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 (such as 'username@server:…'), we recommend managing your SSH keys with Puppet and using the [`require`](http://docs.puppet.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: ~~~ puppet vcsrepo { '/path/to/repo': ensure => latest, provider => git, source => 'ssh://username@example.com/repo.git', user => 'toto', #uses toto's $HOME/.ssh setup require => File['/home/toto/.ssh/id_rsa'], } ~~~ To use SSH over a nonstandard port, use the full SSH scheme and include the port number: ~~~ puppet vcsrepo { '/path/to/repo': ensure => latest, provider => git, source => 'ssh://username@example.com:7999/repo.git', } ~~~ ### Bazaar #### Create a blank repository To create a blank repository, suitable for use as a central repository, define `vcsrepo` without `source` or `revision`: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => bzr, } ~~~ #### Branch from an existing repository ~~~ puppet 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): ~~~ puppet 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 (such as `'bzr+ssh://...'` or `'sftp://...,'`), we recommend using the [`require`](http://docs.puppet.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: ~~~ puppet 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`: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => cvs, } ~~~ #### Checkout/update from a repository ~~~ puppet 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: ~~~ puppet 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: ~~~ puppet 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. ~~~ puppet 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: ~~~ puppet 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.puppet.com/references/stable/metaparameter.html#require) metaparameter to make sure your SSH keys are present before the `vcsrepo` resource is applied: ~~~ puppet 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`: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => hg, } ~~~ #### Clone/pull and update a repository To get the default branch tip: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => hg, source => 'http://hg.example.com/myrepo', } ~~~ For a specific changeset, use `revision`: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => hg, source => 'http://hg.example.com/myrepo', revision => '21ea4598c962', } ~~~ You can also set `revision` to a tag: ~~~ puppet 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: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => hg, source => 'http://hg.example.com/myrepo', user => 'user', } ~~~ To specify an SSH identity key: ~~~ puppet 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: ~~~ puppet 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 (such as `'ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppet.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: ~~~ puppet 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.process.configfiles) stored on the node: ~~~ puppet 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 (such as `puppet-91bc00640c4e5a17787286acbe2c021c`). #### Create/update and sync a Perforce workspace To sync a depot path to head, set `ensure` to 'latest': ~~~ puppet 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: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => p4, source => '//depot/branch/...', revision => '2341' } ~~~ You can also set `revision` to a label: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => p4, source => '//depot/branch/...', revision => 'my_label' } ~~~ ### Subversion #### Create a blank repository ~~~ puppet 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: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => svn, source => 'svn://svnrepo/hello/branches/foo', } ~~~ You can also designate a specific revision: ~~~ puppet vcsrepo { '/path/to/repo': ensure => present, provider => svn, source => 'svn://svnrepo/hello/branches/foo', revision => '1234', } ~~~ ####Checking out only specific paths **Note:** The `includes` param is only supported when subversion client version is >= 1.6. You can check out only specific paths in a particular repository by providing their relative paths to the `includes` parameter, like so: ~~~ vcsrepo { '/path/to/repo': ensure => present, provider => svn, source => 'http://svnrepo/hello/trunk', includes => [ 'root-file.txt', 'checkout-folder', 'file/this-file.txt', 'folder/this-folder/', ] } ~~~ This will create files `/path/to/repo/file-at-root-path.txt` and `/path/to/repo/file/nested/within/repo.jmx`, with folders `/path/to/repo/some-folder` and `/path/to/repo/nested/folder/to/checkout` completely recreating their corresponding working tree path. When specified, the `depth` parameter will also be applied to the `includes` -- the root directory will be checked out using an `empty` depth, and the `includes` you specify will be checked out using the `depth` you provide. To illustrate this point, using the above snippet (with the specified `includes`) and a remote repository layout like this: ~~~ . ├── checkout-folder │   ├── file1 │   └── nested-1 │   ├── nested-2 │   │   └── nested-file-2 │   └── nested-file-1 ├── file │   ├── NOT-this-file.txt │   └── this-file.txt ├── folder │   ├── never-checked-out │   └── this-folder │   ├── deep-nested-1 │   │   ├── deep-nested-2 │   │   │   └── deep-nested-file-2 │   │   └── deep-nested-file-1 │   └── this-file.txt ├── NOT-this-file.txt ├── NOT-this-folder │   ├── NOT-this-file.txt │   └── NOT-this-one-either.txt └── root-file.txt ~~~ With no `depth` given, your local folder `/path/to/repo` will look like this: ~~~ . ├── checkout-folder │   ├── file1 │   └── nested-1 │   ├── nested-2 │   │   └── nested-file-2 │   └── nested-file-1 ├── file │   └── this-file.txt ├── folder │   └── this-folder │   ├── deep-nested-1 │   │   ├── deep-nested-2 │   │   │   └── deep-nested-file-2 │   │   └── deep-nested-file-1 │   └── this-file.txt └── root-file.txt ~~~ And with a `depth` of `files` will look like this: ~~~ . ├── checkout-folder │   └── file1 ├── file │   └── this-file.txt ├── folder │   └── this-folder │   └── this-file.txt └── root-file.txt ~~~ ####Use a specific Subversion configuration directory Use the `configuration` parameter to designate the directory that contains your Subversion configuration files (typically, '/path/to/.subversion'): ~~~ puppet 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 (such as `'svn+ssh://...'`), we recommend using the [`require` metaparameter](http://docs.puppet.com/references/stable/metaparameter.html#require) to make sure your SSH keys are present before the `vcsrepo` resource is applied: ~~~ puppet 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. -For information on the classes and types, see the [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/master/REFERENCE.md) +For information on the classes and types, see the [REFERENCE.md](https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/main/REFERENCE.md) #### 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`, `depth`, `filesystem_types`, `reference_tracking` Parameters: `basic_auth_password`, `basic_auth_username`, `configuration`, `conflict`, `ensure`, `excludes`, `force`, `fstype`, `group`, `includes`, `owner`, `path`, `provider`, `revision`, `source`, `trust_server_cert` #### 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 `hg` and `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 in `git` or sets the scope limit in `svn`. (Available with `git` and `svn`.) * `filesystem_types` - Supports multiple types of filesystem. (Available with `svn`.) * `gzip_compression` - Supports explicit GZip compression levels. (Available with `cvs`.) * `include_paths` - Lets you checkout only certain paths. (Available with `svn`.) * `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`.) ## Limitations Git is the only VCS provider officially [supported by Puppet Inc.](https://forge.puppet.com/supported) Git with 3.18 changes the maximum enabled TLS protocol version, this breaks some HTTPS functionality on older operating systems. They are Enterprise Linux 5 and OracleLinux 6. The includes parameter is only supported when SVN client version is >= 1.6. -For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/master/metadata.json) +For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/main/metadata.json) ## Development Puppet Inc. 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 documentation site.](https://docs.puppet.com/guides/module_guides/bgtm.html) diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index 926667f..9ec77a4 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -1,554 +1,554 @@ # frozen_string_literal: true require 'spec_helper_acceptance' tmpdir = '/tmp/vcsrepo' describe 'clones a remote repo' do before(:all) do my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) run_shell("rm -rf #{tmpdir}") bolt_upload_file("#{my_root}/acceptance/files", tmpdir, 'create_git_repo.sh') run_shell("cd #{tmpdir} && ./create_git_repo.sh") end after(:all) do run_shell("rm -rf #{tmpdir}/testrepo") run_shell("rm -rf #{tmpdir}/testrepo_mirror_repo") end - context 'with get the current master HEAD' do + context 'with get the current main HEAD' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo/.git") do it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo/.git/HEAD") do - it { is_expected.to contain 'ref: refs/heads/master' } + it { is_expected.to contain 'ref: refs/heads/main' } end end context 'with using a https source on github', unless: only_supports_weak_encryption do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/httpstestrepo": ensure => present, provider => git, source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) 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/main' } end end context 'with using a commit SHA' do let(:sha) do run_shell("git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1").stdout.chomp end after(:all) do run_shell("rm -rf #{tmpdir}/testrepo_sha") end it 'clones a repo' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_sha": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", revision => "#{sha}", } MANIFEST # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_sha/.git") do it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo_sha/.git/HEAD") do it { is_expected.to contain sha } end end context 'with using a tag' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_tag": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", revision => '0.0.2', } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_tag/.git") do it { is_expected.to be_directory } end it 'has the tag as the HEAD' do run_shell("git --git-dir=#{tmpdir}/testrepo_tag/.git name-rev HEAD | grep '0.0.2'") end end context 'with using a branch name' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_branch": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", revision => 'a_branch', } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_branch/.git") do it { is_expected.to be_directory } end describe file("#{tmpdir}/testrepo_branch/.git/HEAD") do it { is_expected.to contain 'ref: refs/heads/a_branch' } end end context 'with ensure latest with branch specified' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_latest": ensure => latest, provider => git, source => "file://#{tmpdir}/testrepo.git", revision => 'a_branch', } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end it 'verifies the HEAD commit SHA on remote and local match' do remote_commit = run_shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout local_commit = run_shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp expect(remote_commit).to include(local_commit) end end context 'with ensure latest with branch unspecified' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_latest": ensure => latest, provider => git, source => "file://#{tmpdir}/testrepo.git", } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end it 'verifies the HEAD commit SHA on remote and local match' do remote_commit = run_shell("git ls-remote file://#{tmpdir}/testrepo_latest HEAD | head -1").stdout local_commit = run_shell("git --git-dir=#{tmpdir}/testrepo_latest/.git rev-parse HEAD").stdout.chomp expect(remote_commit).to include(local_commit) end end context 'with with shallow clone' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_shallow": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", depth => '1', } MANIFEST it 'does a shallow clone' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_shallow/.git/shallow") do it { is_expected.to be_file } end end context 'with path is not empty and not a repository' do before(:all) do run_shell("mkdir #{tmpdir}/not_a_repo", acceptable_exit_codes: [0, 1]) run_shell("touch #{tmpdir}/not_a_repo/file1.txt", acceptable_exit_codes: [0, 1]) end pp = <<-MANIFEST vcsrepo { "#{tmpdir}/not_a_repo": ensure => present, provider => git source => "file://#{tmpdir}/testrepo.git", } MANIFEST it 'raises an exception' do apply_manifest(pp, expect_failures: true) end end context 'with with an owner' do pp = <<-MANIFEST user { 'vagrant': ensure => present, } MANIFEST apply_manifest(pp, catch_failures: true) pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_owner": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", owner => 'vagrant', } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_owner") do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'vagrant' } end end context 'with with a group' do pp = <<-MANIFEST group { 'vagrant': ensure => present, } MANIFEST apply_manifest(pp, catch_failures: true) pp = <<-MANIFEST vcsrepo { "/#{tmpdir}/testrepo_group": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", group => 'vagrant', } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_group") do it { is_expected.to be_directory } it { is_expected.to be_grouped_into 'vagrant' } end end context 'with with excludes' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_excludes": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", excludes => ['exclude1.txt', 'exclude2.txt'], } MANIFEST it 'clones a repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do subject { super().content } it { is_expected.to match %r{exclude1.txt} } end describe file("#{tmpdir}/testrepo_excludes/.git/info/exclude") do subject { super().content } it { is_expected.to match %r{exclude2.txt} } end end context 'with with force' do before(:all) do run_shell("mkdir -p #{tmpdir}/testrepo_force/folder") run_shell("touch #{tmpdir}/testrepo_force/temp.txt") end it 'applies the manifest' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_force": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", force => true, } MANIFEST # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_force/folder") do it { is_expected.not_to be_directory } end describe file("#{tmpdir}/testrepo_force/temp.txt") do it { is_expected.not_to be_file } end describe file("#{tmpdir}/testrepo_force/.git") do it { is_expected.to be_directory } end context 'with and noop' do before(:all) do run_shell("mkdir #{tmpdir}/testrepo_already_exists") run_shell("cd #{tmpdir}/testrepo_already_exists && git init") run_shell("cd #{tmpdir}/testrepo_already_exists && touch a && git add a && git commit -m 'a'") end after(:all) do run_shell("rm -rf #{tmpdir}/testrepo_already_exists") end pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_already_exists": ensure => present, source => "file://#{tmpdir}/testrepo.git", provider => git, force => true, noop => true, } MANIFEST it 'applies the manifest' do apply_manifest(pp, catch_changes: true) end end end context 'with as a user' do before(:all) do run_shell("chmod 707 #{tmpdir}") pp = <<-MANIFEST group { 'testuser': ensure => present, } user { 'testuser': ensure => present, groups => 'testuser', } MANIFEST apply_manifest(pp, catch_failures: true) end pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_user": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", user => 'testuser', } MANIFEST it 'applies the manifest' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_user") do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'testuser' } end describe file("#{tmpdir}/testrepo_user") do it { is_expected.to be_directory } it { is_expected.to be_grouped_into 'testuser' } end after(:all) do pp = 'user { "testuser": ensure => absent }' apply_manifest(pp, catch_failures: true) end end context 'with non-origin remote name' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_remote": ensure => present, provider => git, source => "file://#{tmpdir}/testrepo.git", remote => 'testorigin', } MANIFEST it 'applies the manifest' do # Run it twice and test for idempotency idempotent_apply(pp) end it 'remote name is "testorigin"' do run_shell("git --git-dir=#{tmpdir}/testrepo_remote/.git remote | grep 'testorigin'") end end context 'with as a user with ssh - includes special characters' do before(:all) do # create user pp = <<-MANIFEST group { 'testuser-ssh': ensure => present, } user { 'testuser-ssh': ensure => present, groups => 'testuser-ssh', managehome => true, } MANIFEST apply_manifest(pp, catch_failures: true) # create ssh keys run_shell('mkdir -p /home/testuser-ssh/.ssh') run_shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') # copy public key to authorized_keys run_shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') run_shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config') run_shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh') end pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_user_ssh": ensure => present, provider => git, source => "git+ssh://testuser-ssh@localhost#{tmpdir}/testrepo.git", user => 'testuser-ssh', } MANIFEST it 'applies the manifest' do # Run it twice and test for idempotency idempotent_apply(pp) end after(:all) do pp = <<-MANIFEST user { 'testuser-ssh': ensure => absent, managehome => true, } MANIFEST sleep 10 apply_manifest(pp, catch_failures: true) end end context 'with using an identity file' do before(:all) do # create user pp = <<-MANIFEST user { 'testuser-ssh': ensure => present, managehome => true, } MANIFEST apply_manifest(pp, catch_failures: true) # create ssh keys run_shell('mkdir -p /home/testuser-ssh/.ssh') run_shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""') # copy public key to authorized_keys run_shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys') run_shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config') run_shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh') end pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_user_ssh_id": ensure => present, provider => git, source => "testuser-ssh@localhost:#{tmpdir}/testrepo.git", identity => '/home/testuser-ssh/.ssh/id_rsa', } MANIFEST it 'applies the manifest' do # Run it twice and test for idempotency idempotent_apply(pp) end end context 'with bare repo' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_bare_repo": ensure => bare, provider => git, source => "file://#{tmpdir}/testrepo.git", } MANIFEST it 'creates a bare repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_bare_repo/config") do it { is_expected.to contain 'bare = true' } end describe file("#{tmpdir}/testrepo_bare_repo/.git") do it { is_expected.not_to be_directory } end describe file("#{tmpdir}/testrepo_bare_repo/HEAD") do - it { is_expected.to contain 'ref: refs/heads/master' } + it { is_expected.to contain 'ref: refs/heads/main' } end end context 'with mirror repo' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_mirror_repo": ensure => mirror, provider => git, source => "file://#{tmpdir}/testrepo.git", } MANIFEST it 'creates a mirror repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_mirror_repo/config") do it { is_expected.to contain 'bare = true' } it { is_expected.to contain 'mirror = true' } end describe file("#{tmpdir}/testrepo_mirror_repo/.git") do it { is_expected.not_to be_directory } end describe file("#{tmpdir}/testrepo_mirror_repo/HEAD") do - it { is_expected.to contain 'ref: refs/heads/master' } + it { is_expected.to contain 'ref: refs/heads/main' } end end end diff --git a/spec/acceptance/create_repo_spec.rb b/spec/acceptance/create_repo_spec.rb index c2a9618..f6d2a56 100644 --- a/spec/acceptance/create_repo_spec.rb +++ b/spec/acceptance/create_repo_spec.rb @@ -1,100 +1,101 @@ # frozen_string_literal: true require 'spec_helper_acceptance' tmpdir = '/tmp/vcsrepo' describe 'create a repo' do context 'with without a source' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_blank_repo": ensure => present, provider => git, } MANIFEST it 'creates a blank repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_blank_repo/") do it 'has zero files' do run_shell("ls -1 #{tmpdir}/testrepo_blank_repo | wc -l") do |r| expect(r.stdout).to match(%r{^0\n$}) end end end describe file("#{tmpdir}/testrepo_blank_repo/.git") do it { is_expected.to be_directory } end end context 'with no source but revision provided' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_blank_with_revision_repo": ensure => present, provider => git, revision => 'master' } MANIFEST + # Can't remove the above master reference without failing the test it 'does not fail (MODULES-2125)' do # Run it twice and test for idempotency idempotent_apply(pp) end end context 'with bare repo' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_bare_repo": ensure => bare, provider => git, } MANIFEST it 'creates a bare repo' do # Run it twice and test for idempotency idempotent_apply(pp) end describe file("#{tmpdir}/testrepo_bare_repo/config") do it { is_expected.to contain 'bare = true' } end describe file("#{tmpdir}/testrepo_bare_repo/.git") do it { is_expected.not_to be_directory } end end context 'with bare repo with a revision' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_bare_repo_rev": ensure => bare, provider => git, - revision => 'master', + revision => 'main', } MANIFEST it 'does not create a bare repo when a revision is defined' do apply_manifest(pp, expect_failures: true) end describe file("#{tmpdir}/testrepo_bare_repo_rev") do it { is_expected.not_to be_directory } end end context 'with mirror repo' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo_mirror_repo": ensure => mirror, provider => git, } MANIFEST it 'does not create a mirror repo' do apply_manifest(pp, expect_failures: true) end describe file("#{tmpdir}/testrepo_mirror_repo") do it { is_expected.not_to be_directory } end end end diff --git a/spec/acceptance/files/create_git_repo.sh b/spec/acceptance/files/create_git_repo.sh index b5e930c..c9f151e 100755 --- a/spec/acceptance/files/create_git_repo.sh +++ b/spec/acceptance/files/create_git_repo.sh @@ -1,39 +1,42 @@ #!/bin/bash mkdir testrepo cd testrepo -touch file1.txt file2.txt file3.txt git init +touch file1.txt file2.txt file3.txt + echo 'change 1' > file1.txt git add file1.txt git commit -m 'add file1' +# Rename the initial branch +git branch -m main git tag 0.0.1 echo 'change 2' > file2.txt git add file2.txt git commit -m 'add file2' git tag 0.0.2 echo 'change 3' > file3.txt git add file3.txt git commit -m 'add file3' git tag 0.0.3 git checkout -b a_branch echo 'change 4' > file4.txt git add file4.txt git commit -m 'add file4' echo 'change 5' > file5.txt git add file5.txt git commit -m 'add file5' echo 'change 6' > file6.txt git add file6.txt git commit -m 'add file6' -git checkout master +git checkout main cd .. git --git-dir=testrepo/.git config core.bare true cp -r testrepo/.git testrepo.git rm -rf testrepo cd testrepo.git touch git-daemon-export-ok git update-server-info diff --git a/spec/acceptance/revision_spec.rb b/spec/acceptance/revision_spec.rb index 9ea548a..e26963b 100644 --- a/spec/acceptance/revision_spec.rb +++ b/spec/acceptance/revision_spec.rb @@ -1,89 +1,89 @@ # frozen_string_literal: true require 'spec_helper_acceptance' tmpdir = '/tmp/vcsrepo' describe 'changing revision' do before(:all) do # Create testrepo.git my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) bolt_upload_file("#{my_root}/acceptance/files", tmpdir, 'create_git_repo.sh') run_shell("cd #{tmpdir} && ./create_git_repo.sh") # Configure testrepo.git as upstream of testrepo pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo": ensure => present, provider => git, revision => 'a_branch', source => "file://#{tmpdir}/testrepo.git", } MANIFEST apply_manifest(pp, catch_failures: true) end after(:all) do run_shell("rm -rf #{tmpdir}/testrepo.git") end shared_examples 'switch to branch/tag/sha' do pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo": ensure => latest, provider => git, revision => 'a_branch', source => "file://#{tmpdir}/testrepo.git", } MANIFEST it 'pulls the new branch commits' do idempotent_apply(pp) end pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo": ensure => latest, provider => git, revision => '0.0.3', source => "file://#{tmpdir}/testrepo.git", } MANIFEST it 'checks out the tag' do idempotent_apply(pp) end it 'checks out the sha' do - sha = run_shell("cd #{tmpdir}/testrepo && git rev-parse origin/master").stdout.chomp + sha = run_shell("cd #{tmpdir}/testrepo && git rev-parse origin/main").stdout.chomp pp = <<-MANIFEST vcsrepo { "#{tmpdir}/testrepo": ensure => latest, provider => git, revision => '#{sha}', source => "file://#{tmpdir}/testrepo.git", } MANIFEST idempotent_apply(pp) end end context 'when on branch' do before :each do run_shell("cd #{tmpdir}/testrepo && git checkout a_branch") run_shell("cd #{tmpdir}/testrepo && git reset --hard 0.0.2") end it_behaves_like 'switch to branch/tag/sha' end context 'when on tag' do before :each do run_shell("cd #{tmpdir}/testrepo && git checkout 0.0.1") end it_behaves_like 'switch to branch/tag/sha' end context 'when on detached head' do before :each do run_shell("cd #{tmpdir}/testrepo && git checkout 0.0.2") run_shell("cd #{tmpdir}/testrepo && git checkout HEAD~1") end it_behaves_like 'switch to branch/tag/sha' end end diff --git a/spec/fixtures/git_branch_a.txt b/spec/fixtures/git_branch_a.txt index 2c99829..fc77f56 100644 --- a/spec/fixtures/git_branch_a.txt +++ b/spec/fixtures/git_branch_a.txt @@ -1,14 +1,14 @@ feature/foo feature/bar feature/baz feature/quux only/local -* master +* main refactor/foo origin/HEAD origin/feature/foo origin/feature/bar origin/feature/baz origin/feature/quux origin/only/remote - origin/master + origin/main diff --git a/spec/fixtures/git_branch_feature_bar.txt b/spec/fixtures/git_branch_feature_bar.txt index 72d5e20..b560171 100644 --- a/spec/fixtures/git_branch_feature_bar.txt +++ b/spec/fixtures/git_branch_feature_bar.txt @@ -1,14 +1,14 @@ feature/foo * feature/bar feature/baz feature/quux only/local - master + main refactor/foo origin/HEAD origin/feature/foo origin/feature/bar origin/feature/baz origin/feature/quux origin/only/remote - origin/master + origin/main diff --git a/spec/fixtures/git_branch_none.txt b/spec/fixtures/git_branch_none.txt index 7207c37..9c49743 100644 --- a/spec/fixtures/git_branch_none.txt +++ b/spec/fixtures/git_branch_none.txt @@ -1,15 +1,15 @@ feature/foo feature/bar feature/baz feature/quux only/local - master + main * (no branch) refactor/foo origin/HEAD origin/feature/foo origin/feature/bar origin/feature/baz origin/feature/quux origin/only/remote - origin/master + origin/main diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index 6ea27ef..9e0ec2f 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -1,590 +1,590 @@ # frozen_string_literal: true require 'spec_helper' describe Puppet::Type.type(:vcsrepo).provider(:git) do def branch_a_list(include_branch = nil?) < 'git://git@foo.com/bar.git', 'other' => 'git://git@foo.com/baz.git' } resource.delete(:revision) expect(Dir).to receive(:chdir).with('/').once.and_yield expect(provider).to receive(:git).with('clone', '--mirror', resource.value(:source)['origin'], resource.value(:path)) expect(provider).to receive(:update_remotes) expect_chdir expect(provider).to receive(:git).with('config', 'remote.origin.mirror', 'true') expect(provider).to receive(:git).with('config', 'remote.other.mirror', 'true') provider.create end end end context 'when with an ensure of mirror - when the path is a working copy repository' do it 'clones overtop it using force' do resource[:force] = true expect(Dir).to receive(:chdir).with('/').once.and_yield expect(Dir).to receive(:chdir).with('/tmp/test').at_least(:once).and_yield expect(provider).to receive(:path_exists?).and_return(true) expect(provider).to receive(:path_empty?).and_return(false) provider.destroy expect(provider).to receive(:git).with('clone', resource.value(:source), resource.value(:path)) expect(provider).to receive(:update_submodules) expect(provider).to receive(:update_remote_url).with('origin', resource.value(:source)).and_return false expect(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list(resource.value(:revision))) expect(provider).to receive(:git).with('checkout', '--force', resource.value(:revision)) provider.create end end context 'when with an ensure of mirror - when the path is not empty and not a repository' do it 'raises an exception' do expect(provider).to receive(:path_exists?).and_return(true) expect(provider).to receive(:path_empty?).and_return(false) expect { provider.create }.to raise_error(Puppet::Error) end end context 'when converting repo type' do context 'when with working copy to bare' do it 'converts the repo' do resource[:ensure] = :bare expect(provider).to receive(:working_copy_exists?).and_return(true) expect(provider).to receive(:bare_exists?).and_return(false) expect(FileUtils).to receive(:mv).and_return(true) expect(FileUtils).to receive(:rm_rf).and_return(true) expect(FileUtils).to receive(:mv).and_return(true) expect_chdir expect(provider).to receive(:git).with('config', '--local', '--bool', 'core.bare', 'true') provider.instance_eval { convert_working_copy_to_bare } end end context 'when with working copy to mirror' do it 'converts the repo' do resource[:ensure] = :mirror expect(provider).to receive(:working_copy_exists?).and_return(true) expect(provider).to receive(:bare_exists?).and_return(false) expect(FileUtils).to receive(:mv).and_return(true) expect(FileUtils).to receive(:rm_rf).and_return(true) expect(FileUtils).to receive(:mv).and_return(true) expect_chdir expect(provider).to receive(:git).with('config', '--local', '--bool', 'core.bare', 'true') expect(provider).to receive(:git).with('config', 'remote.origin.mirror', 'true') provider.instance_eval { convert_working_copy_to_bare } end end context 'when with bare copy to working copy' do it 'converts the repo' do expect(FileUtils).to receive(:mv).and_return(true) expect(FileUtils).to receive(:mkdir).and_return(true) expect(FileUtils).to receive(:mv).and_return(true) expect_chdir expect(provider).to receive(:commits?).and_return(true) # If you forget to stub these out you lose 3 hours of rspec work. expect(provider).to receive(:git) .with('config', '--local', '--bool', 'core.bare', 'false').and_return(true) expect(provider).to receive(:reset).with('HEAD').and_return(true) expect(provider).to receive(:git_with_identity).with('checkout', '--force').and_return(true) expect(provider).to receive(:update_owner_and_excludes).and_return(true) expect(provider).to receive(:mirror?).and_return(false) provider.instance_eval { convert_bare_to_working_copy } end end context 'when with mirror to working copy' do it 'converts the repo' do expect(FileUtils).to receive(:mv).and_return(true) expect(FileUtils).to receive(:mkdir).and_return(true) expect(FileUtils).to receive(:mv).and_return(true) expect_chdir expect(provider).to receive(:commits?).and_return(true) expect(provider).to receive(:git) .with('config', '--local', '--bool', 'core.bare', 'false').and_return(true) expect(provider).to receive(:reset).with('HEAD').and_return(true) expect(provider).to receive(:git_with_identity).with('checkout', '--force').and_return(true) expect(provider).to receive(:update_owner_and_excludes).and_return(true) expect(provider).to receive(:git).with('config', '--unset', 'remote.origin.mirror') expect(provider).to receive(:mirror?).and_return(true) provider.instance_eval { convert_bare_to_working_copy } end end end context 'when destroying' do it 'removes the directory' do expect_rm_rf provider.destroy end end context 'when checking the revision property' do before(:each) do expect_chdir('/tmp/test') resource[:source] = 'http://example.com' allow(provider).to receive(:git).with('config', 'remote.origin.url').and_return('') allow(provider).to receive(:git).with('fetch', 'origin') # FIXME allow(provider).to receive(:git).with('fetch', '--tags', 'origin') allow(provider).to receive(:git).with('rev-parse', 'HEAD').and_return('currentsha') allow(provider).to receive(:git).with('tag', '-l').and_return('Hello') end context 'when its a SHA and is not different than the current SHA' do it 'and_return the current SHA' do resource[:revision] = 'currentsha' allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list) expect(provider).to receive(:git).with('rev-parse', '--revs-only', resource.value(:revision)).never expect(provider).to receive(:update_references).never expect(provider.revision).to eq(resource.value(:revision)) end end context 'when its a SHA and is different than the current SHA' do it 'and_return the current SHA' do resource[:revision] = 'othersha' allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list) expect(provider).to receive(:git).with('rev-parse', '--revs-only', resource.value(:revision)).and_return('othersha') expect(provider).to receive(:update_references) expect(provider.revision).to eq('currentsha') end end context 'when its a local branch and is not different than the current SHA' do it 'and_return the ref' do resource[:revision] = 'localbranch' allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list('localbranch')) expect(provider).to receive(:git).with('rev-parse', resource.value(:revision)).and_return('currentsha') expect(provider).to receive(:update_references) expect(provider.revision).to eq(resource.value(:revision)) end end context 'when its a local branch and is different than the current SHA' do it 'and_return the current SHA' do resource[:revision] = 'localbranch' allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list('localbranch')) expect(provider).to receive(:git).with('rev-parse', resource.value(:revision)).and_return('othersha') expect(provider).to receive(:update_references) expect(provider.revision).to eq('currentsha') end end context 'when its a ref to a remote head' do it 'and_return the ref' do resource[:revision] = 'remotebranch' allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(" remotes/origin/#{resource.value(:revision)}") expect(provider).to receive(:git).with('rev-parse', "origin/#{resource.value(:revision)}").and_return('currentsha') expect(provider).to receive(:update_references) expect(provider.revision).to eq(resource.value(:revision)) end end context 'when its a ref to non existant remote head' do it 'fails' do resource[:revision] = 'remotebranch' allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list) expect(provider).to receive(:git).with('rev-parse', '--revs-only', resource.value(:revision)).and_return('') expect(provider).to receive(:update_references) expect { provider.revision }.to raise_error(RuntimeError, %r{not a local or remote ref$}) end end context "when there's no source" do it 'and_return the revision' do resource[:revision] = 'localbranch' resource.delete(:source) allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list('localbranch')) expect(provider).to receive(:update_references).never expect(provider).to receive(:git).with('status') expect(provider).to receive(:git).with('rev-parse', resource.value(:revision)).and_return('currentsha') expect(provider.revision).to eq(resource.value(:revision)) end end end context 'when setting the revision property' do before(:each) do expect_chdir end context "when it's an existing local branch" do it "uses 'git fetch' and 'git reset'" do resource[:revision] = 'feature/foo' expect(provider).to receive(:update_submodules) expect(provider).to receive(:git).with('branch', '--no-color', '-a').at_least(:once).and_return(branch_a_list(resource.value(:revision))) expect(provider).to receive(:git).with('checkout', '--force', resource.value(:revision)) expect(provider).to receive(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}") provider.revision = resource.value(:revision) end end context "when it's a remote branch" do it "uses 'git fetch' and 'git reset'" do resource[:revision] = 'only/remote' expect(provider).to receive(:update_submodules) expect(provider).to receive(:git).with('branch', '--no-color', '-a').at_least(:once).and_return(resource.value(:revision)) expect(provider).to receive(:git).with('checkout', '--force', resource.value(:revision)) expect(provider).to receive(:git).with('reset', '--hard', "origin/#{resource.value(:revision)}") provider.revision = resource.value(:revision) end end context "when it's a commit or tag" do it "uses 'git fetch' and 'git reset'" do resource[:revision] = 'a-commit-or-tag' expect(provider).to receive(:git).with('branch', '--no-color', '-a').once.and_return(fixture(:git_branch_a)) expect(provider).to receive(:git).with('checkout', '--force', resource.value(:revision)) expect(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(fixture(:git_branch_a)) expect(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(fixture(:git_branch_a)) expect(provider).to receive(:git).with('submodule', 'update', '--init', '--recursive') provider.revision = resource.value(:revision) end end context 'when ignoring local changes' do it "uses 'git stash'" do resource[:revision] = 'a-commit-or-tag' resource[:keep_local_changes] = true expect(provider).to receive(:git).with('stash', 'save') expect(provider).to receive(:git).with('branch', '--no-color', '-a').once.and_return(fixture(:git_branch_a)) expect(provider).to receive(:git).with('checkout', '--force', resource.value(:revision)) expect(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(fixture(:git_branch_a)) expect(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(fixture(:git_branch_a)) expect(provider).to receive(:git).with('submodule', 'update', '--init', '--recursive') expect(provider).to receive(:git).with('stash', 'pop') provider.revision = resource.value(:revision) end end end context 'when checking the source property' do before(:each) do expect_chdir('/tmp/test') allow(provider).to receive(:git).with('config', 'remote.origin.url').and_return('') allow(provider).to receive(:git).with('fetch', 'origin') # FIXME allow(provider).to receive(:git).with('fetch', '--tags', 'origin') allow(provider).to receive(:git).with('rev-parse', 'HEAD').and_return('currentsha') allow(provider).to receive(:git).with('branch', '--no-color', '-a').and_return(branch_a_list(resource.value(:revision))) allow(provider).to receive(:git).with('tag', '-l').and_return('Hello') end context "when there's a single remote 'origin'" do it 'and_return the URL for the remote' do resource[:source] = 'http://example.com' expect(provider).to receive(:git).with('remote').and_return("origin\n") expect(provider).to receive(:git).with('config', '--get', 'remote.origin.url').and_return('http://example.com') expect(provider.source).to eq(resource.value(:source)) end end context "when there's more than one remote" do it 'and_return the remotes as a hash' do resource[:source] = { 'origin' => 'git://git@foo.com/bar.git', 'other' => 'git://git@foo.com/baz.git' } expect(provider).to receive(:git).with('remote').and_return("origin\nother\n") expect(provider).to receive(:git).with('config', '--get', 'remote.origin.url').and_return('git://git@foo.com/bar.git') expect(provider).to receive(:git).with('config', '--get', 'remote.other.url').and_return('git://git@foo.com/baz.git') expect(provider.source).to eq(resource.value(:source)) end end end context 'when updating remotes' do context 'when with string to string' do it 'fails' do resource[:source] = 'git://git@foo.com/bar.git' resource[:force] = false expect(provider).to receive(:source).and_return('git://git@foo.com/foo.git') expect(provider).to receive(:path_exists?).and_return(true) expect(provider).to receive(:path_empty?).and_return(false) expect { provider.source = resource.value(:source) }.to raise_error(Puppet::Error) end end context 'when with hash to hash' do it 'adds any new remotes, update any existing remotes, remove deleted remotes' do expect_chdir resource[:source] = { 'origin' => 'git://git@foo.com/bar.git', 'new_remote' => 'git://git@foo.com/baz.git' } expect(provider).to receive(:source).and_return( 'origin' => 'git://git@foo.com/foo.git', 'old_remote' => 'git://git@foo.com/old.git', ) expect(provider).to receive(:git).once.with('config', '-l').and_return("remote.old_remote.url=git://git@foo.com/old.git\n", "remote.origin.url=git://git@foo.com/foo.git\n") expect(provider).to receive(:git).with('remote', 'remove', 'old_remote') expect(provider).to receive(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/bar.git') expect(provider).to receive(:git).with('remote', 'add', 'new_remote', 'git://git@foo.com/baz.git') expect(provider).to receive(:git).with('remote', 'update') provider.source = resource.value(:source) end end context 'when with string to hash' do it 'adds any new remotes, update origin remote' do expect_chdir resource[:source] = { 'origin' => 'git://git@foo.com/bar.git', 'new_remote' => 'git://git@foo.com/baz.git' } expect(provider).to receive(:source).and_return('git://git@foo.com/foo.git') expect(provider).to receive(:git).at_least(:once).with('config', '-l').and_return("remote.origin.url=git://git@foo.com/foo.git\n") expect(provider).to receive(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/bar.git') expect(provider).to receive(:git).with('remote', 'add', 'new_remote', 'git://git@foo.com/baz.git') expect(provider).to receive(:git).with('remote', 'update') provider.source = resource.value(:source) end end context 'when with hash to string' do it 'updates origin remote, remove deleted remotes' do expect_chdir resource[:source] = 'git://git@foo.com/baz.git' expect(provider).to receive(:source).and_return( 'origin' => 'git://git@foo.com/foo.git', 'old_remote' => 'git://git@foo.com/old.git', ) expect(provider).to receive(:git).with('remote', 'remove', 'old_remote') expect(provider).to receive(:git).with('config', '-l').at_most(:twice).and_return("remote.origin.url=git://git@foo.com/foo.git\n", "remote.other.url=git://git@foo.com/bar.git\n") expect(provider).to receive(:git).with('remote', 'set-url', 'origin', 'git://git@foo.com/baz.git') expect(provider).to receive(:git).with('remote', 'update') provider.source = resource.value(:source) end end end # rubocop:enable RSpec/ExampleLength context 'when updating references' do it "uses 'git fetch --tags'" do resource.delete(:source) expect_chdir expect(provider).to receive(:git).with('fetch', 'origin') expect(provider).to receive(:git).with('fetch', '--tags', 'origin') provider.update_references end end describe 'latest?' do context 'when true' do it do expect(provider).to receive(:revision).and_return('testrev') expect(provider).to receive(:latest_revision).and_return('testrev') expect(provider).to be_latest end end context 'when false' do it do - expect(provider).to receive(:revision).and_return('master') + expect(provider).to receive(:revision).and_return('main') expect(provider).to receive(:latest_revision).and_return('testrev') expect(provider).not_to be_latest end end end describe 'trust_server_cert' do context 'when true' do before :each do resource[:trust_server_cert] = true end it 'raises error with git 1.7.0' do allow(provider).to receive(:git).with('--version').and_return '1.7.0' expect { provider.create }.to raise_error RuntimeError, %r{Can't set sslVerify to false} end it 'compiles with git 2.13.0' do resource[:revision] = 'only/remote' expect(Dir).to receive(:chdir).with('/').once.and_yield expect(Dir).to receive(:chdir).with('/tmp/test').at_least(:once).and_yield expect(provider).to receive(:git).with('-c', 'http.sslVerify=false', 'clone', resource.value(:source), resource.value(:path)) expect(provider).to receive(:update_submodules) expect(provider).to receive(:update_remote_url).with('origin', resource.value(:source)).and_return false expect(provider).to receive(:git).with('-c', 'http.sslVerify=false', 'branch', '--no-color', '-a').and_return(branch_a_list(resource.value(:revision))) expect(provider).to receive(:git).with('-c', 'http.sslVerify=false', 'checkout', '--force', resource.value(:revision)) allow(provider).to receive(:git).with('--version').and_return '2.13.0' expect { provider.create }.not_to raise_error end end end context 'owner' do it 'without excludes run FileUtils.chown_R' do resource[:owner] = 'john' expect_chdir expect(FileUtils).to receive(:chown_R).with('john', nil, '/tmp/test') expect(provider).to receive(:git).with('fetch', 'origin') expect(provider).to receive(:git).with('fetch', '--tags', 'origin') provider.update_references end it 'with excludes run filtered chown_R' do resource[:owner] = 'john' resource[:excludes] = ['bzr', 'cvs', 'hg', 'p4', 'svn'] expect_chdir filtered_files = ['git/a', 'git/b'] expect(provider).to receive(:files).and_return(filtered_files) expect(FileUtils).to receive(:chown).with('john', nil, filtered_files) expect(provider).to receive(:set_excludes) expect(provider).to receive(:git).with('fetch', 'origin') expect(provider).to receive(:git).with('fetch', '--tags', 'origin') provider.update_references end end end