Skip to content

Commit

Permalink
Update vcsrepo to dd4b638a420c75eb3a3a2badceffc720be231096
Browse files Browse the repository at this point in the history
dd4b638a420c75eb3a3a2badceffc720be231096 Merge pull request redhat-openstack#263 from mhaskel/MODULES-2326
f385df10c57a0a09fa316004e6af18acd56df710 MODULES-2326 - Run Regexp.escape on the source URL
d7534d7cfe98d62b8f0d9ae8adcc30bea483a1e2 Merge pull request redhat-openstack#261 from mhaskel/MODULES-2125
14c05f5d6c589bebc9f93eb117105c14ce7be6f1 MODULES-2125 - Allow revision to be passed without source
5ef1b4740e1aab6672ee3971762c796c898ca639 Merge pull request redhat-openstack#260 from mhaskel/MODULES-1800
d68402d1f930d5a30f1ec9224ac3791b6d9d29b9 MODULES-1800 - fix case where ensure => latest and no revision specified
266b20510b9eec7e8e91096f5aa370ae52a136e7 Merge pull request redhat-openstack#259 from mhaskel/merge_1.3.x_to_master
56d55ee4426ddcbcf568d5b413ed780812738657 Merge pull request redhat-openstack#258 from mhaskel/1.3.1-prep
03ceba70e71e32a4ed56a06c716d91f7db2783f9 1.3.1 prep
231f711e3f0ccb8601bea55f0e6d562b8674488e Merge pull request redhat-openstack#256 from keeleysam/master
b3cddcbd57639acbf0c4a7fa671a70f787e010da fix for detached HEAD on git 2.4+
3a437ea1bc4eafb64621911c34e9821f1e10241b Merge pull request redhat-openstack#242 from BillWeiss/bump-ssl-expiry
1be44c3b95b8e01ac583661c5f9465c141cf82da Just bumping the expiration date...

Change-Id: Ica9906d21ddd26f90fe513b158360bde8ba9018b
  • Loading branch information
xbezdick committed Aug 20, 2015
1 parent 2e2ee5f commit 819a93a
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ mod 'tuskar',
:git => 'https://github.com/openstack/puppet-tuskar.git'

mod 'vcsrepo',
:commit => 'fd63cd94caae3aedcce53b8fad9fd1d5f29139da',
:commit => 'dd4b638a420c75eb3a3a2badceffc720be231096',
:git => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git'

mod 'vlan',
Expand Down
11 changes: 11 additions & 0 deletions vcsrepo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## [1.3.1] - 2015-07-28 Supported Release
###Summary
This release includes a number of bugfixes along with some test updates.

### Fixed
- Fix for detached HEAD on git 2.4+
- Git provider doesn't ignore revision property when depth is used (MODULES-2131)
- Test fixes
- 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.
Expand Down Expand Up @@ -125,6 +135,7 @@ our many contributors for all of these fixes!
- CVS:
- Documented the "module" attribute.

