Skip to content

Commit bc856b5

Browse files
committed
bash-completion on macos
1 parent 359ba6f commit bc856b5

File tree

2 files changed

+40
-33
lines changed

2 files changed

+40
-33
lines changed

manifests/vcsscm/git.pp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,33 @@
1111
$gitignore = false,
1212
) inherits software::params {
1313

14+
$provider = $facts['os']['name'] ? {
15+
'Darwin' => brew,
16+
/(Debian|Ubuntu)/ => undef,
17+
'windows' => chocolatey,
18+
default => fail("The ${name} class is not supported on ${facts['os']['name']}."),
19+
}
20+
21+
package { 'git':
22+
ensure => $ensure,
23+
provider => $provider,
24+
}
25+
26+
if $bash_completion and $facts['os']['name'] != 'windows' {
27+
package { 'bash-completion':
28+
ensure => $ensure,
29+
provider => $provider,
30+
}
31+
}
32+
1433
case $facts['os']['name'] {
1534
'Debian', 'Ubuntu': {
16-
package { 'git':
17-
ensure => $ensure,
18-
}
19-
2035
if $gui {
2136
package { ['gitk', 'git-gui']:
2237
ensure => $ensure,
2338
}
2439
}
2540

26-
if $bash_completion {
27-
package { 'bash-completion':
28-
ensure => $ensure,
29-
}
30-
}
31-
3241
if $bash_prompt {
3342

3443
vcsrepo { '/opt/bash-git-prompt/':
@@ -128,15 +137,7 @@
128137
}
129138
}
130139
}
131-
'windows': {
132-
package { 'git':
133-
ensure => $ensure,
134-
provider => chocolatey,
135-
}
136-
}
137-
default: {
138-
fail("The ${name} class is not supported on ${facts['os']['name']}.")
139-
}
140+
default: {}
140141
}
141142

142143
}

spec/classes/vcsscm/git_spec.rb

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
# rubocop:disable RSpec/RepeatedExample
1111
context 'with defaults' do
1212
if facts[:os]['name'] == 'Darwin'
13-
it { is_expected.to compile.and_raise_error(%r{is not supported on Darwin.}) }
13+
it { is_expected.to compile.with_all_deps }
14+
it { is_expected.to contain_package('git').with_provider('brew') }
15+
it { is_expected.not_to contain_package('bash-completion') }
1416
elsif facts[:os]['name'] == 'windows'
1517
it { is_expected.to compile.with_all_deps }
16-
it { is_expected.to contain_package('git') }
17-
else
18+
it { is_expected.to contain_package('git').with_provider('chocolatey') }
19+
it { is_expected.not_to contain_package('bash-completion') }
20+
elsif ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
1821
it { is_expected.to compile.with_all_deps }
1922
it { is_expected.to contain_package('git') }
2023
it { is_expected.not_to contain_package('gitk') }
@@ -36,7 +39,10 @@
3639
end
3740

3841
if facts[:os]['name'] == 'Darwin'
39-
it { is_expected.to compile.and_raise_error(%r{is not supported on Darwin.}) }
42+
it { is_expected.to compile.with_all_deps }
43+
it { is_expected.to contain_package('git').with_provider('brew') }
44+
it { is_expected.not_to contain_package('gitk') }
45+
it { is_expected.not_to contain_package('git-gui') }
4046
elsif ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
4147
it { is_expected.to compile.with_all_deps }
4248
it { is_expected.to contain_package('git') }
@@ -54,7 +60,13 @@
5460
end
5561

5662
if facts[:os]['name'] == 'Darwin'
57-
it { is_expected.to compile.and_raise_error(%r{is not supported on Darwin.}) }
63+
it { is_expected.to compile.with_all_deps }
64+
it { is_expected.to contain_package('git').with_provider('brew') }
65+
it { is_expected.to contain_package('bash-completion').with_provider('brew') }
66+
elsif facts[:os]['name'] == 'windows'
67+
it { is_expected.to compile.with_all_deps }
68+
it { is_expected.to contain_package('git').with_provider('chocolatey') }
69+
it { is_expected.not_to contain_package('bash-completion') }
5870
elsif ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
5971
it { is_expected.to compile.with_all_deps }
6072
it { is_expected.to contain_package('git') }
@@ -75,9 +87,7 @@
7587
}
7688
end
7789

78-
if facts[:os]['name'] == 'Darwin'
79-
it { is_expected.to compile.and_raise_error(%r{is not supported on Darwin.}) }
80-
elsif ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
90+
if ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
8191
it { is_expected.to compile.with_all_deps }
8292
it { is_expected.to contain_package('git') }
8393
it {
@@ -103,9 +113,7 @@
103113
}
104114
end
105115

106-
if facts[:os]['name'] == 'Darwin'
107-
it { is_expected.to compile.and_raise_error(%r{is not supported on Darwin.}) }
108-
elsif ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
116+
if ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
109117
it { is_expected.to compile.with_all_deps }
110118
it { is_expected.to contain_package('git') }
111119
it { is_expected.not_to contain_file('/etc/gitconfig') }
@@ -133,9 +141,7 @@
133141
}
134142
end
135143

136-
if facts[:os]['name'] == 'Darwin'
137-
it { is_expected.to compile.and_raise_error(%r{is not supported on Darwin.}) }
138-
elsif ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
144+
if ['Debian', 'Ubuntu'].include?(facts[:os]['name'])
139145
it { is_expected.to compile.with_all_deps }
140146
it { is_expected.to contain_package('git') }
141147
it {

0 commit comments

Comments
 (0)