modulesync 0.10.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +0 -5
- data/CHANGELOG.md +9 -0
- data/features/step_definitions/git_steps.rb +1 -1
- data/features/update.feature +46 -27
- data/lib/modulesync.rb +37 -27
- data/lib/modulesync/cli.rb +12 -6
- data/lib/modulesync/git.rb +2 -1
- data/lib/modulesync/settings.rb +1 -2
- data/modulesync.gemspec +1 -1
- data/spec/unit/modulesync_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16cd854b2ba5a64f73b1051081fbf1e3bdbe39bbec2b7dacf5de3a3f37750625
|
4
|
+
data.tar.gz: d45c398dd5e7fc20d4bbf257ca0303bda0faa91ea49d3b6804d34fdbb25e1175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38ae3613c9b28a0d679445350dcf6d625ad0db7156db8e26df7b4a4703a79713b471ce786d20d879a4bcdf8cd23830ac8277f259435f6fb191eede8a5a49ac9f
|
7
|
+
data.tar.gz: 62cacbdc9b002371957bc732727774c79d3b5783280469e3a2a34379265b784a8b6c0a6bccf1ce47ceb4bccea27cdb0273933b86381a37d57fd39e011b382d49
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -25,11 +25,6 @@ Metrics/ClassLength:
|
|
25
25
|
Metrics/CyclomaticComplexity:
|
26
26
|
Max: 13
|
27
27
|
|
28
|
-
# Offense count: 29
|
29
|
-
# Configuration parameters: AllowURI, URISchemes.
|
30
|
-
Metrics/LineLength:
|
31
|
-
Max: 319
|
32
|
-
|
33
28
|
# Offense count: 8
|
34
29
|
# Configuration parameters: CountComments.
|
35
30
|
Metrics/MethodLength:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2019-09-19 - 1.0.0
|
4
|
+
|
5
|
+
This is the first stable release! 🎉
|
6
|
+
|
7
|
+
* Use namespace in directory structure when cloning repositories - [#152](https://github.com/voxpupuli/modulesync/pull/152)
|
8
|
+
* Fix minor typo in help output - [#165](https://github.com/voxpupuli/modulesync/pull/165)
|
9
|
+
* Small improvements and fixes - [#166](https://github.com/voxpupuli/modulesync/pull/166)
|
10
|
+
* Fix overwriting of :global values - [#169](https://github.com/voxpupuli/modulesync/pull/169)
|
11
|
+
|
3
12
|
## 2018-12-27 - 0.10.0
|
4
13
|
|
5
14
|
This is another awesome release!
|
@@ -23,7 +23,7 @@ Given 'a remote module repository' do
|
|
23
23
|
CONFIG
|
24
24
|
end
|
25
25
|
|
26
|
-
Given /a remote module repository with "(.+?)" as the default branch/ do |branch|
|
26
|
+
Given Regexp.new(/a remote module repository with "(.+?)" as the default branch/) do |branch|
|
27
27
|
steps %(
|
28
28
|
Given a directory named "sources"
|
29
29
|
And I run `git clone --mirror https://github.com/maestrodev/puppet-test sources/puppet-test`
|
data/features/update.feature
CHANGED
@@ -31,7 +31,7 @@ Feature: update
|
|
31
31
|
Files added:
|
32
32
|
test
|
33
33
|
"""
|
34
|
-
Given I run `cat modules/puppet-test/test`
|
34
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
35
35
|
Then the output should contain "aruba"
|
36
36
|
|
37
37
|
Scenario: Using skip_broken option and adding a new file to repo without write access
|
@@ -113,14 +113,14 @@ Feature: update
|
|
113
113
|
Then the exit status should be 0
|
114
114
|
And the output should match:
|
115
115
|
"""
|
116
|
-
Warning: using './moduleroot
|
116
|
+
Warning: using './moduleroot/test' as template without '.erb' suffix
|
117
117
|
"""
|
118
118
|
And the output should match:
|
119
119
|
"""
|
120
120
|
Files added:
|
121
121
|
test
|
122
122
|
"""
|
123
|
-
Given I run `cat modules/puppet-test/test`
|
123
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
124
124
|
Then the output should contain "aruba"
|
125
125
|
|
126
126
|
Scenario: Adding a new file using global values
|
@@ -153,7 +153,7 @@ Feature: update
|
|
153
153
|
Files added:
|
154
154
|
test
|
155
155
|
"""
|
156
|
-
Given I run `cat modules/puppet-test/test`
|
156
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
157
157
|
Then the output should contain "aruba"
|
158
158
|
|
159
159
|
Scenario: Adding a new file overriding global values
|
@@ -189,7 +189,7 @@ Feature: update
|
|
189
189
|
Files added:
|
190
190
|
test
|
191
191
|
"""
|
192
|
-
Given I run `cat modules/puppet-test/test`
|
192
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
193
193
|
Then the output should contain "aruba"
|
194
194
|
|
195
195
|
Scenario: Adding a new file ignoring global values
|
@@ -225,7 +225,7 @@ Feature: update
|
|
225
225
|
Files added:
|
226
226
|
test
|
227
227
|
"""
|
228
|
-
Given I run `cat modules/puppet-test/test`
|
228
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
229
229
|
Then the output should contain "aruba"
|
230
230
|
|
231
231
|
Scenario: Adding a file that ERB can't parse
|
@@ -342,7 +342,7 @@ Feature: update
|
|
342
342
|
Files changed:
|
343
343
|
+diff --git a/Gemfile b/Gemfile
|
344
344
|
"""
|
345
|
-
Given I run `cat modules/puppet-test/Gemfile`
|
345
|
+
Given I run `cat modules/maestrodev/puppet-test/Gemfile`
|
346
346
|
Then the output should contain:
|
347
347
|
"""
|
348
348
|
source 'https://somehost.com'
|
@@ -405,7 +405,7 @@ Feature: update
|
|
405
405
|
Not managing Gemfile in puppet-test
|
406
406
|
"""
|
407
407
|
And the exit status should be 0
|
408
|
-
Given I run `cat modules/puppet-test/Gemfile`
|
408
|
+
Given I run `cat modules/maestrodev/puppet-test/Gemfile`
|
409
409
|
Then the output should contain:
|
410
410
|
"""
|
411
411
|
source 'https://rubygems.org'
|
@@ -488,8 +488,8 @@ Feature: update
|
|
488
488
|
"""
|
489
489
|
some spec_helper fud
|
490
490
|
"""
|
491
|
-
And a directory named "modules/puppetlabs-apache/spec"
|
492
|
-
And a file named "modules/puppetlabs-apache/spec/spec_helper.rb" with:
|
491
|
+
And a directory named "modules/puppetlabs/puppetlabs-apache/spec"
|
492
|
+
And a file named "modules/puppetlabs/puppetlabs-apache/spec/spec_helper.rb" with:
|
493
493
|
"""
|
494
494
|
This is a fake spec_helper!
|
495
495
|
"""
|
@@ -499,7 +499,7 @@ Feature: update
|
|
499
499
|
Not managing spec/spec_helper.rb in puppetlabs-apache
|
500
500
|
"""
|
501
501
|
And the exit status should be 0
|
502
|
-
Given I run `cat modules/puppetlabs-apache/spec/spec_helper.rb`
|
502
|
+
Given I run `cat modules/puppetlabs/puppetlabs-apache/spec/spec_helper.rb`
|
503
503
|
Then the output should contain:
|
504
504
|
"""
|
505
505
|
This is a fake spec_helper!
|
@@ -538,7 +538,7 @@ Feature: update
|
|
538
538
|
Files added:
|
539
539
|
spec/spec_helper.rb
|
540
540
|
"""
|
541
|
-
Given I run `cat modules/puppet-test/spec/spec_helper.rb`
|
541
|
+
Given I run `cat modules/maestrodev/puppet-test/spec/spec_helper.rb`
|
542
542
|
Then the output should contain:
|
543
543
|
"""
|
544
544
|
require 'puppetlabs_spec_helper/module_helper'
|
@@ -577,7 +577,7 @@ Feature: update
|
|
577
577
|
Given a file named "managed_modules.yml" with:
|
578
578
|
"""
|
579
579
|
---
|
580
|
-
- puppet-test
|
580
|
+
- maestrodev/puppet-test
|
581
581
|
"""
|
582
582
|
And a file named "modulesync.yml" with:
|
583
583
|
"""
|
@@ -597,8 +597,8 @@ Feature: update
|
|
597
597
|
require '<%= required %>'
|
598
598
|
<% end %>
|
599
599
|
"""
|
600
|
-
Given I run `git init modules/puppet-test`
|
601
|
-
Given a file named "modules/puppet-test/.git/config" with:
|
600
|
+
Given I run `git init modules/maestrodev/puppet-test`
|
601
|
+
Given a file named "modules/maestrodev/puppet-test/.git/config" with:
|
602
602
|
"""
|
603
603
|
[core]
|
604
604
|
repositoryformatversion = 0
|
@@ -667,7 +667,7 @@ Feature: update
|
|
667
667
|
Files added:
|
668
668
|
test
|
669
669
|
"""
|
670
|
-
Given I run `cat modules/puppet-test/test`
|
670
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
671
671
|
Then the output should contain "aruba"
|
672
672
|
|
673
673
|
Scenario: When specifying configurations in managed_modules.yml and using a filter
|
@@ -702,9 +702,9 @@ Feature: update
|
|
702
702
|
Files added:
|
703
703
|
test
|
704
704
|
"""
|
705
|
-
Given I run `cat modules/puppet-test/test`
|
705
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
706
706
|
Then the output should contain "aruba"
|
707
|
-
And a directory named "modules/puppet-blacksmith" should not exist
|
707
|
+
And a directory named "modules/maestrodev/puppet-blacksmith" should not exist
|
708
708
|
|
709
709
|
Scenario: When specifying configurations in managed_modules.yml and using a negative filter
|
710
710
|
Given a file named "managed_modules.yml" with:
|
@@ -738,15 +738,15 @@ Feature: update
|
|
738
738
|
Files added:
|
739
739
|
test
|
740
740
|
"""
|
741
|
-
Given I run `cat modules/puppet-test/test`
|
741
|
+
Given I run `cat modules/maestrodev/puppet-test/test`
|
742
742
|
Then the output should contain "aruba"
|
743
|
-
And a directory named "modules/puppet-blacksmith" should not exist
|
743
|
+
And a directory named "modules/maestrodev/puppet-blacksmith" should not exist
|
744
744
|
|
745
745
|
Scenario: Updating a module with a .sync.yml file
|
746
746
|
Given a file named "managed_modules.yml" with:
|
747
747
|
"""
|
748
748
|
---
|
749
|
-
- puppet-test
|
749
|
+
- maestrodev/puppet-test
|
750
750
|
"""
|
751
751
|
And a file named "modulesync.yml" with:
|
752
752
|
"""
|
@@ -756,6 +756,9 @@ Feature: update
|
|
756
756
|
And a file named "config_defaults.yml" with:
|
757
757
|
"""
|
758
758
|
---
|
759
|
+
:global:
|
760
|
+
global-default: some-default
|
761
|
+
global-to-overwrite: to-be-overwritten
|
759
762
|
spec/spec_helper.rb:
|
760
763
|
require:
|
761
764
|
- puppetlabs_spec_helper/module_helper
|
@@ -766,8 +769,14 @@ Feature: update
|
|
766
769
|
require '<%= required %>'
|
767
770
|
<% end %>
|
768
771
|
"""
|
769
|
-
|
770
|
-
|
772
|
+
And a file named "moduleroot/global-test.md.erb" with:
|
773
|
+
"""
|
774
|
+
<%= @configs['global-default'] %>
|
775
|
+
<%= @configs['global-to-overwrite'] %>
|
776
|
+
<%= @configs['module-default'] %>
|
777
|
+
"""
|
778
|
+
Given I run `git init modules/maestrodev/puppet-test`
|
779
|
+
Given a file named "modules/maestrodev/puppet-test/.git/config" with:
|
771
780
|
"""
|
772
781
|
[core]
|
773
782
|
repositoryformatversion = 0
|
@@ -780,9 +789,12 @@ Feature: update
|
|
780
789
|
url = https://github.com/maestrodev/puppet-test.git
|
781
790
|
fetch = +refs/heads/*:refs/remotes/origin/*
|
782
791
|
"""
|
783
|
-
Given a file named "modules/puppet-test/.sync.yml" with:
|
792
|
+
Given a file named "modules/maestrodev/puppet-test/.sync.yml" with:
|
784
793
|
"""
|
785
794
|
---
|
795
|
+
:global:
|
796
|
+
global-to-overwrite: it-is-overwritten
|
797
|
+
module-default: some-value
|
786
798
|
spec/spec_helper.rb:
|
787
799
|
unmanaged: true
|
788
800
|
"""
|
@@ -792,6 +804,13 @@ Feature: update
|
|
792
804
|
"""
|
793
805
|
Not managing spec/spec_helper.rb in puppet-test
|
794
806
|
"""
|
807
|
+
Given I run `cat modules/maestrodev/puppet-test/global-test.md`
|
808
|
+
Then the output should match:
|
809
|
+
"""
|
810
|
+
some-default
|
811
|
+
it-is-overwritten
|
812
|
+
some-value
|
813
|
+
"""
|
795
814
|
|
796
815
|
Scenario: Module with custom namespace
|
797
816
|
Given a file named "managed_modules.yml" with:
|
@@ -824,9 +843,9 @@ Feature: update
|
|
824
843
|
Files added:
|
825
844
|
test
|
826
845
|
"""
|
827
|
-
Given I run `cat modules/puppet-test/.git/config`
|
846
|
+
Given I run `cat modules/maestrodev/puppet-test/.git/config`
|
828
847
|
Then the output should contain "url = https://github.com/maestrodev/puppet-test.git"
|
829
|
-
Given I run `cat modules/puppet-lib-file_concat/.git/config`
|
848
|
+
Given I run `cat modules/electrical/puppet-lib-file_concat/.git/config`
|
830
849
|
Then the output should contain "url = https://github.com/electrical/puppet-lib-file_concat.git"
|
831
850
|
|
832
851
|
Scenario: Modifying an existing file with values exposed by the module
|
@@ -858,7 +877,7 @@ Feature: update
|
|
858
877
|
Files changed:
|
859
878
|
+diff --git a/README.md b/README.md
|
860
879
|
"""
|
861
|
-
Given I run `cat modules/puppet-test/README.md`
|
880
|
+
Given I run `cat modules/maestrodev/puppet-test/README.md`
|
862
881
|
Then the output should contain:
|
863
882
|
"""
|
864
883
|
echo 'https://github.com/maestrodev'
|
data/lib/modulesync.rb
CHANGED
@@ -29,31 +29,39 @@ module ModuleSync
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.local_file(config_path, file)
|
32
|
-
|
32
|
+
File.join(config_path, MODULE_FILES_DIR, file)
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.module_file(project_root, puppet_module, file)
|
36
|
-
|
35
|
+
def self.module_file(project_root, namespace, puppet_module, file)
|
36
|
+
File.join(project_root, namespace, puppet_module, file)
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
# List all template files.
|
40
|
+
#
|
41
|
+
# Only select *.erb files, and strip the extension. This way all the code will only have to handle bare paths,
|
42
|
+
# except when reading the actual ERB text
|
43
|
+
def self.find_template_files(local_template_dir)
|
44
|
+
if File.exist?(local_template_dir)
|
45
|
+
Find.find(local_template_dir).find_all { |p| p =~ /.erb$/ && !File.directory?(p) }
|
46
|
+
.collect { |p| p.chomp('.erb') }
|
47
|
+
.to_a
|
43
48
|
else
|
44
|
-
puts "#{
|
49
|
+
puts "#{local_template_dir} does not exist." \
|
50
|
+
' Check that you are working in your module configs directory or' \
|
51
|
+
' that you have passed in the correct directory with -c.'
|
45
52
|
exit
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
49
|
-
def self.
|
50
|
-
|
56
|
+
def self.relative_names(file_list, path)
|
57
|
+
file_list.map { |file| file.sub(/#{path}/, '') }
|
51
58
|
end
|
52
59
|
|
53
60
|
def self.managed_modules(config_file, filter, negative_filter)
|
54
61
|
managed_modules = Util.parse_config(config_file)
|
55
62
|
if managed_modules.empty?
|
56
|
-
puts "No modules found in #{config_file}.
|
63
|
+
puts "No modules found in #{config_file}." \
|
64
|
+
' Check that you specified the right :configs directory and :managed_modules_conf file.'
|
57
65
|
exit
|
58
66
|
end
|
59
67
|
managed_modules.select! { |m| m =~ Regexp.new(filter) } unless filter.nil?
|
@@ -78,16 +86,17 @@ module ModuleSync
|
|
78
86
|
end
|
79
87
|
|
80
88
|
def self.manage_file(filename, settings, options)
|
89
|
+
namespace = settings.additional_settings[:namespace]
|
81
90
|
module_name = settings.additional_settings[:puppet_module]
|
82
91
|
configs = settings.build_file_configs(filename)
|
83
92
|
if configs['delete']
|
84
|
-
Renderer.remove(module_file(options[:project_root], module_name, filename))
|
93
|
+
Renderer.remove(module_file(options[:project_root], namespace, module_name, filename))
|
85
94
|
else
|
86
95
|
templatename = local_file(options[:configs], filename)
|
87
96
|
begin
|
88
97
|
erb = Renderer.build(templatename)
|
89
98
|
template = Renderer.render(erb, configs)
|
90
|
-
Renderer.sync(template, module_file(options[:project_root], module_name, filename))
|
99
|
+
Renderer.sync(template, module_file(options[:project_root], namespace, module_name, filename))
|
91
100
|
rescue # rubocop:disable Lint/RescueWithoutErrorClass
|
92
101
|
STDERR.puts "Error while rendering #{filename}"
|
93
102
|
raise
|
@@ -101,20 +110,19 @@ module ModuleSync
|
|
101
110
|
raise unless options[:skip_broken]
|
102
111
|
end
|
103
112
|
|
104
|
-
puts "Syncing #{puppet_module}"
|
105
113
|
namespace, module_name = module_name(puppet_module, options[:namespace])
|
114
|
+
git_repo = File.join(namespace, module_name)
|
106
115
|
unless options[:offline]
|
107
|
-
git_base
|
108
|
-
git_uri = "#{git_base}#{namespace}"
|
109
|
-
Git.pull(git_uri, module_name, options[:branch], options[:project_root], module_options || {})
|
116
|
+
Git.pull(options[:git_base], git_repo, options[:branch], options[:project_root], module_options || {})
|
110
117
|
end
|
111
|
-
|
118
|
+
|
119
|
+
module_configs = Util.parse_config(module_file(options[:project_root], namespace, module_name, MODULE_CONF_FILE))
|
112
120
|
settings = Settings.new(defaults[GLOBAL_DEFAULTS_KEY] || {},
|
113
121
|
defaults,
|
114
122
|
module_configs[GLOBAL_DEFAULTS_KEY] || {},
|
115
123
|
module_configs,
|
116
124
|
:puppet_module => module_name,
|
117
|
-
:git_base => git_base,
|
125
|
+
:git_base => options[:git_base],
|
118
126
|
:namespace => namespace)
|
119
127
|
settings.unmanaged_files(module_files).each do |filename|
|
120
128
|
puts "Not managing #{filename} in #{module_name}"
|
@@ -124,14 +132,14 @@ module ModuleSync
|
|
124
132
|
files_to_manage.each { |filename| manage_file(filename, settings, options) }
|
125
133
|
|
126
134
|
if options[:noop]
|
127
|
-
Git.update_noop(
|
135
|
+
Git.update_noop(git_repo, options)
|
128
136
|
elsif !options[:offline]
|
129
137
|
# Git.update() returns a boolean: true if files were pushed, false if not.
|
130
|
-
pushed = Git.update(
|
138
|
+
pushed = Git.update(git_repo, files_to_manage, options)
|
131
139
|
return nil unless pushed && options[:pr]
|
132
140
|
|
133
141
|
# We only do GitHub PR work if the GITHUB_TOKEN variable is set in the environment.
|
134
|
-
repo_path =
|
142
|
+
repo_path = File.join(namespace, module_name)
|
135
143
|
puts "Submitting PR '#{options[:pr_title]}' on GitHub to #{repo_path} - merges #{options[:branch]} into master"
|
136
144
|
github = Octokit::Client.new(:access_token => GITHUB_TOKEN)
|
137
145
|
pr = github.create_pull_request(repo_path, 'master', options[:branch], options[:pr_title], options[:message])
|
@@ -152,13 +160,15 @@ module ModuleSync
|
|
152
160
|
|
153
161
|
def self.update(options)
|
154
162
|
options = config_defaults.merge(options)
|
155
|
-
defaults = Util.parse_config(
|
163
|
+
defaults = Util.parse_config(File.join(options[:configs], CONF_FILE))
|
156
164
|
|
157
|
-
|
158
|
-
local_files =
|
159
|
-
module_files =
|
165
|
+
local_template_dir = File.join(options[:configs], MODULE_FILES_DIR)
|
166
|
+
local_files = find_template_files(local_template_dir)
|
167
|
+
module_files = relative_names(local_files, local_template_dir)
|
160
168
|
|
161
|
-
managed_modules = self.managed_modules(
|
169
|
+
managed_modules = self.managed_modules(File.join(options[:configs], options[:managed_modules_conf]),
|
170
|
+
options[:filter],
|
171
|
+
options[:negative_filter])
|
162
172
|
|
163
173
|
errors = false
|
164
174
|
# managed_modules is either an array or a hash
|
data/lib/modulesync/cli.rb
CHANGED
@@ -43,7 +43,8 @@ module ModuleSync
|
|
43
43
|
:default => CLI.defaults[:git_base] || 'git@github.com:'
|
44
44
|
class_option :namespace,
|
45
45
|
:aliases => '-n',
|
46
|
-
:desc => 'Remote github namespace (user or organization) to clone from and push to.
|
46
|
+
:desc => 'Remote github namespace (user or organization) to clone from and push to.' \
|
47
|
+
' Defaults to puppetlabs',
|
47
48
|
:default => CLI.defaults[:namespace] || 'puppetlabs'
|
48
49
|
class_option :filter,
|
49
50
|
:aliases => '-f',
|
@@ -53,7 +54,8 @@ module ModuleSync
|
|
53
54
|
:desc => 'A regular expression to skip repositories.'
|
54
55
|
class_option :branch,
|
55
56
|
:aliases => '-b',
|
56
|
-
:desc => 'Branch name to make the changes in.
|
57
|
+
:desc => 'Branch name to make the changes in.' \
|
58
|
+
' Defaults to the default branch of the upstream repository, but falls back to "master".',
|
57
59
|
:default => CLI.defaults[:branch]
|
58
60
|
|
59
61
|
desc 'update', 'Update the modules in managed_modules.yml'
|
@@ -63,7 +65,8 @@ module ModuleSync
|
|
63
65
|
:default => CLI.defaults[:message]
|
64
66
|
option :configs,
|
65
67
|
:aliases => '-c',
|
66
|
-
:desc => 'The local directory or remote repository to define the list of managed modules,
|
68
|
+
:desc => 'The local directory or remote repository to define the list of managed modules,' \
|
69
|
+
' the file templates, and the default values for template variables.'
|
67
70
|
option :remote_branch,
|
68
71
|
:aliases => '-r',
|
69
72
|
:desc => 'Remote branch name to push the changes to. Defaults to the branch name.',
|
@@ -114,18 +117,21 @@ module ModuleSync
|
|
114
117
|
option :tag_pattern,
|
115
118
|
:desc => 'The pattern to use when tagging releases.'
|
116
119
|
option :pre_commit_script,
|
117
|
-
:desc => 'A script to be run before
|
120
|
+
:desc => 'A script to be run before committing',
|
118
121
|
:default => CLI.defaults[:pre_commit_script]
|
119
122
|
option :fail_on_warnings,
|
120
123
|
:type => :boolean,
|
121
124
|
:aliases => '-F',
|
122
|
-
:desc => 'Produce a failure exit code when there are warnings
|
125
|
+
:desc => 'Produce a failure exit code when there are warnings' \
|
126
|
+
' (only has effect when --skip_broken is enabled)',
|
123
127
|
:default => false
|
124
128
|
|
125
129
|
def update
|
126
130
|
config = { :command => 'update' }.merge(options)
|
127
131
|
config = Util.symbolize_keys(config)
|
128
|
-
raise Thor::Error, 'No value provided for required option "--message"' unless config[:noop]
|
132
|
+
raise Thor::Error, 'No value provided for required option "--message"' unless config[:noop] \
|
133
|
+
|| config[:message] \
|
134
|
+
|| config[:offline]
|
129
135
|
config[:git_opts] = { 'amend' => config[:amend], 'force' => config[:force] }
|
130
136
|
ModuleSync.update(config)
|
131
137
|
end
|
data/lib/modulesync/git.rb
CHANGED
@@ -46,12 +46,13 @@ module ModuleSync
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def self.pull(git_base, name, branch, project_root, opts)
|
49
|
+
puts "Syncing #{name}"
|
49
50
|
Dir.mkdir(project_root) unless Dir.exist?(project_root)
|
50
51
|
|
51
52
|
# Repo needs to be cloned in the cwd
|
52
53
|
if !Dir.exist?("#{project_root}/#{name}") || !Dir.exist?("#{project_root}/#{name}/.git")
|
53
54
|
puts 'Cloning repository fresh'
|
54
|
-
remote = opts[:remote] || (git_base.start_with?('file://') ? "#{git_base}
|
55
|
+
remote = opts[:remote] || (git_base.start_with?('file://') ? "#{git_base}#{name}" : "#{git_base}#{name}.git")
|
55
56
|
local = "#{project_root}/#{name}"
|
56
57
|
puts "Cloning from #{remote}"
|
57
58
|
repo = ::Git.clone(remote, local)
|
data/lib/modulesync/settings.rb
CHANGED
@@ -19,10 +19,9 @@ module ModuleSync
|
|
19
19
|
|
20
20
|
def build_file_configs(target_name)
|
21
21
|
file_def = lookup_config(defaults, target_name)
|
22
|
-
file_md = lookup_config(module_defaults, target_name)
|
23
22
|
file_mc = lookup_config(module_configs, target_name)
|
24
23
|
|
25
|
-
global_defaults.merge(file_def).merge(
|
24
|
+
global_defaults.merge(file_def).merge(module_defaults).merge(file_mc).merge(additional_settings)
|
26
25
|
end
|
27
26
|
|
28
27
|
def managed?(target_name)
|
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 = '0.
|
6
|
+
spec.version = '1.0.0'
|
7
7
|
spec.authors = ['Vox Pupuli']
|
8
8
|
spec.email = ['voxpupuli@groups.io']
|
9
9
|
spec.summary = 'Puppet Module Synchronizer'
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe ModuleSync do
|
4
4
|
context '::update' do
|
5
5
|
it 'loads the managed modules from the specified :managed_modules_conf' do
|
6
|
-
allow(ModuleSync).to receive(:
|
6
|
+
allow(ModuleSync).to receive(:find_template_files).and_return([])
|
7
7
|
allow(ModuleSync::Util).to receive(:parse_config).with('./config_defaults.yml').and_return({})
|
8
8
|
expect(ModuleSync).to receive(:managed_modules).with('./test_file.yml', nil, nil).and_return([])
|
9
9
|
|
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: 0.
|
4
|
+
version: 1.0.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:
|
11
|
+
date: 2019-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
rubygems_version: 3.0.
|
196
|
+
rubygems_version: 3.0.6
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Puppet Module Synchronizer
|