modulesync 4.4.0 → 4.5.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: b756f006e9c39eef2b7a94ec1f896866f22f88099978530b2e587565dc9826c8
4
- data.tar.gz: 1d5fb83e96ee7974a09b12f91e6fea79997554fbe959d8ad6c29938d41f76ae8
3
+ metadata.gz: d8ccf6e8a41d6921a17a4171187f6ee1a63478ac231125c5bede16e52e9a2082
4
+ data.tar.gz: 5e65db0d1e4c83cdcaa4bd6537bb2080f5318551ae6ce10cbb62c1897217910d
5
5
  SHA512:
6
- metadata.gz: b838e8aeaf52e6d0f2ff3dfbdc1a6c0ede1d1188862de5e6d7205632d94383782ef3aeaa2fb1150b18469a46c582ded2fad29621048657c4922453d69e4821ed
7
- data.tar.gz: 19160e011a602778c435dfa18e5e7583fada6a7bfdca7ee125be0553b0b8acc795f10f986821bd3783a7dba9f5e8e1d6815565803f3411ab61b0a61c552e1d1b
6
+ metadata.gz: c16e333b6556c1141385a8d3e17c7a53c74b9fc74d648cdab58a655d8f055155c33ed37cb89d90ea16905b3b28ac9bb3fb98b520748ace87bd4a5dca85c33beb
7
+ data.tar.gz: fa3990dfd4ea5c958146832effa2292c5388b8100897a28d7548c3954c385da17fdb16cf1daf7c96aece91c951b69624106c4dcf487b36d17ab06cae67b6a775
@@ -18,7 +18,7 @@ jobs:
18
18
  steps:
19
19
  - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
20
20
  - name: Setup ruby
21
- uses: ruby/setup-ruby@d45b1a4e94b71acab930e56e79c6aa188764e7f9 # v1.316.0
21
+ uses: ruby/setup-ruby@6e5d382445ae5590b7449d8b3bc8cb1c2c27f617 # v1.317.0
22
22
  with:
23
23
  ruby-version: "3.4"
24
24
  bundler-cache: true
@@ -38,7 +38,7 @@ jobs:
38
38
  steps:
39
39
  - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
40
40
  - name: Install Ruby ${{ matrix.ruby }}
41
- uses: ruby/setup-ruby@d45b1a4e94b71acab930e56e79c6aa188764e7f9 # v1.316.0
41
+ uses: ruby/setup-ruby@6e5d382445ae5590b7449d8b3bc8cb1c2c27f617 # v1.317.0
42
42
  with:
43
43
  ruby-version: ${{ matrix.ruby }}
44
44
  bundler-cache: true
@@ -17,7 +17,7 @@ jobs:
17
17
  steps:
18
18
  - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
19
19
  - name: Install Ruby
20
- uses: ruby/setup-ruby@d45b1a4e94b71acab930e56e79c6aa188764e7f9 # v1.316.0
20
+ uses: ruby/setup-ruby@6e5d382445ae5590b7449d8b3bc8cb1c2c27f617 # v1.317.0
21
21
  with:
22
22
  ruby-version: 'ruby'
23
23
  - name: Build gem
@@ -96,7 +96,7 @@ jobs:
96
96
  with:
97
97
  name: gem-artifact
98
98
  - name: Install Ruby
99
- uses: ruby/setup-ruby@d45b1a4e94b71acab930e56e79c6aa188764e7f9 # v1.316.0
99
+ uses: ruby/setup-ruby@6e5d382445ae5590b7449d8b3bc8cb1c2c27f617 # v1.317.0
100
100
  with:
101
101
  ruby-version: 'ruby'
102
102
  - name: Wait for release to propagate
