modulesync 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +7 -6
- data/CHANGELOG.md +25 -1
- data/Gemfile +4 -0
- data/HISTORY.md +227 -0
- data/README.md +6 -6
- data/Rakefile +24 -0
- data/features/update.feature +22 -0
- data/lib/modulesync.rb +4 -1
- data/lib/modulesync/pr/github.rb +20 -11
- data/lib/modulesync/pr/gitlab.rb +23 -12
- data/lib/modulesync/util.rb +4 -1
- data/modulesync.gemspec +2 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67b9f844d9a57ed46eb75c5a9848524dee4409b78c3c1c70576f1f1c9629d24a
|
4
|
+
data.tar.gz: db8bbd7ca58ef57bf981c1ca49c91655d757f49920e598085e67a5e42a78b7b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d69cbe6c58f263a1bb9ba0c418d310505708bf52554d6145af1a9c3dd1ebbd06c987771fcc01c2c87d4e874f4fd918f46ca789342d802069969b196d6e5422
|
7
|
+
data.tar.gz: 89e4f8f54ba515b855060306d562663c1d2b6eed8ccdabc51ecec3ad5d234f3043b546d6263c24cb8086447df5544193e2ab31d90ef181f6ccaf6e5888faf77a
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -2,19 +2,20 @@
|
|
2
2
|
sudo: false
|
3
3
|
language: ruby
|
4
4
|
cache: bundler
|
5
|
-
dist:
|
5
|
+
dist: focal
|
6
6
|
script: 'bundle exec rake test'
|
7
|
+
bundler_args: --without release
|
7
8
|
rvm:
|
8
|
-
- 2.0
|
9
|
-
- 2.1
|
10
|
-
- 2.2
|
11
|
-
- 2.3
|
12
|
-
- 2.4
|
13
9
|
- 2.5
|
14
10
|
- 2.6
|
15
11
|
- 2.7
|
16
12
|
notifications:
|
17
13
|
email: false
|
14
|
+
irc:
|
15
|
+
on_success: always
|
16
|
+
on_failure: always
|
17
|
+
channels:
|
18
|
+
- "chat.freenode.org#voxpupuli-notifications"
|
18
19
|
deploy:
|
19
20
|
provider: rubygems
|
20
21
|
api_key:
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## [2.0.0](https://github.com/voxpupuli/modulesync/tree/2.0.0) (2020-08-18)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/modulesync/compare/1.3.0...2.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Drop support for Ruby 2.4 and older [\#191](https://github.com/voxpupuli/modulesync/pull/191) ([bastelfreak](https://github.com/bastelfreak))
|
12
|
+
|
13
|
+
**Implemented enhancements:**
|
14
|
+
|
15
|
+
- Symbolize keys in managed\_modules except for module names [\#185](https://github.com/voxpupuli/modulesync/pull/185) ([raphink](https://github.com/raphink))
|
16
|
+
|
17
|
+
**Fixed bugs:**
|
18
|
+
|
19
|
+
- GitLab MR: undefined method `\[\]' for nil:NilClass \(NoMethodError\) [\#187](https://github.com/voxpupuli/modulesync/issues/187)
|
20
|
+
- msync fails with nilClass error [\#172](https://github.com/voxpupuli/modulesync/issues/172)
|
21
|
+
- Fix NoMethodError for --pr option \(caused by `module_options = nil`\) / introduce --noop [\#188](https://github.com/voxpupuli/modulesync/pull/188) ([bittner](https://github.com/bittner))
|
22
|
+
- Allow empty module options in self.pr\(\) [\#186](https://github.com/voxpupuli/modulesync/pull/186) ([raphink](https://github.com/raphink))
|
23
|
+
|
24
|
+
## [1.3.0](https://github.com/voxpupuli/modulesync/tree/1.3.0) (2020-07-03)
|
4
25
|
|
5
26
|
* Expose --managed_modules_conf [#184](https://github.com/voxpupuli/modulesync/pull/184)
|
6
27
|
* Allow absolute path for config files [#183](https://github.com/voxpupuli/modulesync/pull/183)
|
@@ -227,3 +248,6 @@ Also fixes the README to document the very important -m flag.
|
|
227
248
|
|
228
249
|
This release adds support for other SSH-based git servers, which means
|
229
250
|
gitlab is now supported.
|
251
|
+
|
252
|
+
|
253
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -4,3 +4,7 @@ gemspec
|
|
4
4
|
|
5
5
|
gem 'cucumber', '< 3.0' if RUBY_VERSION < '2.1'
|
6
6
|
gem 'octokit', '~> 4.9'
|
7
|
+
|
8
|
+
group :release do
|
9
|
+
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/voxpupuli/github-changelog-generator', :branch => 'voxpupuli_essential_fixes'
|
10
|
+
end
|
data/HISTORY.md
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
## [1.3.0](https://github.com/voxpupuli/modulesync/tree/1.3.0) (2020-07-03)
|
2
|
+
|
3
|
+
* Expose --managed_modules_conf [#184](https://github.com/voxpupuli/modulesync/pull/184)
|
4
|
+
* Allow absolute path for config files [#183](https://github.com/voxpupuli/modulesync/pull/183)
|
5
|
+
* Add pr_target_branch option [#182](https://github.com/voxpupuli/modulesync/pull/182)
|
6
|
+
* Allow to specify namespace in module_options [#181](https://github.com/voxpupuli/modulesync/pull/181)
|
7
|
+
* Allow to override PR parameters per module [#178](https://github.com/voxpupuli/modulesync/pull/178)
|
8
|
+
* Include the gitlab library (if we interact with gitlab), not github [#179](https://github.com/voxpupuli/modulesync/pull/179)
|
9
|
+
|
10
|
+
## 2020-07-03 - 1.2.0
|
11
|
+
|
12
|
+
* Add support for GitLab merge requests (MRs) [#175](https://github.com/voxpupuli/modulesync/pull/175)
|
13
|
+
|
14
|
+
## 2020-05-01 - 1.1.0
|
15
|
+
|
16
|
+
This release provides metadata in the ERB template scope which makes it easy to read files from inside the module. A possible application is reading metadata.json and generating CI configs based on that.
|
17
|
+
|
18
|
+
* Add metadata to ERB template scope - [#168](https://github.com/voxpupuli/modulesync/pull/168)
|
19
|
+
* Skip issuing a PR if one already exists for -b option - [#171](https://github.com/voxpupuli/modulesync/pull/171)
|
20
|
+
* Correct the type on the pr-labels option to prevent a deprecation warning - [#173](https://github.com/voxpupuli/modulesync/pull/173)
|
21
|
+
|
22
|
+
## 2019-09-19 - 1.0.0
|
23
|
+
|
24
|
+
This is the first stable release! 🎉
|
25
|
+
|
26
|
+
* Use namespace in directory structure when cloning repositories - [#152](https://github.com/voxpupuli/modulesync/pull/152)
|
27
|
+
* Fix minor typo in help output - [#165](https://github.com/voxpupuli/modulesync/pull/165)
|
28
|
+
* Small improvements and fixes - [#166](https://github.com/voxpupuli/modulesync/pull/166)
|
29
|
+
* Fix overwriting of :global values - [#169](https://github.com/voxpupuli/modulesync/pull/169)
|
30
|
+
|
31
|
+
## 2018-12-27 - 0.10.0
|
32
|
+
|
33
|
+
This is another awesome release!
|
34
|
+
|
35
|
+
* Add support to submit PRs to GitHub when changes are pushed - [#147](https://github.com/voxpupuli/modulesync/pull/147)
|
36
|
+
* Fix "flat files" still mentioned in README - [#151](https://github.com/voxpupuli/modulesync/pull/151)
|
37
|
+
|
38
|
+
## 2018-02-15 - 0.9.0
|
39
|
+
|
40
|
+
## Summary
|
41
|
+
|
42
|
+
This is an awesome release - Now honors the repo default branch[#142](https://github.com/voxpupuli/modulesync/pull/142)
|
43
|
+
|
44
|
+
### Bugfixes
|
45
|
+
|
46
|
+
* Monkey patch ls_files until ruby-git/ruby-git#320 is resolved
|
47
|
+
* Reraise exception rather than exit so we can rescue a derived StandardError when using skip_broken option
|
48
|
+
|
49
|
+
### Enhancements
|
50
|
+
|
51
|
+
* Add new option to produce a failure exit code on warnings
|
52
|
+
* Remove hard coding of managed_modules.yml which means that options passed to ModuleSync.update can override the filename
|
53
|
+
|
54
|
+
## 2017-11-03 - 0.8.2
|
55
|
+
|
56
|
+
### Summary
|
57
|
+
|
58
|
+
This release fixes:
|
59
|
+
* Bug that caused .gitignore file handle to be left open - [#131](https://github.com/voxpupuli/modulesync/pull/131).
|
60
|
+
* Fixed switch_branch to use current_branch instead of master - [#130](https://github.com/voxpupuli/modulesync/pull/130).
|
61
|
+
* Fixed bug where failed runs wouldn't return correct exit code - [#125](https://github.com/voxpupuli/modulesync/pull/125).
|
62
|
+
* Fix typo in README link to Voxpupuli modulesync_config [#123](https://github.com/voxpupuli/modulesync/pull/123).
|
63
|
+
|
64
|
+
## 2017-05-08 - 0.8.1
|
65
|
+
|
66
|
+
### Summary
|
67
|
+
|
68
|
+
This release fixes a nasty bug with CLI vs configuration file option handling: Before [#117](https://github.com/voxpupuli/modulesync/pull/117) it was not possible to override options set in `modulesync.yml` on the command line, which could cause confusion in many cases. Now the configuration file is only used to populate the default values of the options specified in the README, and setting them on the command line will properly use those new values.
|
69
|
+
|
70
|
+
## 2017-05-05 - 0.8.0
|
71
|
+
|
72
|
+
### Summary
|
73
|
+
|
74
|
+
This release now prefers `.erb` suffixes on template files. To convert your moduleroot directory, run this command in your configs repo:
|
75
|
+
|
76
|
+
find moduleroot/ -type f -exec git mv {} {}.erb \;
|
77
|
+
|
78
|
+
Note that any `.erb`-suffixed configuration keys in `config_defaults.yml`, and `.sync.yml` need to be removed by hand. (This was unreleased functionality, will not affect most users.)
|
79
|
+
|
80
|
+
#### Refactoring
|
81
|
+
|
82
|
+
- Prefer `.erb` suffixes on template files, issue deprecation warning for templates without the extension
|
83
|
+
- Require Ruby 2.0 or higher
|
84
|
+
|
85
|
+
#### Bugfixes
|
86
|
+
|
87
|
+
- Fix dependency on `git` gem for diff functionality
|
88
|
+
- Fix error from `git` gem when diff contained line ending changes
|
89
|
+
|
90
|
+
## 2017-02-13 - 0.7.2
|
91
|
+
|
92
|
+
Fixes an issue releasing 0.7.1, no functional changes.
|
93
|
+
|
94
|
+
## 2017-02-13 - 0.7.1
|
95
|
+
|
96
|
+
Fixes an issue releasing 0.7.0, no functional changes.
|
97
|
+
|
98
|
+
## 2017-02-13 - 0.7.0
|
99
|
+
|
100
|
+
### Summary
|
101
|
+
|
102
|
+
This is the first release from Vox Pupuli, which has taken over maintenance of
|
103
|
+
modulesync.
|
104
|
+
|
105
|
+
#### Features
|
106
|
+
- New `msync update` arguments:
|
107
|
+
- `--git-base` to override `git_base`, e.g. for read-only git clones
|
108
|
+
- `-s` to skip the current module and continue on error
|
109
|
+
- `-x` for a negative filter (blacklist) of modules not to update
|
110
|
+
- Add `-a` argument to `msync hook` to pass additional arguments
|
111
|
+
- Add `:git_base` and `:namespace` data to `@configs` hash
|
112
|
+
- Allow `managed_modules.yml` to list modules with a different namespace
|
113
|
+
- Entire directories can be listed with `unmanaged: true`
|
114
|
+
|
115
|
+
#### Refactoring
|
116
|
+
- Replace CLI optionparser with thor
|
117
|
+
|
118
|
+
#### Bugfixes
|
119
|
+
- Fix git 1.8.0 compatibility, detecting when no files are changed
|
120
|
+
- Fix `delete: true` feature, now deletes files correctly
|
121
|
+
- Fix handling of `:global` config entries, not interpreted as a path
|
122
|
+
- Fix push without force to remote branch when no files have changed (#102)
|
123
|
+
- Output template name when ERB rendering fails
|
124
|
+
- Remove extraneous whitespace in `--noop` output
|
125
|
+
|
126
|
+
## 2015-08-13 - 0.6.1
|
127
|
+
|
128
|
+
### Summary
|
129
|
+
|
130
|
+
This is a bugfix release to fix an issue caused by the --project-root flag.
|
131
|
+
|
132
|
+
#### Bugfixes
|
133
|
+
|
134
|
+
- Fix bug in git pull function (#55)
|
135
|
+
|
136
|
+
##2015-08-11 - 0.6.0
|
137
|
+
|
138
|
+
### Summary
|
139
|
+
|
140
|
+
This release adds two new flags to help modulesync better integrate with CI tools.
|
141
|
+
|
142
|
+
#### Features
|
143
|
+
|
144
|
+
- Add --project-root flag
|
145
|
+
- Create --offline flag to disable git functionality
|
146
|
+
|
147
|
+
#### Bugfixes
|
148
|
+
|
149
|
+
- Fix :remote option for repo
|
150
|
+
|
151
|
+
#### Maintenance
|
152
|
+
|
153
|
+
- Added tests
|
154
|
+
|
155
|
+
## 2015-06-30 - 0.5.0
|
156
|
+
|
157
|
+
### Summary
|
158
|
+
|
159
|
+
This release adds the ability to sync a non-bare local git repo.
|
160
|
+
|
161
|
+
#### Features
|
162
|
+
|
163
|
+
- Allow one to sync non-bare local git repository
|
164
|
+
|
165
|
+
## 2015-06-24 - 0.4.0
|
166
|
+
|
167
|
+
### Summary
|
168
|
+
|
169
|
+
This release adds a --remote-branch flag and adds a global key for template
|
170
|
+
config.
|
171
|
+
|
172
|
+
#### Features
|
173
|
+
|
174
|
+
- Expose --remote-branch
|
175
|
+
- Add a global config key
|
176
|
+
|
177
|
+
#### Bugfixes
|
178
|
+
|
179
|
+
- Fix markdown syntax in README
|
180
|
+
|
181
|
+
## 2015-03-12 - 0.3.0
|
182
|
+
|
183
|
+
### Summary
|
184
|
+
|
185
|
+
This release contains a breaking change to some parameters exposed in
|
186
|
+
modulesync.yml. In particular, it abandons the user of git_user and
|
187
|
+
git_provider in favor of the parameter git_base to specify the base part of a
|
188
|
+
git URL to pull from. It also adds support for gerrit by adding a remote_branch
|
189
|
+
parameter for modulesync.yml that can differ from the local branch, plus a
|
190
|
+
number of new flags for updating modules.
|
191
|
+
|
192
|
+
#### Backwards-incompatible changes
|
193
|
+
|
194
|
+
- Remove git_user and git_provider_address as parameters in favor of using
|
195
|
+
git_base as a whole
|
196
|
+
|
197
|
+
#### Features
|
198
|
+
|
199
|
+
- Expose the puppet module name in the ERB templates
|
200
|
+
- Add support for gerrit by:
|
201
|
+
- Adding a --amend flag
|
202
|
+
- Adding a remote_branch parameter for modulesync.yml config file that can
|
203
|
+
differ from the local branch
|
204
|
+
- Adding a script to handle the pre-commit hook for adding a commit id
|
205
|
+
- Using git_base to specify an arbitrary git URL instead of an SCP-style one
|
206
|
+
- Add a --force flag (usually needed with the --amend flag if not using gerrit)
|
207
|
+
- Add --bump, --tag, --tag-pattern, and --changelog flags
|
208
|
+
|
209
|
+
#### Bugfixes
|
210
|
+
|
211
|
+
- Stop requiring .gitignore to exist
|
212
|
+
- Fix non-master branch functionality
|
213
|
+
- Add workarounds for older git versions
|
214
|
+
|
215
|
+
## 2014-11-16 - 0.2.0
|
216
|
+
|
217
|
+
### Summary
|
218
|
+
|
219
|
+
This release adds the --filter flag to filter what modules to sync.
|
220
|
+
Also fixes the README to document the very important -m flag.
|
221
|
+
|
222
|
+
## 2014-9-29 - 0.1.0
|
223
|
+
|
224
|
+
### Summary
|
225
|
+
|
226
|
+
This release adds support for other SSH-based git servers, which means
|
227
|
+
gitlab is now supported.
|
data/README.md
CHANGED
@@ -197,14 +197,14 @@ For GitHub Enterprise and self-hosted GitLab instances you also need to set the
|
|
197
197
|
```yaml
|
198
198
|
---
|
199
199
|
repo1:
|
200
|
-
|
201
|
-
|
202
|
-
|
200
|
+
github:
|
201
|
+
token: 'EXAMPLE_TOKEN'
|
202
|
+
base_url: 'https://api.github.com/'
|
203
203
|
|
204
204
|
repo2:
|
205
|
-
|
206
|
-
|
207
|
-
|
205
|
+
gitlab:
|
206
|
+
token: 'EXAMPLE_TOKEN'
|
207
|
+
base_url: 'https://git.example.com/api/v4'
|
208
208
|
```
|
209
209
|
|
210
210
|
Then:
|
data/Rakefile
CHANGED
@@ -20,3 +20,27 @@ end
|
|
20
20
|
|
21
21
|
task :test => %i[clean spec cucumber rubocop]
|
22
22
|
task :default => %i[test]
|
23
|
+
|
24
|
+
begin
|
25
|
+
require 'github_changelog_generator/task'
|
26
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
27
|
+
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
|
28
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix modulesync skip-changelog]
|
29
|
+
config.user = 'voxpupuli'
|
30
|
+
config.project = 'modulesync'
|
31
|
+
config.future_release = Gem::Specification.load("#{config.project}.gemspec").version
|
32
|
+
end
|
33
|
+
|
34
|
+
# Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
|
35
|
+
require 'rbconfig'
|
36
|
+
if RbConfig::CONFIG['host_os'] =~ /linux/
|
37
|
+
task :changelog do
|
38
|
+
puts 'Fixing line endings...'
|
39
|
+
changelog_file = File.join(__dir__, 'CHANGELOG.md')
|
40
|
+
changelog_txt = File.read(changelog_file)
|
41
|
+
new_contents = changelog_txt.gsub(/\r\n/, "\n")
|
42
|
+
File.open(changelog_file, 'w') { |file| file.puts new_contents }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
rescue LoadError
|
46
|
+
end
|
data/features/update.feature
CHANGED
@@ -905,6 +905,28 @@ Feature: update
|
|
905
905
|
Then the output should not contain "error"
|
906
906
|
Then the output should not contain "rejected"
|
907
907
|
|
908
|
+
Scenario: Creating a GitHub PR with an update
|
909
|
+
Given a mocked git configuration
|
910
|
+
And a remote module repository
|
911
|
+
And a directory named "moduleroot"
|
912
|
+
And I set the environment variables to:
|
913
|
+
| variable | value |
|
914
|
+
| GITHUB_TOKEN | foobar |
|
915
|
+
When I run `msync update --noop --branch managed_update --pr`
|
916
|
+
Then the output should contain "Would submit PR "
|
917
|
+
And the exit status should be 0
|
918
|
+
|
919
|
+
Scenario: Creating a GitLab MR with an update
|
920
|
+
Given a mocked git configuration
|
921
|
+
And a remote module repository
|
922
|
+
And a directory named "moduleroot"
|
923
|
+
And I set the environment variables to:
|
924
|
+
| variable | value |
|
925
|
+
| GITLAB_TOKEN | foobar |
|
926
|
+
When I run `msync update --noop --branch managed_update --pr`
|
927
|
+
Then the output should contain "Would submit MR "
|
928
|
+
And the exit status should be 0
|
929
|
+
|
908
930
|
Scenario: Repository with a default branch other than master
|
909
931
|
Given a mocked git configuration
|
910
932
|
And a remote module repository with "develop" as the default branch
|
data/lib/modulesync.rb
CHANGED
@@ -132,6 +132,7 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
|
|
132
132
|
|
133
133
|
if options[:noop]
|
134
134
|
Git.update_noop(git_repo, options)
|
135
|
+
options[:pr] && pr(module_options).manage(namespace, module_name, options)
|
135
136
|
elsif !options[:offline]
|
136
137
|
pushed = Git.update(git_repo, files_to_manage, options)
|
137
138
|
pushed && options[:pr] && pr(module_options).manage(namespace, module_name, options)
|
@@ -171,7 +172,8 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
|
|
171
172
|
# managed_modules is either an array or a hash
|
172
173
|
managed_modules.each do |puppet_module, module_options|
|
173
174
|
begin
|
174
|
-
|
175
|
+
mod_options = module_options.nil? ? nil : Util.symbolize_keys(module_options)
|
176
|
+
manage_module(puppet_module, module_files, mod_options, defaults, options)
|
175
177
|
rescue # rubocop:disable Lint/RescueWithoutErrorClass
|
176
178
|
$stderr.puts "Error while updating #{puppet_module}"
|
177
179
|
raise unless options[:skip_broken]
|
@@ -183,6 +185,7 @@ module ModuleSync # rubocop:disable Metrics/ModuleLength
|
|
183
185
|
end
|
184
186
|
|
185
187
|
def self.pr(module_options)
|
188
|
+
module_options ||= {}
|
186
189
|
github_conf = module_options[:github]
|
187
190
|
gitlab_conf = module_options[:gitlab]
|
188
191
|
|
data/lib/modulesync/pr/github.rb
CHANGED
@@ -18,23 +18,32 @@ module ModuleSync
|
|
18
18
|
head = "#{namespace}:#{options[:branch]}"
|
19
19
|
target_branch = options[:pr_target_branch] || 'master'
|
20
20
|
|
21
|
-
|
22
|
-
if pull_requests.empty?
|
23
|
-
pr = @api.create_pull_request(repo_path,
|
24
|
-
target_branch,
|
25
|
-
options[:branch],
|
26
|
-
options[:pr_title],
|
27
|
-
options[:message])
|
21
|
+
if options[:noop]
|
28
22
|
$stdout.puts \
|
29
|
-
"
|
30
|
-
|
23
|
+
"Using no-op. Would submit PR '#{options[:pr_title]}' to #{repo_path} " \
|
24
|
+
"- merges #{options[:branch]} into #{target_branch}"
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
pull_requests = @api.pull_requests(repo_path,
|
29
|
+
:state => 'open',
|
30
|
+
:base => target_branch,
|
31
|
+
:head => head)
|
32
|
+
unless pull_requests.empty?
|
31
33
|
# Skip creating the PR if it exists already.
|
32
34
|
$stdout.puts "Skipped! #{pull_requests.length} PRs found for branch #{options[:branch]}"
|
35
|
+
return
|
33
36
|
end
|
34
37
|
|
35
|
-
# PR labels can either be a list in the YAML file or they can pass in a comma
|
36
|
-
# separated list via the command line argument.
|
37
38
|
pr_labels = ModuleSync::Util.parse_list(options[:pr_labels])
|
39
|
+
pr = @api.create_pull_request(repo_path,
|
40
|
+
target_branch,
|
41
|
+
options[:branch],
|
42
|
+
options[:pr_title],
|
43
|
+
options[:message])
|
44
|
+
$stdout.puts \
|
45
|
+
"Submitted PR '#{options[:pr_title]}' to #{repo_path} " \
|
46
|
+
"- merges #{options[:branch]} into #{target_branch}"
|
38
47
|
|
39
48
|
# We only assign labels to the PR if we've discovered a list > 1. The labels MUST
|
40
49
|
# already exist. We DO NOT create missing labels.
|
data/lib/modulesync/pr/gitlab.rb
CHANGED
@@ -15,27 +15,38 @@ module ModuleSync
|
|
15
15
|
|
16
16
|
def manage(namespace, module_name, options)
|
17
17
|
repo_path = File.join(namespace, module_name)
|
18
|
-
|
19
18
|
head = "#{namespace}:#{options[:branch]}"
|
20
19
|
target_branch = options[:pr_target_branch] || 'master'
|
20
|
+
|
21
|
+
if options[:noop]
|
22
|
+
$stdout.puts \
|
23
|
+
"Using no-op. Would submit MR '#{options[:pr_title]}' to #{repo_path} " \
|
24
|
+
"- merges #{options[:branch]} into #{target_branch}"
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
21
28
|
merge_requests = @api.merge_requests(repo_path,
|
22
29
|
:state => 'opened',
|
23
30
|
:source_branch => head,
|
24
31
|
:target_branch => target_branch)
|
25
|
-
|
26
|
-
mr_labels = ModuleSync::Util.parse_list(options[:pr_labels])
|
27
|
-
mr = @api.create_merge_request(repo_path, options[:pr_title],
|
28
|
-
:source_branch => options[:branch],
|
29
|
-
:target_branch => target_branch,
|
30
|
-
:labels => mr_labels)
|
31
|
-
$stdout.puts \
|
32
|
-
"Submitted MR '#{options[:pr_title]}' to #{repo_path} - merges #{options[:branch]} into #{target_branch}"
|
33
|
-
return if mr_labels.empty?
|
34
|
-
$stdout.puts "Attached the following labels to MR #{mr.iid}: #{mr_labels.join(', ')}"
|
35
|
-
else
|
32
|
+
unless merge_requests.empty?
|
36
33
|
# Skip creating the MR if it exists already.
|
37
34
|
$stdout.puts "Skipped! #{merge_requests.length} MRs found for branch #{options[:branch]}"
|
35
|
+
return
|
38
36
|
end
|
37
|
+
|
38
|
+
mr_labels = ModuleSync::Util.parse_list(options[:pr_labels])
|
39
|
+
mr = @api.create_merge_request(repo_path,
|
40
|
+
options[:pr_title],
|
41
|
+
:source_branch => options[:branch],
|
42
|
+
:target_branch => target_branch,
|
43
|
+
:labels => mr_labels)
|
44
|
+
$stdout.puts \
|
45
|
+
"Submitted MR '#{options[:pr_title]}' to #{repo_path} " \
|
46
|
+
"- merges #{options[:branch]} into #{target_branch}"
|
47
|
+
|
48
|
+
return if mr_labels.empty?
|
49
|
+
$stdout.puts "Attached the following labels to MR #{mr.iid}: #{mr_labels.join(', ')}"
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
data/lib/modulesync/util.rb
CHANGED
@@ -3,7 +3,10 @@ require 'yaml'
|
|
3
3
|
module ModuleSync
|
4
4
|
module Util
|
5
5
|
def self.symbolize_keys(hash)
|
6
|
-
hash.inject({})
|
6
|
+
hash.inject({}) do |memo, (k, v)|
|
7
|
+
memo[k.to_sym] = v.is_a?(Hash) ? symbolize_keys(v) : v
|
8
|
+
memo
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
def self.parse_config(config_file)
|
data/modulesync.gemspec
CHANGED
@@ -3,14 +3,14 @@ $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 = '
|
6
|
+
spec.version = '2.0.0'
|
7
7
|
spec.authors = ['Vox Pupuli']
|
8
8
|
spec.email = ['voxpupuli@groups.io']
|
9
9
|
spec.summary = 'Puppet Module Synchronizer'
|
10
10
|
spec.description = 'Utility to synchronize common files across puppet modules in Github.'
|
11
11
|
spec.homepage = 'http://github.com/voxpupuli/modulesync'
|
12
12
|
spec.license = 'Apache-2.0'
|
13
|
-
spec.required_ruby_version = '>= 2.
|
13
|
+
spec.required_ruby_version = '>= 2.5.0'
|
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) }
|
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:
|
4
|
+
version: 2.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: 2020-
|
11
|
+
date: 2020-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- ".travis.yml"
|
166
166
|
- CHANGELOG.md
|
167
167
|
- Gemfile
|
168
|
+
- HISTORY.md
|
168
169
|
- LICENSE
|
169
170
|
- README.md
|
170
171
|
- Rakefile
|
@@ -204,14 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
205
|
requirements:
|
205
206
|
- - ">="
|
206
207
|
- !ruby/object:Gem::Version
|
207
|
-
version: 2.
|
208
|
+
version: 2.5.0
|
208
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
210
|
requirements:
|
210
211
|
- - ">="
|
211
212
|
- !ruby/object:Gem::Version
|
212
213
|
version: '0'
|
213
214
|
requirements: []
|
214
|
-
rubygems_version: 3.1.
|
215
|
+
rubygems_version: 3.1.2
|
215
216
|
signing_key:
|
216
217
|
specification_version: 4
|
217
218
|
summary: Puppet Module Synchronizer
|