modulesync 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf27b8e1ab5da1a382062fb50cf5fef7b1c24ec6df90988b9033b03a8293a5ae
4
- data.tar.gz: f45b4745c56ecb09f2e41e7b7df376fa55da074d0e7eda123428282734ed1e4f
3
+ metadata.gz: 5e2ed989c9e8e1837a6839019ab67c2defd8c61c2c724e2f0b9691a51012258e
4
+ data.tar.gz: 94f5d3040444e96ed1f22a4860d9e2d1c15aace660300cc5f0e4ee2194eb4bfe
5
5
  SHA512:
6
- metadata.gz: 04116e1a9f754869a52d7b008bc079ab5b9018fbc5a2d92a0f065a5b65dcdaf7970701e35787b2f781dc7a8b74856e7fc81c9b4bc2de76b6ac8d5006ea29dcc1
7
- data.tar.gz: 5bb03dd6cfd926a4f4249647dd54b5cf088a81015d6bf5493a7e7c6cfff657597e82884421c48814aedfcf01dba4da99290c8a89f848ac8eb6d0b5bea1595477
6
+ metadata.gz: 1b2b04b08c73b482e4f33f6b06ee038c95b334480b55a61751dc2360484157b8007f30378bf6d1e134ac1448e20930473f2e139fe86d62ef5f34897c6b59c771
7
+ data.tar.gz: 18d9cc8cff9cfbf5e68fa2c1818802701387f768d0a293cd6a950cf2bad297cd9dc7e8822858bc0d427c1a143d4b7bef72d7ce28889c61841dbc3b5d40a56507
@@ -46,6 +46,11 @@ jobs:
46
46
  run: bundle exec rake spec
47
47
  - name: Run behavior tests
48
48
  run: bundle exec cucumber
49
+ env:
50
+ GIT_COMMITTER_NAME: 'Aruba'
51
+ GIT_COMMITTER_EMAIL: 'aruba@example.com'
52
+ GIT_AUTHOR_NAME: 'Aruba'
53
+ GIT_AUTHOR_EMAIL: 'aruba@example.com'
49
54
  - name: Build gem
50
55
  run: gem build --strict --verbose *.gemspec