data/CHANGELOG.md CHANGED
@@ -2,9 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [4.4.0](https://github.com/voxpupuli/modulesync/tree/4.4.0) (2026-07-09)
5
+ ## [4.5.0](https://github.com/voxpupuli/modulesync/tree/4.5.0) (2026-07-15)
6
6
 
7
- [Full Changelog](https://github.com/voxpupuli/modulesync/compare/v4.3.0...4.4.0)
7
+ [Full Changelog](https://github.com/voxpupuli/modulesync/compare/v4.4.0...4.5.0)
8
+
9
+ **Implemented enhancements:**
10
+
11
+ - feat: update pr/mr title if needed [\#358](https://github.com/voxpupuli/modulesync/pull/358) ([rwaffen](https://github.com/rwaffen))
12
+ - feat: add option to rebase modulesync branch with the latest changes from the origin’s default branch [\#356](https://github.com/voxpupuli/modulesync/pull/356) ([rwaffen](https://github.com/rwaffen))
13
+
14
+ **Merged pull requests:**
15
+
16
+ - Enhance README.md [\#298](https://github.com/voxpupuli/modulesync/pull/298) ([bastelfreak](https://github.com/bastelfreak))
17
+
18
+ ## [v4.4.0](https://github.com/voxpupuli/modulesync/tree/v4.4.0) (2026-07-09)
19
+
20
+ [Full Changelog](https://github.com/voxpupuli/modulesync/compare/v4.3.0...v4.4.0)
8
21
 
9
22
  **Implemented enhancements:**
10
23
 
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- ModuleSync
2
- ===========
1
+ # ModuleSync
3
2
 
4
3
  [![License](https://img.shields.io/github/license/voxpupuli/modulesync.svg)](https://github.com/voxpupuli/modulesync/blob/master/LICENSE)
5
4
  [![Test](https://github.com/voxpupuli/modulesync/actions/workflows/ci.yml/badge.svg)](https://github.com/voxpupuli/modulesync/actions/workflows/ci.yml)
@@ -9,198 +8,191 @@ ModuleSync
9
8
  [![RubyGem Downloads](https://img.shields.io/gem/dt/modulesync.svg)](https://rubygems.org/gems/modulesync)
10
9
  [![Donated by Puppet Inc](https://img.shields.io/badge/donated%20by-Puppet%20Inc-fb7047.svg)](#transfer-notice)
11
10
 
12
- Table of Contents
13
- -----------------
14
-
15
- 1. [Usage TLDR](#usage-tldr)
16
- 2. [Overview](#overview)
17
- 3. [How it works](#how-it-works)
18
- 4. [Installing](#installing)
19
- 5. [Workflow](#workflow)
20
- 6. [The Templates](#the-templates)
21
-
22
- Usage TLDR
23
- ----------
24
-
25
- ```
11
+ ## Table of Contents
12
+
13
+ - [ModuleSync](#modulesync)
14
+ - [Table of Contents](#table-of-contents)
15
+ - [Usage TLDR](#usage-tldr)
16
+ - [Overview](#overview)
17
+ - [How It Works](#how-it-works)
18
+ - [Installing](#installing)
19
+ - [Workflow](#workflow)
20
+ - [Default mode](#default-mode)
21
+ - [Make changes](#make-changes)
22
+ - [Dry-run](#dry-run)
23
+ - [Offline support](#offline-support)
24
+ - [Damage mode](#damage-mode)
25
+ - [Automating Updates](#automating-updates)
26
+ - [Submitting PRs/MRs to GitHub or GitLab](#submitting-prsmrs-to-github-or-gitlab)
27
+ - [Using Forks and Non-master branches](#using-forks-and-non-master-branches)
28
+ - [Dry-run](#dry-run-1)
29
+ - [Damage mode](#damage-mode-1)
30
+ - [Configuring ModuleSync defaults](#configuring-modulesync-defaults)
31
+ - [Example](#example)
32
+ - [GitHub](#github)
33
+ - [GitLab](#gitlab)
34
+ - [Gerrit](#gerrit)
35
+ - [Filtering Repositories](#filtering-repositories)
36
+ - [Pushing to a different remote branch](#pushing-to-a-different-remote-branch)
37
+ - [Automating updates](#automating-updates-1)
38
+ - [Updating metadata.json](#updating-metadatajson)
39
+ - [Tagging repositories](#tagging-repositories)
40
+ - [Setting the tag pattern](#setting-the-tag-pattern)
41
+ - [Executing bundle command with a shared bundle path and gemfile](#executing-bundle-command-with-a-shared-bundle-path-and-gemfile)
42
+ - [Updating the CHANGELOG](#updating-the-changelog)
43
+ - [Working with templates](#working-with-templates)
44
+ - [The Templates](#the-templates)
45
+ - [Transfer Notice](#transfer-notice)
46
+ - [License](#license)
47
+ - [Release information](#release-information)
48
+
49
+ ## Usage TLDR
50
+
51
+ ```shell
26
52
  gem install modulesync
27
53
  msync --help
28
54
  ```
29
55
 
30
- Overview
31
- --------
32
-
33
- ModuleSync was written as a simple script with ERB templates to help the
34
- Puppet Labs module engineers manage the zoo of Puppet modules on GitHub, and
35
- has now been restructured and generalized to be used within other
36
- organizations. Puppet modules within an organization tend to have a number of
37
- meta-files that are identical or very similar between modules, such as the
38
- `Gemfile`, `.travis.yml`, `.gitignore`, or `spec_helper.rb`. If a file needs to
39
- change in one module, it likely needs to change in the same way in every other
40
- module that the organization manages.
41
-
42
- One approach to this problem is to use sed in a bash for loop on the modules to
43
- make a single change across every module. This approach falls short if there is
44
- a single file that is purposefully different than the others, but still needs
45
- to be managed. Moreover, this approach does not help if two files are
46
- structured differently but need to be changed with the same meaning; for
47
- instance, if the .travis.yml of one module uses a list of environments to
48
- include, and another uses a matrix of includes with a list of excludes, adding
49
- a test environment to both modules will require entirely different approaches.
50
-
51
- ModuleSync provides the advantage of defining a standard template for each
52
- file to follow, so it becomes clear what a file is supposed to look like. Two
53
- files with the same semantics should also have the same syntax. A difference
54
- between two files should have clear reasons, and old cruft should not be left
55
- in files of one module as the files of another module march forward.
56
-
57
- Another advantage of ModuleSync is the ability to run in no-op mode, which
58
- makes local changes and shows the diffs, but does not make permanent changes in
59
- the remote repository.
60
-
61
- How It Works
62
- ------------
63
-
64
- ModuleSync is a gem that uses the GitHub workflow to clone, update, and push module
65
- repositories. It expects to be activated from a directory containing
66
- configuration for modulesync and the modules, or you can pass it the location
67
- of this configuration directory. [The configuration for the Vox Pupuli
68
- modules](https://github.com/voxpupuli/modulesync_config), can be used as an
69
- example for your own configuration. The configuration directory contains a
70
- directory called moduleroot which mirrors the structure of a module. The files
71
- in the moduleroot are ERB templates, and MUST be named after the target file,
72
- with `.erb.` appended. The templates are
73
- rendered using values from a file called `config_defaults.yml` in the root (not
74
- moduleroot) of the configuration directory. The default values can be
75
- overridden or extended by adding a file called `.sync.yml` to the module itself.
76
- This allows us to, for example, have a set of "required" gems that are added
77
- to all Gemfiles, and a set of "optional" gems that a single module might add.
78
-
79
- Within the templates, values can be accessed in the `@configs` hash, which is
80
- merged from the values under the keys `:global` and the target file name (no
81
- `.erb` suffix).
82
-
83
- The list of modules to manage is in `managed_modules.yml` in the configuration
84
- directory. This lists just the names of the modules to be managed.
85
-
86
- ModuleSync can be called from the command line with parameters to change the
87
- branch you're working on or the remote to clone from and push to. You can also
88
- define these parameters in a file named `modulesync.yml` in the configuration
89
- directory.
90
-
91
- Installing
92
- ----------
56
+ ## Overview
93
57
 
94
- ```
58
+ ModuleSync was written as a simple script with ERB templates to help the Puppet Labs module engineers manage the zoo of Puppet modules on GitHub, and has now been restructured and generalized to be used within other organizations.
59
+ Puppet modules within an organization tend to have a number of meta-files that are identical or very similar between modules, such as the `Gemfile`, `.travis.yml`, `.gitignore`, or `spec_helper.rb`.
60
+ If a file needs to change in one module, it likely needs to change in the same way in every other module that the organization manages.
61
+
62
+ One approach to this problem is to use sed in a bash for loop on the modules to make a single change across every module.
63
+ This approach falls short if there is a single file that is purposefully different than the others, but still needs to be managed.
64
+ Moreover, this approach does not help if two files are structured differently but need to be changed with the same meaning;
65
+ for instance, if the .travis.yml of one module uses a list of environments to include, and another uses a matrix of includes with a list of excludes, adding a test environment to both modules will require entirely different approaches.
66
+
67
+ ModuleSync provides the advantage of defining a standard template for each file to follow, so it becomes clear what a file is supposed to look like.
68
+ Two files with the same semantics should also have the same syntax.
69
+ A difference between two files should have clear reasons, and old cruft should not be left in files of one module as the files of another module march forward.
70
+
71
+ Another advantage of ModuleSync is the ability to run in no-op mode, which makes local changes and shows the diffs, but does not make permanent changes in the remote repository.
72
+
73
+ ## How It Works
74
+
75
+ ModuleSync is a gem that uses the GitHub workflow to clone, update, and push module repositories.
76
+ It expects to be activated from a directory containing configuration for modulesync and the modules, or you can pass it the location of this configuration directory.
77
+ [The configuration for the Vox Pupuli modules](https://github.com/voxpupuli/modulesync_configs), can be used as an example for your own configuration.
78
+ The configuration directory contains a directory called moduleroot which mirrors the structure of a module.
79
+ The files in the moduleroot are ERB templates, and MUST be named after the target file, with `.erb.` appended.
80
+ The templates are rendered using values from a file called `config_defaults.yml` in the root (not moduleroot) of the configuration directory.
81
+ The default values can be overridden or extended by adding a file called `.sync.yml` to the module itself.
82
+ This allows us to, for example, have a set of "required" gems that are added to all Gemfiles, and a set of "optional" gems that a single module might add.
83
+
84
+ Within the templates, values can be accessed in the `@configs` hash, which is merged from the values under the keys `:global` and the target file name (no `.erb` suffix).
85
+
86
+ The list of modules to manage is in `managed_modules.yml` in the configuration directory.
87
+ This lists just the names of the modules to be managed.
88
+
89
+ ModuleSync can be called from the command line with parameters to change the branch you're working on or the remote to clone from and push to.
90
+ You can also define these parameters in a file named `modulesync.yml` in the configuration directory.
91
+
92
+ ## Installing
93
+
94
+ ```shell
95
95
  gem install modulesync
96
96
  ```
97
97
 
98
98
  For developers:
99
99
 
100
- ```
100
+ ```shell
101
101
  gem build modulesync.gemspec
102
102
  gem install modulesync-*.gem
103
103
  ```
104
104
 
105
- Workflow
106
- --------
105
+ ## Workflow
107
106
 
108
107
  ### Default mode
109
108
 
110
- With no additional arguments, ModuleSync clones modules from the puppetlabs
111
- github organization and pushes to the master branch.
109
+ With no additional arguments, ModuleSync clones modules from the puppetlabs github organization and pushes to the master branch.
112
110
 
113
111
  #### Make changes
114
112
 
115
- Make changes to a file in the moduleroot. For sanity's sake you should commit
116
- and push these changes, but in this mode the update will be rendered from the
117
- state of the files locally.
113
+ Make changes to a file in the moduleroot.
114
+ For sanity's sake you should commit and push these changes, but in this mode the update will be rendered from the state of the files locally.
118
115
 
119
116
  #### Dry-run
120
117
 
121
- Do a dry-run to see what files will be changed, added and removed. This clones
122
- the modules to `modules/<namespace>-<modulename>` in the current working
123
- directory, or if the modules are already cloned, does an effective `git fetch
124
- origin; git checkout master; git reset --hard origin/master` on the modules.
125
- Don't run modulesync if the current working directory contains a modules/
126
- directory with changes you want to keep. The dry-run makes local changes there,
127
- but does not commit or push changes. It is still destructive in that it
128
- overwrites local changes.
118
+ Do a dry-run to see what files will be changed, added and removed.
119
+ This clones the modules to `modules/<namespace>-<modulename>` in the current working directory, or if the modules are already cloned, does an effective
129
120
 
121
+ ```shell
122
+ git fetch origin
123
+ git checkout master
124
+ git reset --hard origin/master
130
125
  ```
126
+
127
+ on the modules.
128
+ Don't run modulesync if the current working directory contains a `modules/` directory with changes you want to keep.
129
+ The dry-run makes local changes there, but does not commit or push changes.
130
+ It is still destructive in that it overwrites local changes.
131
+
132
+ ```shell
131
133
  msync update --noop
132
134
  ```
133
135
 
134
136
  #### Offline support
135
137
 
136
- The --offline flag was added to allow a user to disable git support within
137
- msync. One reason for this is because the user wants to control git commands
138
- external to msync. Note, when using this command, msync assumes you have
139
- create the folder structure and git repositories correctly. If not, msync will
140
- fail to update correctly.
138
+ The --offline flag was added to allow a user to disable git support within msync.
139
+ One reason for this is because the user wants to control git commands external to msync.
140
+ Note, when using this command, msync assumes you have create the folder structure and git repositories correctly.
141
+ If not, msync will fail to update correctly.
141
142
 
142
- ```
143
+ ```shell
143
144
  msync update --offline
144
145
  ```
145
146
 
146
147
  #### Damage mode
147
148
 
148
- Make changes for real and push them back to master. This operates on the
149
- pre-cloned modules from the dry-run or clones them fresh if the modules aren't
150
- found.
149
+ Make changes for real and push them back to master.
150
+ This operates on the pre-cloned modules from the dry-run or clones them fresh if the modules aren't found.
151
151
 
152
- ```
152
+ ```shell
153
153
  msync update -m "Commit message"
154
154
  ```
155
155
 
156
156
  Amend the commit if changes are needed.
157
157
 
158
- ```
158
+ ```shell
159
159
  msync update --amend
160
160
  ```
161
161
 
162
- For most workflows you will need to force-push an amended commit. Not required
163
- for gerrit.
162
+ For most workflows you will need to force-push an amended commit.
163
+ Not required for gerrit.
164
164
 
165
- ```
165
+ ```shell
166
166
  msync update --amend --force
167
167
  ```
168
168
 
169
169
  #### Automating Updates
170
170
 
171
- You can install a pre-push git hook to automatically clone, update, and push
172
- modules upon pushing changes to the configuration directory. This does not
173
- include a noop mode.
171
+ You can install a pre-push git hook to automatically clone, update, and push modules upon pushing changes to the configuration directory.
172
+ This does not include a noop mode.
174
173
 
175
- ```
174
+ ```shell
176
175
  msync hook activate
177
176
  ```
178
177
 
179
- If you have activated the hook but want to make changes to the configuration
180
- directory (such as changes to `managed_modules.yml` or `modulesync.yml`) without
181
- touching the modules, you can deactivate the hook.
178
+ If you have activated the hook but want to make changes to the configuration directory (such as changes to `managed_modules.yml` or `modulesync.yml`) without touching the modules, you can deactivate the hook.
182
179
 
183
- ```
180
+ ```shell
184
181
  msync hook deactivate
185
182
  ```
186
183
 
187
184
  #### Submitting PRs/MRs to GitHub or GitLab
188
185
 
189
- You can have modulesync submit Pull Requests on GitHub or Merge Requests on
190
- GitLab automatically with the `--pr` CLI option.
186
+ You can have modulesync submit Pull Requests on GitHub or Merge Requests on GitLab automatically with the `--pr` CLI option.
191
187
 
192
- ```
188
+ ```shell
193
189
  msync update --pr
194
190
  ```
195
191
 
196
- In order for GitHub PRs or GitLab MRs to work, you must either provide
197
- the `GITHUB_TOKEN` or `GITLAB_TOKEN` environment variables,
198
- or set them per repository in `managed_modules.yml`, using the `github` or
199
- `gitlab` keys respectively.
192
+ In order for GitHub PRs or GitLab MRs to work, you must either provide the `GITHUB_TOKEN` or `GITLAB_TOKEN` environment variables.
193
+ You can also set them per repository in `managed_modules.yml`, using the `github` or `gitlab` keys respectively.
200
194
 
201
- For GitHub Enterprise and self-hosted GitLab instances you also need to set the
202
- `GITHUB_BASE_URL` or `GITLAB_BASE_URL` environment variables, or specify the
203
- `base_url` parameter per repository in `managed_modules.yml`:
195
+ For GitHub Enterprise and self-hosted GitLab instances you also need to set the `GITHUB_BASE_URL` or `GITLAB_BASE_URL` environment variables, or specify the `base_url` parameter in `modulesync.yml`:
204
196
 
205
197
  ```yaml
206
198
  ---
@@ -217,13 +209,9 @@ repo2:
217
209
 
218
210
  Then:
219
211
 
220
- * Set the PR/MR title with `--pr-title` or in `modulesync.yml` with the
221
- `pr_title` attribute.
222
- * Assign labels to the PR/MR with `--pr-labels` or in `modulesync.yml` with
223
- the `pr_labels` attribute. **NOTE:** `pr_labels` should be a list. When
224
- using the `--pr-labels` CLI option, you should use a comma separated list.
225
- * Set the target branch with `--pr-target-branch` or in `modulesync.yml` with
226
- the `pr_target_branch` attribute.
212
+ * Set the PR/MR title with `--pr-title` or in `modulesync.yml` with the `pr_title` attribute.
213
+ * Assign labels to the PR/MR with `--pr-labels` or in `modulesync.yml` with the `pr_labels` attribute. **NOTE:** `pr_labels` should be a list. When using the `--pr-labels` CLI option, you should use a comma separated list.
214
+ * Set the target branch with `--pr-target-branch` or in `modulesync.yml` with the `pr_target_branch` attribute.
227
215
 
228
216
  More details for GitHub:
229
217
 
@@ -231,42 +219,35 @@ More details for GitHub:
231
219
 
232
220
  ### Using Forks and Non-master branches
233
221
 
234
- The default functionality is to run ModuleSync on the puppetlabs modules, but
235
- you can use this on your own organization's modules. This functionality also
236
- applies if you want to work on a fork of the puppetlabs modules or work on a
237
- non-master branch of any organization's modules. ModuleSync does not support
238
- cloning from one remote and pushing to another, you are expected to fork
239
- manually. It does not support automating pull requests.
222
+ The default functionality is to run ModuleSync on the Vox Pupuli modules, but you can use this on your own organization's modules.
223
+ This functionality also applies if you want to work on a fork of the Vox Pupuli modules or work on a non-master branch of any organization's modules.
224
+ ModuleSync does not support cloning from one remote and pushing to another, you are expected to fork manually.
225
+ It does not support automating pull requests.
240
226
 
241
227
  #### Dry-run
242
228
 
243
- If you dry-run before doing the live update, you need to specify what namespace
244
- to clone from because the live update will not re-clone if the modules are
245
- already cloned. The namespace should be your fork, not the upstream module (if
246
- working on a fork).
229
+ If you dry-run before doing the live update, you need to specify what namespace to clone from because the live update will not re-clone if the modules are already cloned.
230
+ The namespace should be your fork, not the upstream module (if working on a fork).
247
231
 
248
- ```
249
- msync update -n puppetlabs --noop
232
+ ```shell
233
+ msync update -n voxpupuli --noop
250
234
  ```
251
235
 
252
236
  #### Damage mode
253
237
 
254
- You don't technically need to specify the namespace if the modules are already
255
- cloned from the dry-run, but it doesn't hurt. You do need to specify the
256
- namespace if the modules are not pre-cloned. You need to specify a branch to
257
- push to if you are not pushing to master.
238
+ You don't technically need to specify the namespace if the modules are already cloned from the dry-run, but it doesn't hurt.
239
+ You do need to specify the namespace if the modules are not pre-cloned.
240
+ You need to specify a branch to push to if you are not pushing to master.
258
241
 
259
- ```
260
- msync update -n puppetlabs -b sync_branch -m "Commit message"
242
+ ```shell
243
+ msync update -n voxpupuli -b sync_branch -m "Commit message"
261
244
  ```
262
245
 
263
246
  #### Configuring ModuleSync defaults
264
247
 
265
- If you're not using the puppetlabs modules or only ever pushing to a fork of
266
- them, then specifying the namespace and branch every time you use ModuleSync
267
- probably seems excessive. You can create a file called modulesync.yml in the
268
- configuration directory that provides these arguments automatically. This file
269
- has a form such as:
248
+ If you're not using Vox Pupuli modules or only ever pushing to a fork of them, then specifying the namespace and branch every time you use ModuleSync probably seems excessive.
249
+ You can create a file called modulesync.yml in the configuration directory that provides these arguments automatically.
250
+ This file has a form such as:
270
251
 
271
252
  ```yaml
272
253
  ---
@@ -276,17 +257,20 @@ branch: modulesyncbranch
276
257
 
277
258
  Then you can run ModuleSync without extra arguments:
278
259
 
279
- ```
260
+ ```shell
280
261
  msync update --noop
281
262
  msync update -m "Commit message"
282
263
  ```
283
264
 
265
+ Use `--rebase` to update the local working branch with the latest remote default
266
+ branch before ModuleSync changes any files. If the rebase conflicts, ModuleSync
267
+ aborts the rebase and reports an error for that module. A branch changed by the
268
+ rebase is pushed even when the template sync itself produces no changes.
269
+
284
270
  Available parameters for modulesync.yml
285
271
 
286
272
  * `git_base` : The default URL to git clone from (Default: 'git@github.com:')
287
- * `namespace` : Namespace of the projects to manage (Default: 'puppetlabs').
288
- This value can be overridden in the module name (e.g. 'namespace/mod') or by
289
- using the `namespace` key for the module in `managed_modules.yml`.
273
+ * `namespace` : Namespace of the projects to manage (Default: 'puppetlabs'). This value can be overridden in the module name (e.g. 'namespace/mod') or by using the `namespace` key for the module in `managed_modules.yml`.
290
274
  * `branch` : Branch to push to (Default: 'master')
291
275
  * `remote_branch` : Remote branch to push to (Default: Same value as branch)
292
276
  * `message` : Commit message to apply to updated modules.
@@ -333,14 +317,14 @@ pre_commit_script: openstack-commit-msg-hook.sh
333
317
 
334
318
  If you only want to sync some of the repositories in your managed_modules.yml, use the `-f` flag to filter by a regex:
335
319
 
336
- ```
320
+ ```shell
337
321
  msync update -f augeas -m "Commit message" # acts only on the augeas module
338
322
  msync update -f puppet-a..o "Commit message"
339
323
  ```
340
324
 
341
325
  If you want to skip syncing some of the repositories in your managed_modules.yml, use the `-x` flag to filter by a regex:
342
326
 
343
- ```
327
+ ```shell
344
328
  msync update -x augeas -m "Commit message" # acts on all modules except the augeas module
345
329
  msync update -x puppet-a..o "Commit message"
346
330
  ```
@@ -351,45 +335,41 @@ If no `-f` is specified, all repository are processed, if no `-x` is specified n
351
335
 
352
336
  If you want to push the modified branch to a different remote branch, you can use the -r flag:
353
337
 
354
- ```
338
+ ```shell
355
339
  msync update -r master_new -m "Commit message"
356
340
  ```
357
341
 
358
342
  #### Automating updates
359
343
 
360
- If you install a git hook, you need to tell it what remote and branch to push
361
- to. This may not work properly if you already have the modules cloned from a
362
- different remote. The hook will also look in modulesync.yml for default
363
- arguments.
344
+ If you install a git hook, you need to tell it what remote and branch to push to.
345
+ This may not work properly if you already have the modules cloned from a different remote.
346
+ The hook will also look in modulesync.yml for default arguments.
364
347
 
365
- ```
366
- msync hook activate -n puppetlabs -b sync_branch
348
+ ```shell
349
+ msync hook activate -n voxpupuli -b sync_branch
367
350
  ```
368
351
 
369
352
  #### Updating metadata.json
370
353
 
371
- Modulesync can optionally bump the minor version in `metadata.json` for each
372
- modified modules if you add the `--bump` flag to the command line:
354
+ Modulesync can optionally bump the minor version in `metadata.json` for each modified modules if you add the `--bump` flag to the command line:
373
355
 
374
- ```
356
+ ```shell
375
357
  msync update -m "Commit message" --bump
376
358
  ```
377
359
 
378
360
  #### Tagging repositories
379
361
 
380
- If you wish to tag the modified repositories with the newly bumped version,
381
- you can do so by using the `--tag` flag:
362
+ If you wish to tag the modified repositories with the newly bumped version, you can do so by using the `--tag` flag:
382
363
 
383
- ```
364
+ ```shell
384
365
  msync update -m "Commit message" --bump --tag
385
366
  ```
386
367
 
387
368
  #### Setting the tag pattern
388
369
 
389
- You can also set the format of the tag to be used (`printf`-formatted)
390
- by setting the `tag_pattern` option:
370
+ You can also set the format of the tag to be used (`printf`-formatted) by setting the `tag_pattern` option:
391
371
 
392
- ```
372
+ ```shell
393
373
  msync update -m "Commit message" --bump --tag --tag_pattern 'v%s'
394
374
  ```
395
375
 
@@ -399,30 +379,28 @@ The default for the tag pattern is `%s`.
399
379
 
400
380
  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
381
 
402
- ```
382
+ ```shell
403
383
  msync execute --env BUNDLE_PATH,BUNDLE_GEMFILE bundle exec rake lint
404
384
  ```
405
385
 
406
386
  #### Updating the CHANGELOG
407
387
 
408
- When bumping the version in `metadata.json`, modulesync can let you
409
- updating `CHANGELOG.md` in each modified repository.
388
+ When bumping the version in `metadata.json`, modulesync can let you updating `CHANGELOG.md` in each modified repository.
410
389
 
411
390
  This is one by using the `--changelog` flag:
412
391
 
413
- ```
392
+ ```shell
414
393
  msync update -m "Commit message" --bump --changelog
415
394
  ```
416
395
 
417
- This flag will cause the `CHANGELOG.md` file to be updated with the
418
- current date, bumped (minor) version, and commit message.
396
+ This flag will cause the `CHANGELOG.md` file to be updated with the current date, bumped (minor) version, and commit message.
419
397
 
420
398
  If `CHANGELOG.md` is absent in the repository, nothing will happen.
421
399
 
422
-
423
400
  #### Working with templates
424
401
 
425
- 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:
402
+ As mentioned, files in the moduleroot directory must be ERB templates (they must have an .erb extension, or they will be ignored).
403
+ These files have direct access to @configs hash, which gets values from config_defaults.yml file and from the module being processed:
426
404
 
427
405
  ```erb
428
406
  <%= @configs[:git_base] %>
@@ -430,8 +408,8 @@ As mentioned, files in the moduleroot directory must be ERB templates (they must
430
408
  <%= @configs[:puppet_module] %>
431
409
  ```
432
410
 
433
- Alternatively some meta data is passed to the template. This will allow you to add custom Ruby extensions inside the
434
- template, reading other files from the module, to make the template system more adaptive.
411
+ Alternatively some meta data is passed to the template.
412
+ This will allow you to add custom Ruby extensions inside the template, reading other files from the module, to make the template system more adaptive.
435
413
 
436
414
  ```erb
437
415
  module: <%= @metadata[:module_name] %>
@@ -441,16 +419,15 @@ workdir: <%= @metadata[:workdir] %>
441
419
 
442
420
  Will result in something like:
443
421
 
444
- ```
422
+ ```yaml
445
423
  module: puppet-test
446
424
  target: modules/github-org/puppet-test/test
447
425
  workdir: modules/github-org/puppet-test
448
426
  ```
449
427
 
450
- The Templates
451
- -------------
428
+ ## The Templates
452
429
 
453
- See [Vox Pupuli's modulesync\_config](https://github.com/voxpupuli/modulesync_config) and [Puppet's modulesync\_configs (Archived)](https://github.com/puppetlabs/modulesync_configs) repositories for different templates currently in use.
430
+ See [Vox Pupuli's modulesync\_config](https://github.com/voxpupuli/modulesync_config) repository for templates currently in use.
454
431
 
455
432
  ## Transfer Notice
456
433
 
@@ -467,6 +444,7 @@ This gem is licensed under the Apache-2 license.
467
444
  ## Release information
468
445
 
469
446
  To make a new release, please do:
447
+
470
448
  * update the version in `lib/modulesync/version.rb`
471
449
  * Install gems with `bundle install --with release --path .vendor`
472
450
  * generate the changelog with `bundle exec rake changelog`
@@ -114,6 +114,10 @@ module ModuleSync
114
114
  type: :boolean,
115
115
  desc: 'Do not run any Git commands. Allows the user to manage Git outside of ModuleSync.',
116
116
  default: false
117
+ option :rebase,
118
+ type: :boolean,
119
+ desc: 'Rebase the local branch onto the latest remote default branch before syncing.',
120
+ default: false
117
121
  option :bump,
118
122
  type: :boolean,
119
123
  desc: 'Bump module version to the next minor',
@@ -41,8 +41,17 @@ module ModuleSync
41
41
  base: target_branch,
42
42
  head: head)
43
43
  unless pull_requests.empty?
44
- # Skip creating the PR if it exists already.
45
- $stdout.puts "Skipped! #{pull_requests.length} PRs found for branch '#{source_branch}'"
44
+ # assumption: there should only be one PR for a given source and target branch, so we just take the first one
45
+ pr = pull_requests.first
46
+
47
+ if pr['title'] == title
48
+ $stdout.puts "Skipped! #{pull_requests.length} PRs found for branch '#{source_branch}'"
49
+ $stdout.puts "Skipped! Existing PR ##{pr['number']} already has title '#{title}'"
50
+ else
51
+ @api.update_pull_request(repo_path, pr['number'], title: title)
52
+ $stdout.puts "Updated title of existing PR ##{pr['number']} to '#{title}'"
53
+ end
54
+
46
55
  return
47
56
  end
48
57
 
@@ -40,8 +40,17 @@ module ModuleSync
40
40
  source_branch: source_branch,
41
41
  target_branch: target_branch)
42
42
  unless merge_requests.empty?
43
- # Skip creating the MR if it exists already.
44
- $stdout.puts "Skipped! #{merge_requests.length} MRs found for branch '#{source_branch}'"
43
+ # assumption: there should only be one MR for a given source and target branch, so we just take the first one
44
+ mr = merge_requests.first
45
+
46
+ if mr['title'] == title
47
+ $stdout.puts "Skipped! #{merge_requests.length} MRs found for branch '#{source_branch}'"
48
+ $stdout.puts "Skipped! Existing MR !#{mr['iid']} already has title '#{title}'"
49
+ else
50
+ @api.update_merge_request(repo_path, mr['iid'], title: title)
51
+ $stdout.puts "Updated title of existing MR !#{mr['iid']} to '#{title}'"
52
+ end
53
+
45
54
  return
46
55
  end
47
56
 
@@ -42,6 +42,12 @@ module ModuleSync
42
42
  commits.any?
43
43
  end
44
44
 
45
+ def branch_behind?(branch, target_branch)
46
+ log = repo.log(1).between(branch, "origin/#{target_branch}")
47
+ commits = log.respond_to?(:execute) ? log.execute : log
48
+ commits.any?
49
+ end
50
+
45
51
  def default_branch
46
52
  # `Git.default_branch` requires ruby-git >= 1.17.0
47
53
  return Git.default_branch(repo.dir) if Git.respond_to? :default_branch
@@ -52,6 +58,12 @@ module ModuleSync
52
58
  %r{remotes/origin/HEAD\s+->\s+origin/(?<branch>.+?)$}.match(symbolic_ref.full)[:branch]
53
59
  end
54
60
 
61
+ def remote_default_branch
62
+ return Git.default_branch(@remote) if Git.respond_to? :default_branch
63
+
64
+ default_branch
65
+ end
66
+
55
67
  def switch(branch:)
56
68
  unless branch
57
69
  branch = default_branch
@@ -87,13 +99,16 @@ module ModuleSync
87
99
  @git = Git.clone(@remote, @directory)
88
100
  end
89
101
 
90
- def prepare_workspace(branch:, operate_offline:)
102
+ def prepare_workspace(branch:, operate_offline:, rebase: false)
103
+ @rebased = false
91
104
  if cloned?
92
105
  puts "Overriding any local changes to repository in '#{@directory}'"
93
106
  git.fetch 'origin', prune: true unless operate_offline
94
107
  git.reset_hard
108
+ rebase_target = remote_default_branch if rebase && !operate_offline
95
109
  switch(branch: branch)
96
110
  git.pull('origin', branch) if !operate_offline && remote_branch_exists?(branch)
111
+ rebase_onto(rebase_target) if rebase_target
97
112
  else
98
113
  raise ModuleSync::Error, 'Unable to clone in offline mode.' if operate_offline
99
114
 
@@ -102,6 +117,31 @@ module ModuleSync
102
117
  end
103
118
  end
104
119
 
120
+ def rebase_onto(branch)
121
+ return false if repo.current_branch == branch || !branch_behind?(repo.current_branch, branch)
122
+
123
+ puts "Rebasing #{repo.current_branch} onto origin/#{branch}"
124
+ repo.lib.send(:command, 'rebase', "origin/#{branch}")
125
+ @rebased = true
126
+ rescue Git::Error => e
127
+ begin
128
+ repo.lib.send(:command, 'rebase', '--abort')
129
+ rescue Git::Error
130
+ # Preserve the original rebase error if Git had no rebase to abort.
131
+ end
132
+ raise ModuleSync::Error, "Rebase onto origin/#{branch} failed and was aborted: #{e.message}"
133
+ end
134
+
135
+ def push_changes(branch, remote_branch, options)
136
+ refspec = remote_branch ? "#{branch}:#{remote_branch}" : branch
137
+ if @rebased && !options[:force]
138
+ repo.lib.send(:command, 'push', '--force-with-lease', 'origin', refspec)
139
+ else
140
+ opts_push = options[:force] ? { force: true } : {}
141
+ repo.push('origin', refspec, opts_push)
142
+ end
143
+ end
144
+
105
145
  def default_reset_branch(branch)
106
146
  remote_branch_exists?(branch) ? branch : default_branch
107
147
  end
@@ -151,26 +191,24 @@ module ModuleSync
151
191
  end
152
192
  begin
153
193
  opts_commit = {}
154
- opts_push = {}
155
194
  opts_commit = { amend: true } if options[:amend]
156
- opts_push = { force: true } if options[:force]
157
195
  if options[:pre_commit_script]
158
196
  script = "#{File.dirname(__FILE__, 3)}/contrib/#{options[:pre_commit_script]}"
159
197
  system(script, @directory)
160
198
  end
161
199
  if repo.status.changed.empty? && repo.status.added.empty? && repo.status.deleted.empty?
162
200
  puts "There were no changes in '#{@directory}'. Not committing."
163
- return false
201
+ return false unless @rebased
164
202
  else
165
203
  repo.commit(message, opts_commit)
166
204
  end
167
205
  if options[:remote_branch]
168
- if remote_branch_differ?(branch, options[:remote_branch])
169
- repo.push('origin', "#{branch}:#{options[:remote_branch]}", opts_push)
206
+ if @rebased || remote_branch_differ?(branch, options[:remote_branch])
207
+ push_changes(branch, options[:remote_branch], options)
170
208
  puts "Changes have been pushed to: '#{branch}:#{options[:remote_branch]}'"
171
209
  end
172
210
  else
173
- repo.push('origin', branch, opts_push)
211
+ push_changes(branch, nil, options)
174
212
  puts "Changes have been pushed to: '#{branch}'"
175
213
  end
176
214
  rescue Git::Error => e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ModuleSync
4
- VERSION = '4.4.0'
4
+ VERSION = '4.5.0'
5
5
  end
data/lib/modulesync.rb CHANGED
@@ -123,7 +123,8 @@ module ModuleSync
123
123
  # but we totally skip the workspace preparation to keep the current behavior
124
124
  unless options[:offline]
125
125
  puppet_module.repository.prepare_workspace(branch: options[:branch],
126
- operate_offline: false)
126
+ operate_offline: false,
127
+ rebase: options[:rebase])
127
128
  end
128
129
 
129
130
  module_configs = Util.parse_config puppet_module.path(MODULE_CONF_FILE)
@@ -54,7 +54,7 @@ describe ModuleSync::GitService::GitHub do
54
54
  expect { @it.open_pull_request(**args) }.to output(/Submitted PR/).to_stdout
55
55
  end
56
56
 
57
- it 'skips submitting PR if one has already been issued' do
57
+ it 'updates the title if an existing PR has a different title' do
58
58
  pr = {
59
59
  'title' => 'Test title',
60
60
  'html_url' => 'https://example.com/pulls/44',
@@ -66,7 +66,28 @@ describe ModuleSync::GitService::GitHub do
66
66
  state: 'open',
67
67
  base: 'master',
68
68
  head: "#{args[:namespace]}:#{args[:source_branch]}").and_return([pr])
69
- expect { @it.open_pull_request(**args) }.to output("Skipped! 1 PRs found for branch 'test'\n").to_stdout
69
+ expect(@client).to receive(:update_pull_request)
70
+ .with(args[:repo_path], pr['number'], title: args[:title])
71
+ expect { @it.open_pull_request(**args) }
72
+ .to output("Updated title of existing PR #44 to 'Test PR is submitted'\n").to_stdout
73
+ end
74
+
75
+ it 'skips updating an existing PR if its title is unchanged' do
76
+ pr = {
77
+ 'title' => args[:title],
78
+ 'html_url' => 'https://example.com/pulls/44',
79
+ 'number' => '44',
80
+ }
81
+
82
+ expect(@client).to receive(:pull_requests)
83
+ .with(args[:repo_path],
84
+ state: 'open',
85
+ base: 'master',
86
+ head: "#{args[:namespace]}:#{args[:source_branch]}").and_return([pr])
87
+ expect(@client).not_to receive(:update_pull_request)
88
+ expect { @it.open_pull_request(**args) }
89
+ .to output("Skipped! 1 PRs found for branch 'test'\n" \
90
+ "Skipped! Existing PR #44 already has title 'Test PR is submitted'\n").to_stdout
70
91
  end
71
92
 
72
93
  context 'when labels are set' do
@@ -44,7 +44,7 @@ describe ModuleSync::GitService::GitLab do
44
44
  expect { @it.open_pull_request(**args) }.to output(/Submitted MR/).to_stdout
45
45
  end
46
46
 
47
- it 'skips submitting MR if one has already been issued' do
47
+ it 'updates the title if an existing MR has a different title' do
48
48
  mr = {
49
49
  'title' => 'Test title',
50
50
  'html_url' => 'https://example.com/pulls/44',
@@ -56,8 +56,28 @@ describe ModuleSync::GitService::GitLab do
56
56
  state: 'opened',
57
57
  source_branch: args[:source_branch],
58
58
  target_branch: 'master').and_return([mr])
59
+ expect(@client).to receive(:update_merge_request)
60
+ .with(args[:repo_path], mr['iid'], title: args[:title])
61
+ expect { @it.open_pull_request(**args) }
62
+ .to output("Updated title of existing MR !44 to 'Test MR is submitted'\n").to_stdout
63
+ end
64
+
65
+ it 'skips updating an existing MR if its title is unchanged' do
66
+ mr = {
67
+ 'title' => args[:title],
68
+ 'html_url' => 'https://example.com/pulls/44',
69
+ 'iid' => '44',
70
+ }
59
71
 
60
- expect { @it.open_pull_request(**args) }.to output("Skipped! 1 MRs found for branch 'test'\n").to_stdout
72
+ expect(@client).to receive(:merge_requests)
73
+ .with(args[:repo_path],
74
+ state: 'opened',
75
+ source_branch: args[:source_branch],
76
+ target_branch: 'master').and_return([mr])
77
+ expect(@client).not_to receive(:update_merge_request)
78
+ expect { @it.open_pull_request(**args) }
79
+ .to output("Skipped! 1 MRs found for branch 'test'\n" \
80
+ "Skipped! Existing MR !44 already has title 'Test MR is submitted'\n").to_stdout
61
81
  end
62
82
 
63
83
  context 'when labels are set' do
@@ -15,10 +15,12 @@ describe ModuleSync::Repository do
15
15
  end
16
16
  let(:branches) { instance_double(Git::Branches, remote: remote_branches) }
17
17
  let(:log) { instance_double(Git::Log) }
18
- let(:git) { instance_double(Git::Base, branches: branches, log: log) }
18
+ let(:git_lib) { instance_double(Git::Lib) }
19
+ let(:git) { instance_double(Git::Base, branches: branches, lib: git_lib, log: log) }
19
20
 
20
21
  before do
21
22
  repository.instance_variable_set(:@git, git)
23
+ ModuleSync.instance_variable_set(:@options, verbose: false)
22
24
  end
23
25
 
24
26
  it 'detects commits on a remote source branch that are missing from the target branch' do
@@ -33,4 +35,85 @@ describe ModuleSync::Repository do
33
35
 
34
36
  expect(repository.remote_branch_ahead?('modulesync', 'main')).to be false
35
37
  end
38
+
39
+ describe '#rebase_onto' do
40
+ before do
41
+ allow(git).to receive(:current_branch).and_return('modulesync')
42
+ allow(log).to receive(:between).with('modulesync', 'origin/main').and_return(log)
43
+ allow(log).to receive(:execute).and_return([instance_double(Git::Object::Commit)])
44
+ end
45
+
46
+ it 'rebases the current branch onto the remote default branch' do
47
+ expect(git_lib).to receive(:send).with(:command, 'rebase', 'origin/main')
48
+
49
+ repository.rebase_onto('main')
50
+ end
51
+
52
+ it 'does not rebase the default branch onto itself' do
53
+ allow(git).to receive(:current_branch).and_return('main')
54
+ expect(git_lib).not_to receive(:send)
55
+
56
+ repository.rebase_onto('main')
57
+ end
58
+
59
+ it 'does not rebase a branch that already contains the remote default branch' do
60
+ allow(log).to receive(:execute).and_return([])
61
+ expect(git_lib).not_to receive(:send)
62
+
63
+ repository.rebase_onto('main')
64
+ end
65
+
66
+ it 'aborts and reports a failed rebase' do
67
+ allow(git_lib).to receive(:send).with(:command, 'rebase', 'origin/main').and_raise(Git::Error, 'merge conflict')
68
+ expect(git_lib).to receive(:send).with(:command, 'rebase', '--abort')
69
+
70
+ expect { repository.rebase_onto('main') }
71
+ .to raise_error(ModuleSync::Error, %r{Rebase onto origin/main failed and was aborted: merge conflict})
72
+ end
73
+ end
74
+
75
+ describe '#prepare_workspace' do
76
+ it 'fetches and rebases the selected branch onto the remote default branch when requested' do
77
+ allow(Dir).to receive(:exist?).with('/tmp/example/.git').and_return(true)
78
+ allow(Git).to receive(:default_branch).with('https://github.com/example/repository.git').and_return('main')
79
+ allow(git).to receive(:current_branch).and_return('modulesync')
80
+ allow(log).to receive(:between).with('modulesync', 'origin/main').and_return(log)
81
+ allow(log).to receive(:execute).and_return([instance_double(Git::Object::Commit)])
82
+ expect(git).to receive(:fetch).with('origin', prune: true).ordered
83
+ expect(git).to receive(:reset_hard).ordered
84
+ expect(git).to receive(:pull).with('origin', 'modulesync').ordered
85
+ expect(git_lib).to receive(:send).with(:command, 'rebase', 'origin/main').ordered
86
+
87
+ repository.prepare_workspace(branch: 'modulesync', operate_offline: false, rebase: true)
88
+ end
89
+ end
90
+
91
+ describe '#submit_changes' do
92
+ it 'does not push an unchanged branch that was not rebased' do
93
+ status = instance_double(Git::Status, added: {}, changed: {}, deleted: {})
94
+ branch = instance_double(Git::Branch, checkout: true)
95
+ allow(git).to receive(:branch).with('modulesync').and_return(branch)
96
+ allow(git).to receive(:status).and_return(status)
97
+ expect(git).not_to receive(:push)
98
+ expect(git_lib).not_to receive(:send)
99
+
100
+ result = repository.submit_changes([], branch: 'modulesync', message: 'Update', force: false)
101
+
102
+ expect(result).to be false
103
+ end
104
+
105
+ it 'pushes a rebased branch even when ModuleSync made no file changes' do
106
+ status = instance_double(Git::Status, added: {}, changed: {}, deleted: {})
107
+ branch = instance_double(Git::Branch, checkout: true)
108
+ repository.instance_variable_set(:@rebased, true)
109
+ allow(git).to receive(:branch).with('modulesync').and_return(branch)
110
+ allow(git).to receive(:status).and_return(status)
111
+ expect(git_lib).to receive(:send)
112
+ .with(:command, 'push', '--force-with-lease', 'origin', 'modulesync')
113
+
114
+ result = repository.submit_changes([], branch: 'modulesync', message: 'Update', force: false)
115
+
116
+ expect(result).to be true
117
+ end
118
+ end
36
119
  end
@@ -63,5 +63,12 @@ describe ModuleSync do
63
63
 
64
64
  described_class.manage_module(puppet_module, [], {})
65
65
  end
66
+
67
+ it 'requests a rebase before syncing when enabled' do
68
+ described_class.instance_variable_set(:@options, described_class.config_defaults.merge(rebase: true))
69
+ expect(repository).to receive(:prepare_workspace).with(branch: nil, operate_offline: false, rebase: true)
70
+
71
+ described_class.manage_module(puppet_module, [], {})
72
+ end
66
73
  end
67
74
  end
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.4.0
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  - !ruby/object:Gem::Version
267
267
  version: '0'
268
268
  requirements: []
269
- rubygems_version: 4.0.10
269
+ rubygems_version: 4.0.16
270
270
  specification_version: 4
271
271
  summary: Puppet Module Synchronizer
272
272
  test_files: []