modulesync 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile +1 -0
- data/README.md +44 -15
- data/lib/modulesync/cli.rb +10 -0
- data/lib/modulesync/git.rb +3 -0
- data/lib/modulesync/util.rb +10 -0
- data/lib/modulesync.rb +33 -1
- data/modulesync.gemspec +2 -1
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf47637269ebb272e17ffe11db44344aff0677e8a93fec636d7fcf6ed4d66e01
|
4
|
+
data.tar.gz: c2496e33b76a8af894707b6615662f05bcdb4ff73378020238a633b88915f433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9bc5072c017bff505be1f43e4e0bc2630645d0acee00bbb0a8a2d5b23804e4150414c904126570a5418e310ae873073ce207f91887e8f849db5f9cdc61fd680
|
7
|
+
data.tar.gz: 45588886c292dd533923614af9ea94d74685743a7b7708b3caeb4cbfbfe0539adafa2f78a8183d0d2384a4cd9d8f0c03535935b99c8278031f487317d36370e3
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 2018-
|
3
|
+
## 2018-12-27 - 0.10.0
|
4
|
+
|
5
|
+
This is another awesome release!
|
6
|
+
|
7
|
+
* Add support to submit PRs to GitHub when changes are pushed - [#147](https://github.com/voxpupuli/modulesync/pull/147)
|
8
|
+
* Fix "flat files" still mentioned in README - [#151](https://github.com/voxpupuli/modulesync/pull/151)
|
9
|
+
|
10
|
+
## 2018-02-15 - 0.9.0
|
4
11
|
|
5
12
|
## Summary
|
6
13
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -176,6 +176,28 @@ touching the modules, you can deactivate the hook.
|
|
176
176
|
msync hook deactivate
|
177
177
|
```
|
178
178
|
|
179
|
+
#### Submitting PRs to GitHub
|
180
|
+
|
181
|
+
You can have modulesync submit Pull Requests on GitHub automatically with the
|
182
|
+
`--pr` CLI option.
|
183
|
+
|
184
|
+
```
|
185
|
+
msync update --pr
|
186
|
+
```
|
187
|
+
|
188
|
+
You must set `GITHUB_TOKEN` in your environment for this to work. Other options
|
189
|
+
include:
|
190
|
+
|
191
|
+
* Set the PR title with `--pr-title` or in `modulesync.yml` with the `pr_title`
|
192
|
+
attribute.
|
193
|
+
* Assign labels to the PR with `--pr-labels` or in `modulesync.yml` with the
|
194
|
+
`pr_labels` attribute. **NOTE:** `pr_labels` should be a list. When using
|
195
|
+
the `--pr-labels` CLI option, you should use a comma separated list.
|
196
|
+
|
197
|
+
You can optionally set the `GITHUB_BASE_URL` environment variable to use GitHub
|
198
|
+
Enterprise. This is passed to Octokit's [`api_endpoint`](https://github.com/octokit/octokit.rb#interacting-with-the-githubcom-apis-in-github-enterprise)
|
199
|
+
configuration option.
|
200
|
+
|
179
201
|
### Using Forks and Non-master branches
|
180
202
|
|
181
203
|
The default functionality is to run ModuleSync on the puppetlabs modules, but
|
@@ -215,7 +237,7 @@ probably seems excessive. You can create a file called modulesync.yml in the
|
|
215
237
|
configuration directory that provides these arguments automatically. This file
|
216
238
|
has a form such as:
|
217
239
|
|
218
|
-
```
|
240
|
+
```yaml
|
219
241
|
---
|
220
242
|
namespace: mygithubusername
|
221
243
|
branch: modulesyncbranch
|
@@ -230,26 +252,33 @@ msync update -m "Commit message"
|
|
230
252
|
|
231
253
|
Available parameters for modulesync.yml
|
232
254
|
|
233
|
-
* git_base : The default URL to git clone from (Default: 'git@github.com:')
|
234
|
-
* namespace : Namespace of the projects to manage (Default: 'puppetlabs')
|
235
|
-
* branch : Branch to push to (Default: 'master')
|
236
|
-
* remote_branch : Remote branch to push to (Default: Same value as branch)
|
237
|
-
* message : Commit message to apply to updated modules.
|
238
|
-
* pre_commit_script : A script to be run before commiting (e.g. 'contrib/myfooscript.sh')
|
255
|
+
* `git_base` : The default URL to git clone from (Default: 'git@github.com:')
|
256
|
+
* `namespace` : Namespace of the projects to manage (Default: 'puppetlabs')
|
257
|
+
* `branch` : Branch to push to (Default: 'master')
|
258
|
+
* `remote_branch` : Remote branch to push to (Default: Same value as branch)
|
259
|
+
* `message` : Commit message to apply to updated modules.
|
260
|
+
* `pre_commit_script` : A script to be run before commiting (e.g. 'contrib/myfooscript.sh')
|
261
|
+
* `pr_title` : The title to use when submitting PRs to GitHub.
|
262
|
+
* `pr_labels` : A list of labels to assign PRs created on GitHub.
|
239
263
|
|
240
264
|
##### Example
|
241
265
|
|
242
|
-
######
|
266
|
+
###### GitHub
|
243
267
|
|
244
|
-
```
|
268
|
+
```yaml
|
245
269
|
---
|
246
270
|
namespace: MySuperOrganization
|
247
271
|
branch: modulesyncbranch
|
272
|
+
pr_title: "Updates to module template files via modulesync"
|
273
|
+
pr_labels:
|
274
|
+
- TOOLING
|
275
|
+
- MAINTENANCE
|
276
|
+
- MODULESYNC
|
248
277
|
```
|
249
278
|
|
250
|
-
######
|
279
|
+
###### GitLab
|
251
280
|
|
252
|
-
```
|
281
|
+
```yaml
|
253
282
|
---
|
254
283
|
git_base: 'user@gitlab.example.com:'
|
255
284
|
namespace: MySuperOrganization
|
@@ -258,7 +287,7 @@ branch: modulesyncbranch
|
|
258
287
|
|
259
288
|
###### Gerrit
|
260
289
|
|
261
|
-
```
|
290
|
+
```yaml
|
262
291
|
---
|
263
292
|
namespace: stackforge
|
264
293
|
git_base: ssh://jdoe@review.openstack.org:29418/
|
@@ -350,11 +379,11 @@ current date, bumped (minor) version, and commit message.
|
|
350
379
|
If `CHANGELOG.md` is absent in the repository, nothing will happen.
|
351
380
|
|
352
381
|
|
353
|
-
####
|
382
|
+
#### Working with templates
|
354
383
|
|
355
|
-
As
|
384
|
+
As mentioned, files in the moduleroot directory must be ERB templates (they must have an .erb extension, or they will be ignored). These files have direct access to @configs hash, which gets values from config_defaults.yml file and from the module being processed:
|
356
385
|
|
357
|
-
```
|
386
|
+
```erb
|
358
387
|
<%= @configs[:git_base] %>
|
359
388
|
<%= @configs[:namespace] %>
|
360
389
|
<%= @configs[:puppet_module] %>
|
data/lib/modulesync/cli.rb
CHANGED
@@ -85,6 +85,16 @@ module ModuleSync
|
|
85
85
|
:type => :boolean,
|
86
86
|
:desc => 'No-op mode',
|
87
87
|
:default => false
|
88
|
+
option :pr,
|
89
|
+
:type => :boolean,
|
90
|
+
:desc => 'Submit GitHub PR',
|
91
|
+
:default => false
|
92
|
+
option :pr_title,
|
93
|
+
:desc => 'Title of GitHub PR',
|
94
|
+
:default => CLI.defaults[:pr_title] || 'Update to module template files'
|
95
|
+
option :pr_labels,
|
96
|
+
:desc => 'Labels to add to the GitHub PR',
|
97
|
+
:default => CLI.defaults[:pr_labels] || []
|
88
98
|
option :offline,
|
89
99
|
:type => :boolean,
|
90
100
|
:desc => 'Do not run any Git commands. Allows the user to manage Git outside of ModuleSync.',
|
data/lib/modulesync/git.rb
CHANGED
@@ -151,11 +151,14 @@ module ModuleSync
|
|
151
151
|
rescue ::Git::GitExecuteError => git_error
|
152
152
|
if git_error.message =~ /working (directory|tree) clean/
|
153
153
|
puts "There were no files to update in #{name}. Not committing."
|
154
|
+
return false
|
154
155
|
else
|
155
156
|
puts git_error
|
156
157
|
raise
|
157
158
|
end
|
158
159
|
end
|
160
|
+
|
161
|
+
true
|
159
162
|
end
|
160
163
|
|
161
164
|
# Needed because of a bug in the git gem that lists ignored files as
|
data/lib/modulesync/util.rb
CHANGED
data/lib/modulesync.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'octokit'
|
2
3
|
require 'pathname'
|
3
4
|
require 'modulesync/cli'
|
4
5
|
require 'modulesync/constants'
|
@@ -9,6 +10,12 @@ require 'modulesync/settings'
|
|
9
10
|
require 'modulesync/util'
|
10
11
|
require 'monkey_patches'
|
11
12
|
|
13
|
+
GITHUB_TOKEN = ENV.fetch('GITHUB_TOKEN', '')
|
14
|
+
|
15
|
+
Octokit.configure do |c|
|
16
|
+
c.api_endpoint = ENV.fetch('GITHUB_BASE_URL', 'https://api.github.com')
|
17
|
+
end
|
18
|
+
|
12
19
|
module ModuleSync
|
13
20
|
include Constants
|
14
21
|
|
@@ -89,6 +96,11 @@ module ModuleSync
|
|
89
96
|
end
|
90
97
|
|
91
98
|
def self.manage_module(puppet_module, module_files, module_options, defaults, options)
|
99
|
+
if options[:pr] && !GITHUB_TOKEN
|
100
|
+
STDERR.puts 'Environment variable GITHUB_TOKEN must be set to use --pr!'
|
101
|
+
raise unless options[:skip_broken]
|
102
|
+
end
|
103
|
+
|
92
104
|
puts "Syncing #{puppet_module}"
|
93
105
|
namespace, module_name = module_name(puppet_module, options[:namespace])
|
94
106
|
unless options[:offline]
|
@@ -114,7 +126,27 @@ module ModuleSync
|
|
114
126
|
if options[:noop]
|
115
127
|
Git.update_noop(module_name, options)
|
116
128
|
elsif !options[:offline]
|
117
|
-
Git.update(
|
129
|
+
# Git.update() returns a boolean: true if files were pushed, false if not.
|
130
|
+
pushed = Git.update(module_name, files_to_manage, options)
|
131
|
+
return nil unless pushed && options[:pr]
|
132
|
+
|
133
|
+
# We only do GitHub PR work if the GITHUB_TOKEN variable is set in the environment.
|
134
|
+
repo_path = "#{namespace}/#{module_name}"
|
135
|
+
puts "Submitting PR '#{options[:pr_title]}' on GitHub to #{repo_path} - merges #{options[:branch]} into master"
|
136
|
+
github = Octokit::Client.new(:access_token => GITHUB_TOKEN)
|
137
|
+
pr = github.create_pull_request(repo_path, 'master', options[:branch], options[:pr_title], options[:message])
|
138
|
+
puts "PR created at #{pr['html_url']}"
|
139
|
+
|
140
|
+
# PR labels can either be a list in the YAML file or they can pass in a comma
|
141
|
+
# separated list via the command line argument.
|
142
|
+
pr_labels = Util.parse_list(options[:pr_labels])
|
143
|
+
|
144
|
+
# We only assign labels to the PR if we've discovered a list > 1. The labels MUST
|
145
|
+
# already exist. We DO NOT create missing labels.
|
146
|
+
unless pr_labels.empty?
|
147
|
+
puts "Attaching the following labels to PR #{pr['number']}: #{pr_labels.join(', ')}"
|
148
|
+
github.add_labels_to_an_issue(repo_path, pr['number'], pr_labels)
|
149
|
+
end
|
118
150
|
end
|
119
151
|
end
|
120
152
|
|
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 = '0.10.0'
|
7
7
|
spec.authors = ['Vox Pupuli']
|
8
8
|
spec.email = ['voxpupuli@groups.io']
|
9
9
|
spec.summary = 'Puppet Module Synchronizer'
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'rubocop', '~> 0.50.0'
|
25
25
|
|
26
26
|
spec.add_runtime_dependency 'git', '~>1.3'
|
27
|
+
spec.add_runtime_dependency 'octokit', '~>4.0'
|
27
28
|
spec.add_runtime_dependency 'puppet-blacksmith', '~>3.0'
|
28
29
|
spec.add_runtime_dependency 'thor'
|
29
30
|
end
|
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: 0.10.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: 2018-
|
11
|
+
date: 2018-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: octokit
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: puppet-blacksmith
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,8 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0'
|
181
195
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.7.6
|
196
|
+
rubygems_version: 3.0.1
|
184
197
|
signing_key:
|
185
198
|
specification_version: 4
|
186
199
|
summary: Puppet Module Synchronizer
|