[DRE-commits] [librarian-puppet] 63/153: Issue #261 Incorrect install directory is created if the organization name contains a dash
Stig Sandbeck Mathisen
ssm at debian.org
Wed Jun 1 20:30:43 UTC 2016
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository librarian-puppet.
commit 4838707f10153edddc89dc4a6dd22d5794f73ef5
Author: Carlos Sanchez <csanchez at maestrodev.com>
Date: Fri Oct 10 09:24:45 2014 +0200
Issue #261 Incorrect install directory is created if the organization name contains a dash
Assume organization can contain dashes, but not the module name
---
Changelog.md | 2 ++
lib/librarian/puppet/source/forge.rb | 2 +-
lib/librarian/puppet/source/forge/repo.rb | 2 +-
lib/librarian/puppet/source/githubtarball.rb | 2 +-
lib/librarian/puppet/source/local.rb | 2 +-
lib/librarian/puppet/util.rb | 10 +++++++---
spec/util_spec.rb | 14 ++++++++++++++
7 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/Changelog.md b/Changelog.md
index 3fe7c8a..9213d6f 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -6,11 +6,13 @@
* Jump from 1.3.x to 2.x to leave 1.x for Ruby 1.8 compatibility
* [Issue #254](https://github.com/rodjek/librarian-puppet/issues/254) Add a rsync option to prevent deleting directories
+ * [Issue #261](https://github.com/rodjek/librarian-puppet/issues/261) Incorrect install directory is created if the organization name contains a dash
### 1.4.0
* Jump from 1.0.x to 1.4.x to keep Ruby 1.8 compatibility in the 1.x series
* [Issue #254](https://github.com/rodjek/librarian-puppet/issues/254) Add a rsync option to prevent deleting directories
+ * [Issue #261](https://github.com/rodjek/librarian-puppet/issues/261) Incorrect install directory is created if the organization name contains a dash
### 1.3.3
diff --git a/lib/librarian/puppet/source/forge.rb b/lib/librarian/puppet/source/forge.rb
index 008aeac..898c129 100644
--- a/lib/librarian/puppet/source/forge.rb
+++ b/lib/librarian/puppet/source/forge.rb
@@ -121,7 +121,7 @@ module Librarian
end
def install_path(name)
- environment.install_path.join(organization_name(name))
+ environment.install_path.join(module_name(name))
end
def fetch_version(name, version_uri)
diff --git a/lib/librarian/puppet/source/forge/repo.rb b/lib/librarian/puppet/source/forge/repo.rb
index c16a878..00ba102 100644
--- a/lib/librarian/puppet/source/forge/repo.rb
+++ b/lib/librarian/puppet/source/forge/repo.rb
@@ -59,7 +59,7 @@ module Librarian
install_path.rmtree
end
- unpacked_path = version_unpacked_cache_path(version).join(organization_name(name))
+ unpacked_path = version_unpacked_cache_path(version).join(module_name(name))
unless unpacked_path.exist?
raise Error, "#{unpacked_path} does not exist, something went wrong. Try removing it manually"
diff --git a/lib/librarian/puppet/source/githubtarball.rb b/lib/librarian/puppet/source/githubtarball.rb
index 2a636eb..090c97e 100644
--- a/lib/librarian/puppet/source/githubtarball.rb
+++ b/lib/librarian/puppet/source/githubtarball.rb
@@ -98,7 +98,7 @@ module Librarian
end
def install_path(name)
- environment.install_path.join(organization_name(name))
+ environment.install_path.join(module_name(name))
end
def fetch_version(name, version_uri)
diff --git a/lib/librarian/puppet/source/local.rb b/lib/librarian/puppet/source/local.rb
index 52e411c..eda14be 100644
--- a/lib/librarian/puppet/source/local.rb
+++ b/lib/librarian/puppet/source/local.rb
@@ -19,7 +19,7 @@ module Librarian
warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" }
end
- install_path = environment.install_path.join(organization_name(name))
+ install_path = environment.install_path.join(module_name(name))
if install_path.exist? && rsync? != true
debug { "Deleting #{relative_path_to(install_path)}" }
install_path.rmtree
diff --git a/lib/librarian/puppet/util.rb b/lib/librarian/puppet/util.rb
index 7031d58..851bc81 100644
--- a/lib/librarian/puppet/util.rb
+++ b/lib/librarian/puppet/util.rb
@@ -51,10 +51,14 @@ module Librarian
name.sub('/','-')
end
- # get the organization name from organization-module
- def organization_name(name)
- name.split('-',2).last
+ # get the module name from organization-module
+ def module_name(name)
+ # module name can't have dashes, so let's assume it is everything after the last dash
+ name.rpartition('-').last
end
+
+ # deprecated
+ alias :organization_name :module_name
end
end
end
diff --git a/spec/util_spec.rb b/spec/util_spec.rb
new file mode 100644
index 0000000..eefe7d2
--- /dev/null
+++ b/spec/util_spec.rb
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe Librarian::Puppet::Util do
+
+ subject { Class.new { include Librarian::Puppet::Util }.new }
+
+ it 'should get organization name' do
+ expect(subject.module_name('puppetlabs-xy')).to eq('xy')
+ end
+
+ it 'should get organization name when org contains dashes' do
+ expect(subject.module_name('puppet-labs-xy')).to eq('xy')
+ end
+end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/librarian-puppet.git
More information about the Pkg-ruby-extras-commits
mailing list