51
56
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [4.1.0](https://github.com/voxpupuli/modulesync/tree/4.1.0) (2025-10-16)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/modulesync/compare/4.0.1...4.1.0)
8
+
9
+ **Implemented enhancements:**
10
+
11
+ - Add execute option to preserve env vars [\#321](https://github.com/voxpupuli/modulesync/pull/321) ([Joris29](https://github.com/Joris29))
12
+ - Update git requirement from ~\> 3.0 [\#280](https://github.com/voxpupuli/modulesync/pull/280) ([dependabot[bot]](https://github.com/apps/dependabot))
13
+
5
14
  ## [4.0.1](https://github.com/voxpupuli/modulesync/tree/4.0.1) (2025-09-02)
6
15
 
7
16
  [Full Changelog](https://github.com/voxpupuli/modulesync/compare/4.0.0...4.0.1)
data/README.md CHANGED
@@ -395,6 +395,14 @@ msync update -m "Commit message" --bump --tag --tag_pattern 'v%s'
395
395
 
396
396
  The default for the tag pattern is `%s`.
397
397
 
398
+ #### Executing bundle command with a shared bundle path and gemfile
399
+
400
+ By default `msync execute` will remove bundler related env vars (^BUNDLE|^SOURCE_DATE_EPOCH$|^GEM_|RUBY), you can use `--env` flag to keep specified env vars:
401
+
402
+ ```
403
+ msync execute --env BUNDLE_PATH,BUNDLE_GEMFILE bundle exec rake lint
404
+ ```
405
+
398
406
  #### Updating the CHANGELOG
399
407
 
400
408
  When bumping the version in `metadata.json`, modulesync can let you
data/features/cli.feature CHANGED
@@ -45,5 +45,5 @@ Feature: CLI
45
45
  When I successfully run `msync update --verbose --noop --namespace fakenamespace --branch command-line-branch`
46
46
  Then the output should contain:
47
47
  """
48
- Creating new branch command-line-branch
48
+ Creating new branch command-line-branch from master
49
49
  """
@@ -49,3 +49,14 @@ Feature: execute
49
49
  [--fail-fast], [--no-fail-fast], [--skip-fail-fast] # Abort the run after a command execution failure
50
50
  """
51
51
  # NOTE: It seems there is a Thor bug here: default value is missing in help when sets to 'false'
52
+
53
+ Scenario: Show preserved bundle env var.
54
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
55
+ And I set the environment variables to:
56
+ | variable | value |
57
+ | BUNLE_PATH | /opt/msync/bundle |
58
+ When I successfully run `msync exec --env BUNLE_PATH -- env`
59
+ Then the stdout should contain:
60
+ """
61
+ BUNLE_PATH=/opt/msync/bundle
62
+ """
@@ -184,6 +184,9 @@ module ModuleSync
184
184
  type: :boolean,
185
185
  desc: 'Abort the run after a command execution failure',
186
186
  default: CLI.defaults[:fail_fast].nil? || CLI.defaults[:fail_fast]
187
+ option :env,
188
+ aliases: '-e',
189
+ desc: 'Comma-separated list of environment variables to preserve.'
187
190
  def execute(*command_args)
188
191
  raise Thor::Error, 'COMMAND is a required argument' if command_args.empty?
189
192
 
@@ -145,10 +145,15 @@ module ModuleSync
145
145
  opts_commit = { amend: true } if options[:amend]
146
146
  opts_push = { force: true } if options[:force]
147
147
  if options[:pre_commit_script]
148
- script = "#{File.dirname(__FILE__, 2)}/../contrib/#{options[:pre_commit_script]}"
149
- `#{script} #{@directory}`
148
+ script = "#{File.dirname(__FILE__, 3)}/contrib/#{options[:pre_commit_script]}"
149
+ system(script, @directory)
150
+ end
151
+ if repo.status.changed.empty? && repo.status.added.empty? && repo.status.deleted.empty?
152
+ puts "There were no changes in '#{@directory}'. Not committing."
153
+ return false
154
+ else
155
+ repo.commit(message, opts_commit)
150
156
  end
151
- repo.commit(message, opts_commit)
152
157
  if options[:remote_branch]
153
158
  if remote_branch_differ?(branch, options[:remote_branch])
154
159
  repo.push('origin', "#{branch}:#{options[:remote_branch]}", opts_push)
@@ -158,11 +163,8 @@ module ModuleSync
158
163
  repo.push('origin', branch, opts_push)
159
164
  puts "Changes have been pushed to: '#{branch}'"
160
165
  end
161
- rescue Git::GitExecuteError => e
162
- raise unless e.message.match?(/working (directory|tree) clean/)
163
-
164
- puts "There were no changes in '#{@directory}'. Not committing."
165
- return false
166
+ rescue Git::Error => e
167
+ raise e.message
166
168
  end
167
169
 
168
170
  true
@@ -191,7 +193,7 @@ module ModuleSync
191
193
  checkout_branch(options[:branch])
192
194
 
193
195
  $stdout.puts 'Files changed:'
194
- repo.diff('HEAD', '--').each do |diff|
196
+ repo.diff('HEAD').each do |diff|
195
197
  $stdout.puts diff.patch
196
198
  end
197
199
 
@@ -203,7 +205,7 @@ module ModuleSync
203
205
  $stdout.puts "\n\n"
204
206
  $stdout.puts '--------------------------------'
205
207
 
206
- git.diff('HEAD', '--').any? || untracked_unignored_files.any?
208
+ git.diff('HEAD').any? || untracked_unignored_files.any?
207
209
  end
208
210
 
209
211
  def puts(*)
data/lib/modulesync.rb CHANGED
@@ -178,7 +178,7 @@ module ModuleSync
178
178
  # managed_modules is either an array or a hash
179
179
  managed_modules.each do |puppet_module|
180
180
  manage_module(puppet_module, module_files, defaults)
181
- rescue ModuleSync::Error, Git::GitExecuteError => e
181
+ rescue ModuleSync::Error, Git::Error => e
182
182
  message = e.message || 'Error during `update`'
183
183
  warn "#{puppet_module.given_name}: #{message}"
184
184
  exit 1 unless options[:skip_broken]
@@ -216,11 +216,12 @@ module ModuleSync
216
216
  end
217
217
 
218
218
  command_args = cli_options[:command_args]
219
+ env_whitelist = (@options[:env] || '').split(',')
219
220
  local_script = File.expand_path command_args[0]
220
221
  command_args[0] = local_script if File.exist?(local_script)
221
222
 
222
- # Remove bundler-related env vars to allow the subprocess to run `bundle`
223
- command_env = ENV.reject { |k, _v| k.match?(/(^BUNDLE|^SOURCE_DATE_EPOCH$|^GEM_|RUBY)/) }
223
+ # Remove bundler-related env vars to allow the subprocess to run `bundle` unless explicitly whitelisted.
224
+ command_env = ENV.reject { |k, _v| k.match?(/(^BUNDLE|^SOURCE_DATE_EPOCH$|^GEM_|RUBY)/) && !env_whitelist.include?(k) }
224
225
 
225
226
  result = system command_env, *command_args, unsetenv_others: true, chdir: puppet_module.working_directory
226
227
  unless result
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Git
4
4
  module LibMonkeyPatch
5
- # Monkey patch set_custom_git_env_variables due to our ::Git::GitExecuteError handling.
5
+ # Monkey patch set_custom_git_env_variables due to our ::Git::Error handling.
6
6
  #
7
- # We rescue on the GitExecuteError and proceed differently based on the output of git.
7
+ # We rescue on the Git::Error and proceed differently based on the output of git.
8
8
  # This way makes code language-dependent, so here we ensure that Git gem throw git commands with the "C" language
9
9
  def set_custom_git_env_variables
10
10
  super
data/modulesync.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'modulesync'
8
- spec.version = '4.0.1'
8
+ spec.version = '4.1.0'
9
9
  spec.authors = ['Vox Pupuli']
10
10
  spec.email = ['voxpupuli@groups.io']
11
11
  spec.summary = 'Puppet Module Synchronizer'
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'rspec', '~> 3.13'
25
25
  spec.add_development_dependency 'voxpupuli-rubocop', '~> 4.2.0'
26
26
 
27
- spec.add_dependency 'git', '~>1.7'
27
+ spec.add_dependency 'git', '~> 3.0'
28
28
  spec.add_dependency 'gitlab', '>=4', '<6'
29
29
  spec.add_dependency 'octokit', '>=4', '<10'
30
30
  spec.add_dependency 'puppet-blacksmith', '>= 3.0', '< 9'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -91,14 +91,14 @@ dependencies:
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '1.7'
94
+ version: '3.0'
95
95
  type: :runtime
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '1.7'
101
+ version: '3.0'
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: gitlab
104
104
  requirement: !ruby/object:Gem::Requirement