Skip to content

Commit fcc093d

Browse files
authored
Merge pull request #727 from syseleven/allow_v-prefixed_version
pip: allow v-prefixed version string
2 parents cdcb65e + cede473 commit fcc093d

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

manifests/pip.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@
160160
# If it wasn't or if there is any error, the package manager will trigger a failure.
161161
$grep_regex = $_ensure ? {
162162
/^(present|absent|latest)$/ => "^${real_pkgname}[[:space:]].*$",
163-
/^[0-9].*$/ => "^${real_pkgname}[[:space:]]\\+(\\?${_ensure}\\()$\\|$\\|, \\|[[:space:]]\\)",
164-
default => fail('ensure can be a version number or one of: present, absent, latest')
163+
/^v?[0-9].*$/ => "^${real_pkgname}[[:space:]]\\+(\\?${_ensure}\\()$\\|$\\|, \\|[[:space:]]\\)",
164+
default => fail('ensure can be a version number (e.g. 1.7.0 or v1.7.0) or one of: present, absent, latest')
165165
}
166166

167167
$extras_string = empty($extras) ? {
@@ -195,7 +195,7 @@
195195
}
196196
} else {
197197
case $_ensure {
198-
/^[0-9].*$/: {
198+
/^v?[0-9].*$/: {
199199
# Specific version
200200
$command = "${pip_install} ${install_args} ${pip_common_args}==${_ensure}"
201201
$unless_command = "${pip_env} list | grep -i -e '${grep_regex}'"

spec/defines/pip_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@
147147
end
148148
end
149149

150+
describe 'install specific version' do
151+
context 'supports v-prefixed version string' do
152+
let(:params) { { ensure: 'v1.7.0' } }
153+
154+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install rpyc==v1.7.0') }
155+
end
156+
157+
context 'supports version string without v-prefix' do
158+
let(:params) { { ensure: '1.7.0' } }
159+
160+
it { is_expected.to contain_exec('pip_install_rpyc').with_command('pip --log /tmp/pip.log install rpyc==1.7.0') }
161+
end
162+
end
163+
150164
describe 'uninstall' do
151165
context 'adds correct title' do
152166
let(:params) { { ensure: 'absent' } }

0 commit comments

Comments
 (0)