From 34cc0c0d4e35fdc5a7b8381033886d160927d501 Mon Sep 17 00:00:00 2001 From: Paul Allen Date: Wed, 2 Jul 2014 12:05:35 +0100 Subject: Update Markdown with missing Perforce details. Fix tabs/spaces in p4.rb --- README.markdown | 10 ++++- lib/puppet/provider/vcsrepo/p4.rb | 56 ++++++++++++++-------------- spec/unit/puppet/provider/vcsrepo/p4_spec.rb | 2 +- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/README.markdown b/README.markdown index f83c7fd..7ce9657 100644 --- a/README.markdown +++ b/README.markdown @@ -459,6 +459,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `cvs` - Supports the CVS VCS. (Contains features: `cvs_rsh`, `gzip_compression`, `modules`,`reference_tracking`.) * `dummy` - * `hg` - Supports the Mercurial VCS. (Contains features: `reference_tracking`, `ssh_identity`, `user`.) +* `p4` - Supports the Perforce VCS. (Contains features: `reference_tracking`, `filesystem_types`, `p4config`.) * `svn` - Supports the Subversion VCS. (Contains features: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking`.) ####Features @@ -477,6 +478,7 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `reference_tracking` - The provider supports tracking revision references that can change over time (e.g. some VCS tags and branch names). (Available with `bar`, `cvs`, `git`, `hg`, `svn`.) * `ssh_identity` - The provider supports a configurable SSH identity file. (Available with `git` and `hg`.) * `user` - The provider can run as a different user. (Available with `git` and `hg`.) +* `p4config` - The provider support setting the P4CONFIG environment. (Available with `p4`.) ####Parameters @@ -494,12 +496,13 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers * `identity` - Specifies the SSH identity file. (Requires the `ssh_identity` feature.) * `module` - Specifies the repository module to manage. (Requires the `modules` feature.) * `owner` - Specifies the user/uid that owns the repository files. -* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. +* `path` - Specifies the absolute path to the repository. If omitted, the value defaults to the resource's title. * `provider` - Specifies the backend to use for this vcsrepo resource. * `remote` - Specifies the remote repository to track. (Requires the `multiple_remotes` feature.) * `revision` - Sets the revision of the repository. Values can match /^\S+$/. * `source` - Specifies the source URI for the repository. * `user` - Specifies the user to run as for repository operations. +* `p4config` - Specifies the P4CONFIG environment used for Perforce connection configuration. ####Features and Parameters by Provider @@ -523,6 +526,11 @@ The vcsrepo module is slightly unusual in that it is simply a type and providers **Parameters**: `ensure`, `excludes`, `force`, `group`, `identity`, `owner`, `path`, `provider`, `revision`, `source`, `user` +#####`p4` +**Features**: `reference_tracking`, `filesystem_types`, `p4config` + +**Parameters**: `ensure`, `group`, `owner`, `path`, `provider`, `revision`, `source`, `p4config` + #####`svn` **Features**: `basic_auth`, `configuration`, `filesystem_types`, `reference_tracking` diff --git a/lib/puppet/provider/vcsrepo/p4.rb b/lib/puppet/provider/vcsrepo/p4.rb index 4f53415..63d3df2 100644 --- a/lib/puppet/provider/vcsrepo/p4.rb +++ b/lib/puppet/provider/vcsrepo/p4.rb @@ -68,12 +68,12 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d revision = 0 if hash && hash['code'] != 'error' - hash['data'].each do |c| - if c['status'] == 'have' - change = c['change'].to_i - revision = change if change > revision - end - end + hash['data'].each do |c| + if c['status'] == 'have' + change = c['change'].to_i + revision = change if change > revision + end + end end return revision end @@ -180,7 +180,7 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d view = "\nView:\n" hash.keys.sort.each do |k| - v = hash[k] + v = hash[k] next if( k == "code" ) if(k.to_s =~ /View/ ) view += "\t#{v}\n" @@ -251,28 +251,28 @@ Puppet::Type.type(:vcsrepo).provide(:p4, :parent => Puppet::Provider::Vcsrepo) d # helper method as cstat does not Marshal def marshal_cstat(hash) - data = hash['data'] - code = 'error' - - list = Array.new - change = Hash.new - data.each_line do |l| - p = /^\.\.\. (.*) (.*)$/ - m = p.match(l) - if m + data = hash['data'] + code = 'error' + + list = Array.new + change = Hash.new + data.each_line do |l| + p = /^\.\.\. (.*) (.*)$/ + m = p.match(l) + if m change[m[1]] = m[2] - if m[1] == 'status' - code = 'stat' - list.push change - change = Hash.new - end - end - end - - hash = Hash.new - hash.store 'code', code - hash.store 'data', list - return hash + if m[1] == 'status' + code = 'stat' + list.push change + change = Hash.new + end + end + end + + hash = Hash.new + hash.store 'code', code + hash.store 'data', list + return hash end end diff --git a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb index 2d382da..abbd9ec 100644 --- a/spec/unit/puppet/provider/vcsrepo/p4_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/p4_spec.rb @@ -51,7 +51,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:p4) do ENV['P4CLIENT'] = nil path = resource.value(:path) - host = Facter.value('hostname') + host = Facter.value('hostname') default = "puppet-" + Digest::MD5.hexdigest(path + host) provider.expects(:p4).with(['client', '-o', default]).returns({}) -- cgit v1.2.3