[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
Expand Down
32 changes: 26 additions & 6 deletions vcsrepo/lib/puppet/provider/vcsrepo/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def latest?
#
# @return [String] Returns the target sha/tag/branch
def latest
@resource.value(:revision)
if not @resource.value(:revision) and branch = on_branch?
return branch
else
return @resource.value(:revision)
end
end

# Get the current revision of the repo (tag/branch/sha)
Expand All @@ -72,7 +76,11 @@ def revision=(desired)
#updated and authoritative.
#TODO might be worthwhile to have an allow_local_changes param to decide
#whether to reset or pull when we're ensuring latest.
at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") }
if @resource.value(:source)
at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") }
else
at_path { git_with_identity('reset', '--hard', "#{desired}") }
end
end
#TODO Would this ever reach here if it is bare?
if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true
Expand Down Expand Up @@ -103,7 +111,7 @@ def default_url

def working_copy_exists?
if @resource.value(:source) and File.exists?(File.join(@resource.value(:path), '.git', 'config'))
File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{default_url}/).any?
File.readlines(File.join(@resource.value(:path), '.git', 'config')).grep(/#{Regexp.escape(default_url)}/).any?
else
File.directory?(File.join(@resource.value(:path), '.git'))
end
Expand Down Expand Up @@ -281,7 +289,7 @@ def commits_in?(dot_git)
# handle upstream branch changes
# @!visibility private
def checkout(revision = @resource.value(:revision))
if !local_branch_revision? && remote_branch_revision?
if !local_branch_revision?(revision) && remote_branch_revision?(revision)
#non-locally existant branches (perhaps switching to a branch that has never been checked out)
at_path { git_with_identity('checkout', '--force', '-b', revision, '--track', "#{@resource.value(:remote)}/#{revision}") }
else
Expand Down Expand Up @@ -329,11 +337,13 @@ def branches
at_path { git_with_identity('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip }
end

# git < 2.4 returns 'detached from'
# git 2.4+ returns 'HEAD detached at'
# @!visibility private
def on_branch?
at_path {
matches = git_with_identity('branch', '-a').match /\*\s+(.*)/
matches[1] unless matches[1].match /(\(detached from|\(no branch)/
matches[1] unless matches[1].match /(\(detached from|\(HEAD detached at|\(no branch)/
}
end

Expand Down Expand Up @@ -386,7 +396,17 @@ def latest_revision
# @return [String] Returns the tag/branch of the current repo if it's up to
# date; otherwise returns the sha of the requested revision.
def get_revision(rev = 'HEAD')
update_references
if @resource.value(:source)
update_references
else
status = at_path { git_with_identity('status')}
is_it_new = status =~ /Initial commit/
if is_it_new
status =~ /On branch (.*)/
branch = $1
return branch
end
end
current = at_path { git_with_identity('rev-parse', rev).strip }
if @resource.value(:revision)
if tag_revision?
Expand Down
12 changes: 6 additions & 6 deletions vcsrepo/metadata.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "puppetlabs-vcsrepo",
"version": "1.3.0",
"version": "1.3.1",
"author": "Puppet Labs",
"summary": "Puppet module providing a type to manage repositories from various version control systems",
"license": "GPLv2",
"source": "https://github.com/puppetlabs/puppetlabs-vcsrepo",
"project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"dependencies": [

],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
Expand Down Expand Up @@ -67,14 +70,11 @@
"requirements": [
{
"name": "pe",
"version_requirement": "3.x"
"version_requirement": ">= 3.0.0 < 2015.3.0"
},
{
"name": "puppet",
"version_requirement": "3.x"
"version_requirement": ">= 3.0.0 < 5.0.0"
}
],
"dependencies": [

]
}
16 changes: 16 additions & 0 deletions vcsrepo/spec/acceptance/create_repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@
end
end

context 'no source but revision provided' do
it 'should not fail (MODULES-2125)' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_blank_with_revision_repo":
ensure => present,
provider => git,
revision => 'master'
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
end

context 'bare repo' do
it 'creates a bare repo' do
pp = <<-EOS
Expand Down
14 changes: 7 additions & 7 deletions vcsrepo/spec/acceptance/files/server.crt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-----BEGIN CERTIFICATE-----
MIICATCCAWoCCQCS3fQotV10LzANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMB4XDTE0MDQyMzIyMzEyM1oXDTE1MDQyMzIyMzEyM1owRTELMAkG
A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
MIICATCCAWoCCQDRobnOvvkStDANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMB4XDTE1MDQwODE3MjM1NVoXDTI1MDQwNTE3MjM1NVowRTELMAkG
A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyRTv
uX6328aQ5Auc8PI+xNaCiE0UZNYcs+xq3AEkR/Tnz0HGXdx3+PnFG7MIRSS65hXA
VGenZk3wP4vNIe9gu+G9jtOFTJOgoOBUnJ/Hcs79Zgcmz3cAWQpqww+CZpyngUDS
msZ5HoEbNS+qaIron3IrYCgPsy1BHFs5ze7JrtcCAwEAATANBgkqhkiG9w0BAQUF
AAOBgQA2uLvdc1cf+nt7d8Lmu0SdaoIsCzh6DjVscCpFJKXdDjGT2Ys40iKbLRnY
Tt98wa6uRzEhSKfx+zVi8n3PSkQHlER7jzKFXMVx8NEt2/O/APKXVizmLFjk5WcT
FvGmmbkqX+Nj9TUTuSRZEmF776r5k8U5ABu/VarxvAzyoXAhqA==
AAOBgQCaYVv8WbFbrnLMOcyjE7GjSmVh68fEN+AqntZa1Z5GOv6OQIN9mVSoNxWo
lb/9xmldfMQThgKckHHvB5Q9kf923nMQZOi8yxyaoeYWrkglkFFU/sdF6yuFBdUU
D+rXmHnS754FLTGDzESmlRVUCYuwVgrRdm+P+wu2+lZT3x85VA==
-----END CERTIFICATE-----
41 changes: 41 additions & 0 deletions vcsrepo/spec/acceptance/modules_1800_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'spec_helper_acceptance'

tmpdir = default.tmpdir('vcsrepo')

describe 'clones a remote repo' do
before(:all) do
my_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
shell("mkdir -p #{tmpdir}") # win test
end

after(:all) do
shell("rm -rf #{tmpdir}/vcsrepo")
end

context 'ensure latest with no revision' do
it 'clones from default remote' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/vcsrepo":
ensure => present,
provider => git,
source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git",
}
EOS

apply_manifest(pp, :catch_failures => true)
shell("cd #{tmpdir}/vcsrepo; /usr/bin/git reset --hard HEAD~2")
end

it 'updates' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/vcsrepo":
ensure => latest,
provider => git,
source => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git",
}
EOS

apply_manifest(pp, :catch_failures => true)
end
end
end
69 changes: 69 additions & 0 deletions vcsrepo/spec/acceptance/modules_2326_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
require 'spec_helper_acceptance'

tmpdir = default.tmpdir('vcsrepo')

describe 'clones with special characters' do

before(:all) do
my_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
shell("mkdir -p #{tmpdir}") # win test
scp_to(default, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
shell("cd #{tmpdir} && ./create_git_repo.sh")
end

after(:all) do
shell("rm -rf #{tmpdir}/testrepo.git")
end

context 'as a user with ssh' do
before(:all) do
# create user
pp = <<-EOS
group { 'testuser-ssh':
ensure => present,
}
user { 'testuser-ssh':
ensure => present,
groups => 'testuser-ssh',
managehome => true,
}
EOS
apply_manifest(pp, :catch_failures => true)

# create ssh keys
shell('mkdir -p /home/testuser-ssh/.ssh')
shell('ssh-keygen -q -t rsa -f /home/testuser-ssh/.ssh/id_rsa -N ""')

# copy public key to authorized_keys
shell('cat /home/testuser-ssh/.ssh/id_rsa.pub > /home/testuser-ssh/.ssh/authorized_keys')
shell('echo -e "Host localhost\n\tStrictHostKeyChecking no\n" > /home/testuser-ssh/.ssh/config')
shell('chown -R testuser-ssh:testuser-ssh /home/testuser-ssh/.ssh')
shell("chown testuser-ssh:testuser-ssh #{tmpdir}")
end

it 'applies the manifest' do
pp = <<-EOS
vcsrepo { "#{tmpdir}/testrepo_user_ssh":
ensure => present,
provider => git,
source => "git+ssh://testuser-ssh@localhost#{tmpdir}/testrepo.git",
user => 'testuser-ssh',
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

after(:all) do
pp = <<-EOS
user { 'testuser-ssh':
ensure => absent,
managehome => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
end
end
10 changes: 9 additions & 1 deletion vcsrepo/spec/unit/puppet/provider/vcsrepo/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def branch_a_list(include_branch = nil?)
before do
expects_chdir('/tmp/test')
resource[:revision] = 'currentsha'
resource.delete(:source)
resource[:source] = 'http://example.com'
provider.stubs(:git).with('config', 'remote.origin.url').returns('')
provider.stubs(:git).with('fetch', 'origin') # FIXME
provider.stubs(:git).with('fetch', '--tags', 'origin')
Expand Down Expand Up @@ -272,6 +272,14 @@ def branch_a_list(include_branch = nil?)
end
end

context "when there's no source" do
it 'should return the revision' do
resource.delete(:source)
provider.expects(:git).with('status')
provider.expects(:git).with('rev-parse', resource.value(:revision)).returns('currentsha')
expect(provider.revision).to eq(resource.value(:revision))
end
end
end

context "setting the revision property" do
Expand Down

0 comments on commit 819a93a

Please sign in to comment.