modulesync 2.3.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 592e73854b4792850a6696971ca1a28a441bd04c195f548933cc1ec01ba6b433
4
- data.tar.gz: 8eb8d8b165bc87a633fe90feea07e713bdcf4b6ccaf3fd6ba8cce5d57053c7b7
3
+ metadata.gz: dab88d217406b70303f6514b14c56a6ec6652b962d3fa16fd967e36fdb17b0b4
4
+ data.tar.gz: 18f7c8f38c273f248f80005b2edd6fe5528138739aad2daf0ffe11f22fad40e6
5
5
  SHA512:
6
- metadata.gz: 9329c73bc685a734e5e1fe8387c4ad202a9468f502aed86cdbf32362d9e0079eb5385b2a1c3d0a155912f049945702a9e8eca6d465a79b5aa458dde735784a96
7
- data.tar.gz: 506630e05453bcb84783d326bbb81d69f4bfe653d1b80f6d5416814c9d3d1b6f2802e0c560e5c8f80a4377f82d1e0403bda1933ad658c3915590d125af1d51f0
6
+ metadata.gz: 4be95c61128a95c5cb28689f6abe256f7c164a197ef44028a58963139a474568ec82aef11adc6608b3a9681b126014ccb699ea4b82686558563e41740d6608f0
7
+ data.tar.gz: 6341644230ec2cd827180917c692cbf6e6abc3c5e8866f5c72ba415d3079517a910ebee988fe9009f693b3d2dcd91b1e50c7403071088ab234b13157b0902c0d
data/.rubocop.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
3
8
  AllCops:
4
9
  TargetRubyVersion: 2.5
5
10
  NewCops: enable
@@ -27,6 +32,9 @@ Style/TrailingCommaInArrayLiteral:
27
32
  Style/TrailingCommaInHashLiteral:
28
33
  EnforcedStyleForMultiline: comma
29
34
 
35
+ Layout/LineContinuationLeadingSpace:
36
+ Enabled: false
37
+
30
38
  # sane line length
31
39
  Layout/LineLength:
32
40
  Max: 120
data/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.5.0](https://github.com/voxpupuli/modulesync/tree/2.5.0) (2022-10-14)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/modulesync/compare/2.4.0...2.5.0)
8
+
9
+ **Implemented enhancements:**
10
+
11
+ - Copy file permissions from template to target [\#257](https://github.com/voxpupuli/modulesync/pull/257) ([ekohl](https://github.com/ekohl))
12
+
13
+ ## [2.4.0](https://github.com/voxpupuli/modulesync/tree/2.4.0) (2022-09-27)
14
+
15
+ [Full Changelog](https://github.com/voxpupuli/modulesync/compare/2.3.1...2.4.0)
16
+
17
+ **Implemented enhancements:**
18
+
19
+ - Expose namespace in metadata [\#254](https://github.com/voxpupuli/modulesync/pull/254) ([ekohl](https://github.com/ekohl))
20
+
21
+ **Merged pull requests:**
22
+
23
+ - Fix Rubocop and add additional rubocop plugins [\#255](https://github.com/voxpupuli/modulesync/pull/255) ([ekohl](https://github.com/ekohl))
24
+
5
25
  ## [2.3.1](https://github.com/voxpupuli/modulesync/tree/2.3.1) (2022-05-05)
6
26
 
7
27
  [Full Changelog](https://github.com/voxpupuli/modulesync/compare/2.3.0...2.3.1)
@@ -717,6 +717,7 @@ Feature: update
717
717
  And a file named "moduleroot/test.erb" with:
718
718
  """
719
719
  module: <%= @metadata[:module_name] %>
720
+ namespace: <%= @metadata[:namespace] %>
720
721
  target: <%= @metadata[:target_file] %>
721
722
  workdir: <%= @metadata[:workdir] %>
722
723
  """
@@ -724,6 +725,7 @@ Feature: update
724
725
  Then the file named "modules/fakenamespace/puppet-test/test" should contain:
725
726
  """
726
727
  module: puppet-test
728
+ namespace: fakenamespace
727
729
  target: modules/fakenamespace/puppet-test/test
728
730
  workdir: modules/fakenamespace/puppet-test
729
731
  """
@@ -41,7 +41,7 @@ module ModuleSync
41
41
  # - file:///path/to/repo.git/
42
42
  # - any invalid URL
43
43
  def self.extract_hostname(url)
44
- return nil if url.start_with?('/') || url.start_with?('file://') # local path (e.g. file:///path/to/repo)
44
+ return nil if url.start_with?('/', 'file://') # local path (e.g. file:///path/to/repo)
45
45
 
46
46
  unless url.start_with?(%r{[a-z]+://}) # SSH notation does not contain protocol (e.g. user@server:path/to/repo/)
47
47
  pattern = /^(?<user>.*@)?(?<hostname>[\w|.]*):(?<repo>.*)$/ # SSH path (e.g. user@server:repo)
@@ -32,7 +32,7 @@ module ModuleSync
32
32
  end
33
33
 
34
34
  def deactivate
35
- File.delete(hook_file) if File.exist?(hook_file)
35
+ FileUtils.rm_f(hook_file)
36
36
  end
37
37
  end
38
38
  end
@@ -10,13 +10,7 @@ module ModuleSync
10
10
  end
11
11
  end
12
12
 
13
- def self.build(target_name)
14
- template_file = if !File.exist?("#{target_name}.erb") && File.exist?(target_name)
15
- $stderr.puts "Warning: using '#{target_name}' as template without '.erb' suffix"
16
- target_name
17
- else
18
- "#{target_name}.erb"
19
- end
13
+ def self.build(template_file)
20
14
  template = File.read(template_file)
21
15
  erb_obj = if RUBY_VERSION >= '2.7'
22
16
  ERB.new(template, trim_mode: '-')
@@ -29,16 +23,17 @@ module ModuleSync
29
23
  end
30
24
 
31
25
  def self.remove(file)
32
- File.delete(file) if File.exist?(file)
26
+ FileUtils.rm_f(file)
33
27
  end
34
28
 
35
29
  def self.render(_template, configs = {}, metadata = {})
36
30
  ForgeModuleFile.new(configs, metadata).render
37
31
  end
38
32
 
39
- def self.sync(template, target_name)
33
+ def self.sync(template, target_name, mode = nil)
40
34
  FileUtils.mkdir_p(File.dirname(target_name))
41
35
  File.write(target_name, template)
36
+ File.chmod(mode, target_name) unless mode.nil?
42
37
  end
43
38
  end
44
39
  end
@@ -31,7 +31,7 @@ module ModuleSync
31
31
  end
32
32
 
33
33
  def default_branch
34
- symbolic_ref = repo.branches.find { |b| b.full =~ %r{remotes/origin/HEAD} }
34
+ symbolic_ref = repo.branches.find { |b| b.full.include?('remotes/origin/HEAD') }
35
35
  return unless symbolic_ref
36
36
 
37
37
  %r{remotes/origin/HEAD\s+->\s+origin/(?<branch>.+?)$}.match(symbolic_ref.full)[:branch]
data/lib/modulesync.rb CHANGED
@@ -31,7 +31,13 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
31
31
  end
32
32
 
33
33
  def self.local_file(config_path, file)
34
- File.join(config_path, MODULE_FILES_DIR, file)
34
+ path = File.join(config_path, MODULE_FILES_DIR, file)
35
+ if !File.exist?("#{path}.erb") && File.exist?(path)
36
+ $stderr.puts "Warning: using '#{path}' as template without '.erb' suffix"
37
+ path
38
+ else
39
+ "#{path}.erb"
40
+ end
35
41
  end
36
42
 
37
43
  # List all template files.
@@ -83,23 +89,24 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
83
89
  end
84
90
 
85
91
  def self.manage_file(puppet_module, filename, settings, options)
86
- module_name = settings.additional_settings[:puppet_module]
87
92
  configs = settings.build_file_configs(filename)
88
93
  target_file = puppet_module.path(filename)
89
94
  if configs['delete']
90
95
  Renderer.remove(target_file)
91
96
  else
92
- templatename = local_file(options[:configs], filename)
97
+ template_file = local_file(options[:configs], filename)
93
98
  begin
94
- erb = Renderer.build(templatename)
99
+ erb = Renderer.build(template_file)
95
100
  # Meta data passed to the template as @metadata[:name]
96
101
  metadata = {
97
- :module_name => module_name,
102
+ :module_name => settings.additional_settings[:puppet_module],
103
+ :namespace => settings.additional_settings[:namespace],
98
104
  :workdir => puppet_module.working_directory,
99
105
  :target_file => target_file,
100
106
  }
101
107
  template = Renderer.render(erb, configs, metadata)
102
- Renderer.sync(template, target_file)
108
+ mode = File.stat(template_file).mode
109
+ Renderer.sync(template, target_file, mode)
103
110
  rescue StandardError
104
111
  $stderr.puts "#{puppet_module.given_name}: Error while rendering file: '#{filename}'"
105
112
  raise
@@ -214,9 +221,7 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
214
221
  message = "Command execution failed ('#{@options[:command_args].join ' '}': #{$CHILD_STATUS})"
215
222
  raise Thor::Error, message if @options[:fail_fast]
216
223
 
217
- errors.merge!(
218
- puppet_module.given_name => message,
219
- )
224
+ errors[puppet_module.given_name] = message
220
225
  $stderr.puts message
221
226
  end
222
227
 
data/modulesync.gemspec CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'modulesync'
6
- spec.version = '2.3.1'
6
+ spec.version = '2.5.0'
7
7
  spec.authors = ['Vox Pupuli']
8
8
  spec.email = ['voxpupuli@groups.io']
9
9
  spec.summary = 'Puppet Module Synchronizer'
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
17
  spec.require_paths = ['lib']
19
18
 
20
19
  spec.add_development_dependency 'aruba', '>= 0.14', '< 2'
@@ -23,6 +22,7 @@ Gem::Specification.new do |spec|
23
22
  spec.add_development_dependency 'rake'
24
23
  spec.add_development_dependency 'rspec'
25
24
  spec.add_development_dependency 'rubocop', '~> 1.2'
25
+ spec.add_development_dependency 'rubocop-performance'
26
26
  spec.add_development_dependency 'rubocop-rake'
27
27
  spec.add_development_dependency 'rubocop-rspec'
28
28
  spec.add_development_dependency 'simplecov'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-05 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.2'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-performance
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: rubocop-rake
105
119
  requirement: !ruby/object:Gem::Requirement
@@ -305,26 +319,4 @@ rubygems_version: 3.3.7
305
319
  signing_key:
306
320
  specification_version: 4
307
321
  summary: Puppet Module Synchronizer
308
- test_files:
309
- - features/cli.feature
310
- - features/execute.feature
311
- - features/hook.feature
312
- - features/push.feature
313
- - features/reset.feature
314
- - features/step_definitions/git_steps.rb
315
- - features/support/env.rb
316
- - features/update.feature
317
- - features/update/bad_context.feature
318
- - features/update/bump_version.feature
319
- - features/update/dot_sync.feature
320
- - features/update/pull_request.feature
321
- - spec/helpers/faker.rb
322
- - spec/helpers/faker/puppet_module_remote_repo.rb
323
- - spec/spec_helper.rb
324
- - spec/unit/modulesync/git_service/factory_spec.rb
325
- - spec/unit/modulesync/git_service/github_spec.rb
326
- - spec/unit/modulesync/git_service/gitlab_spec.rb
327
- - spec/unit/modulesync/git_service_spec.rb
328
- - spec/unit/modulesync/settings_spec.rb
329
- - spec/unit/modulesync/source_code_spec.rb
330
- - spec/unit/modulesync_spec.rb
322
+ test_files: []