modulesync 2.1.1 → 2.3.1

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +29 -9
  3. data/.github/workflows/release.yml +5 -6
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +17 -8
  6. data/.rubocop_todo.yml +25 -17
  7. data/.simplecov +46 -0
  8. data/CHANGELOG.md +60 -0
  9. data/Gemfile +5 -3
  10. data/LICENSE +173 -12
  11. data/README.md +30 -0
  12. data/bin/msync +17 -1
  13. data/features/cli.feature +12 -6
  14. data/features/execute.feature +51 -0
  15. data/features/hook.feature +5 -8
  16. data/features/push.feature +46 -0
  17. data/features/reset.feature +57 -0
  18. data/features/step_definitions/git_steps.rb +29 -1
  19. data/features/support/env.rb +9 -0
  20. data/features/update/bump_version.feature +8 -12
  21. data/features/update/dot_sync.feature +52 -0
  22. data/features/update/pull_request.feature +180 -0
  23. data/features/update.feature +74 -103
  24. data/lib/modulesync/cli/thor.rb +12 -0
  25. data/lib/modulesync/cli.rb +122 -28
  26. data/lib/modulesync/git_service/base.rb +63 -0
  27. data/lib/modulesync/git_service/factory.rb +28 -0
  28. data/lib/modulesync/{pr → git_service}/github.rb +23 -21
  29. data/lib/modulesync/git_service/gitlab.rb +62 -0
  30. data/lib/modulesync/git_service.rb +96 -0
  31. data/lib/modulesync/hook.rb +11 -13
  32. data/lib/modulesync/renderer.rb +9 -7
  33. data/lib/modulesync/repository.rb +78 -28
  34. data/lib/modulesync/settings.rb +0 -1
  35. data/lib/modulesync/source_code.rb +28 -2
  36. data/lib/modulesync/util.rb +4 -4
  37. data/lib/modulesync.rb +104 -66
  38. data/modulesync.gemspec +9 -5
  39. data/spec/helpers/faker/puppet_module_remote_repo.rb +16 -1
  40. data/spec/spec_helper.rb +2 -0
  41. data/spec/unit/modulesync/git_service/factory_spec.rb +16 -0
  42. data/spec/unit/modulesync/git_service/github_spec.rb +81 -0
  43. data/spec/unit/modulesync/git_service/gitlab_spec.rb +90 -0
  44. data/spec/unit/modulesync/git_service_spec.rb +201 -0
  45. data/spec/unit/modulesync/source_code_spec.rb +22 -0
  46. data/spec/unit/modulesync_spec.rb +0 -12
  47. metadata +96 -14
  48. data/lib/modulesync/pr/gitlab.rb +0 -54
  49. data/spec/unit/modulesync/pr/github_spec.rb +0 -49
  50. data/spec/unit/modulesync/pr/gitlab_spec.rb +0 -81
@@ -0,0 +1,51 @@
1
+ Feature: execute
2
+ Use ModuleSync to execute a custom script on each repositories
3
+
4
+ Scenario: Cloning sourcecodes before running command when modules/ dir is empty
5
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
6
+ Then the file "modules/awesome/puppet-test/metadata.json" should not exist
7
+ When I successfully run `msync exec --verbose -- /bin/true`
8
+ Then the stdout should contain "Cloning from 'file://"
9
+ And the file "modules/awesome/puppet-test/metadata.json" should exist
10
+
11
+ @no-clobber
12
+ Scenario: No clones before running command when sourcecode have already been cloned
13
+ Then the file "modules/awesome/puppet-test/metadata.json" should exist
14
+ When I successfully run `msync exec --verbose /bin/true`
15
+ Then the stdout should not contain "Cloning from 'file://"
16
+
17
+ @no-clobber
18
+ Scenario: When command run fails, fail fast if option defined
19
+ When I run `msync exec --verbose --fail-fast -- /bin/false`
20
+ Then the exit status should be 1
21
+ And the stderr should contain:
22
+ """
23
+ Command execution failed
24
+ """
25
+
26
+ @no-clobber
27
+ Scenario: When command run fails, run all and summarize errors if option fail-fast is not set
28
+ When I run `msync exec --verbose --no-fail-fast -- /bin/false`
29
+ Then the exit status should be 1
30
+ And the stderr should contain:
31
+ """
32
+ Error(s) during `execute` command:
33
+ *
34
+ """
35
+
36
+ Scenario: Show fail-fast default value in help
37
+ When I successfully run `msync help exec`
38
+ Then the stdout should contain:
39
+ """
40
+ [--fail-fast], [--no-fail-fast] # Abort the run after a command execution failure
41
+ # Default: true
42
+ """
43
+
44
+ Scenario: Override fail-fast default value using config file
45
+ Given the global option "fail_fast" sets to "false"
46
+ When I successfully run `msync help exec`
47
+ Then the stdout should contain:
48
+ """
49
+ [--fail-fast], [--no-fail-fast] # Abort the run after a command execution failure
50
+ """
51
+ # NOTE: It seems there is a Thor bug here: default value is missing in help when sets to 'false'
@@ -3,24 +3,21 @@ Feature: hook
3
3
 
4
4
  Scenario: Activating a hook
5
5
  Given a directory named ".git/hooks"
6
- When I run `msync hook activate`
7
- Then the exit status should be 0
8
- And the file named ".git/hooks/pre-push" should contain "bash"
6
+ When I successfully run `msync hook activate`
7
+ Then the file named ".git/hooks/pre-push" should contain "bash"
9
8
 
10
9
  Scenario: Deactivating a hook
11
10
  Given a file named ".git/hooks/pre-push" with:
12
11
  """
13
12
  git hook
14
13
  """
15
- When I run `msync hook deactivate`
16
- Then the exit status should be 0
14
+ When I successfully run `msync hook deactivate`
17
15
  Then the file ".git/hooks/pre-push" should not exist
18
16
 
19
17
  Scenario: Activating a hook with arguments
20
18
  Given a directory named ".git/hooks"
21
- When I run `msync hook activate -a '--foo bar --baz quux' -b master`
22
- Then the exit status should be 0
23
- And the file named ".git/hooks/pre-push" should contain:
19
+ When I successfully run `msync hook activate -a '--foo bar --baz quux' -b master`
20
+ Then the file named ".git/hooks/pre-push" should contain:
24
21
  """
25
22
  "$message" -n puppetlabs -b master --foo bar --baz quux
26
23
  """
@@ -0,0 +1,46 @@
1
+ Feature: push
2
+ Push commits to remote
3
+
4
+ Scenario: Push available commits to remote
5
+ Given a mocked git configuration
6
+ And a puppet module "puppet-test" from "awesome"
7
+ And a file named "managed_modules.yml" with:
8
+ """
9
+ ---
10
+ puppet-test:
11
+ namespace: awesome
12
+ """
13
+ And a file named "modulesync.yml" with:
14
+ """
15
+ ---
16
+ branch: modulesync
17
+ """
18
+ And a git_base option appended to "modulesync.yml" for local tests
19
+ And I successfully run `msync reset`
20
+ And I cd to "modules/awesome/puppet-test"
21
+ And I run `touch hello`
22
+ And I run `git add hello`
23
+ And I run `git commit -m'Hello!'`
24
+ And I cd to "~"
25
+ Then the puppet module "puppet-test" from "awesome" should have no commits made by "Aruba"
26
+ When I successfully run `msync push --verbose`
27
+ Then the puppet module "puppet-test" from "awesome" should have 1 commit made by "Aruba" in branch "modulesync"
28
+
29
+ Scenario: Push command without a branch sets
30
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
31
+ When I run `msync push --verbose`
32
+ Then the exit status should be 1
33
+ And the stderr should contain:
34
+ """
35
+ Error: 'branch' option is missing, please set it in configuration or in command line.
36
+ """
37
+
38
+ Scenario: Report the need to clone repositories if sourcecode was not cloned before
39
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
40
+ And the global option "branch" sets to "modulesync"
41
+ When I run `msync push --verbose`
42
+ Then the exit status should be 1
43
+ And the stderr should contain:
44
+ """
45
+ puppet-test: Repository must be locally available before trying to push
46
+ """
@@ -0,0 +1,57 @@
1
+ Feature: reset
2
+ Reset all repositories
3
+
4
+ Scenario: Running first reset to clone repositories
5
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
6
+ And the global option "branch" sets to "modulesync"
7
+ When I successfully run `msync reset --verbose`
8
+ Then the output should contain "Cloning from 'file://"
9
+ And the output should not contain "Hard-resetting any local changes to repository in"
10
+
11
+ @no-clobber
12
+ Scenario: Reset when sourcecodes have already been cloned
13
+ Given the file "modules/awesome/puppet-test/metadata.json" should exist
14
+ And the global option "branch" sets to "modulesync"
15
+ When I successfully run `msync reset --verbose`
16
+ Then the output should not contain "Cloning from 'file://"
17
+ And the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/master'"
18
+
19
+ Scenario: Reset after an upstream file addition
20
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
21
+ And the global option "branch" sets to "modulesync"
22
+ And I successfully run `msync reset`
23
+ Then the file "modules/awesome/puppet-test/hello" should not exist
24
+ When the puppet module "puppet-test" from "awesome" has a file named "hello" with:
25
+ """
26
+ Hello
27
+ """
28
+ When I successfully run `msync reset --verbose`
29
+ Then the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/master'"
30
+ And the file "modules/awesome/puppet-test/hello" should exist
31
+
32
+ Scenario: Reset after an upstream file addition in offline mode
33
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
34
+ And the global option "branch" sets to "modulesync"
35
+ And I successfully run `msync reset`
36
+ Then the file "modules/awesome/puppet-test/hello" should not exist
37
+ When the puppet module "puppet-test" from "awesome" has a branch named "execute"
38
+ And the puppet module "puppet-test" from "awesome" has, in branch "execute", a file named "hello" with:
39
+ """
40
+ Hello
41
+ """
42
+ When I successfully run `msync reset --offline`
43
+ Then the file "modules/awesome/puppet-test/hello" should not exist
44
+
45
+ Scenario: Reset to a specified branch
46
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
47
+ And the global option "branch" sets to "modulesync"
48
+ When the puppet module "puppet-test" from "awesome" has a branch named "other-branch"
49
+ And the puppet module "puppet-test" from "awesome" has, in branch "other-branch", a file named "hello" with:
50
+ """
51
+ Hello
52
+ """
53
+ And I successfully run `msync reset`
54
+ Then the file "modules/awesome/puppet-test/hello" should not exist
55
+ When I successfully run `msync reset --verbose --source-branch origin/other-branch`
56
+ And the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/other-branch'"
57
+ Then the file "modules/awesome/puppet-test/hello" should exist
@@ -32,7 +32,20 @@ Given 'a puppet module {string} from {string}' do |name, namespace|
32
32
  end
33
33
 
34
34
  Given 'a git_base option appended to "modulesync.yml" for local tests' do
35
- File.write "#{Aruba.config.working_directory}/modulesync.yml", "\ngit_base: #{ModuleSync::Faker::PuppetModuleRemoteRepo.git_base}", mode: 'a'
35
+ step "the global option 'git_base' sets to '#{ModuleSync::Faker::PuppetModuleRemoteRepo.git_base}'"
36
+ end
37
+
38
+ Given 'the file {string} appended with:' do |filename, content|
39
+ File.write filename, "\n#{content}", mode: 'a'
40
+ end
41
+
42
+ Given 'the global option {string} sets to {string}' do |key, value|
43
+ steps %(
44
+ Given the file "#{Aruba.config.working_directory}/modulesync.yml" appended with:
45
+ """
46
+ #{key}: #{value}
47
+ """
48
+ )
36
49
  end
37
50
 
38
51
  Given 'the puppet module {string} from {string} is read-only' do |name, namespace|
@@ -64,6 +77,16 @@ Given 'the puppet module {string} from {string} has a file named {string} with:'
64
77
  pmrr.add_file(filename, content)
65
78
  end
66
79
 
80
+ Given 'the puppet module {string} from {string} has, in branch {string}, a file named {string} with:' do |name, namespace, branch, filename, content|
81
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
82
+ pmrr.add_file(filename, content, branch)
83
+ end
84
+
85
+ Given 'the puppet module {string} from {string} has a branch named {string}' do |name, namespace, branch|
86
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
87
+ pmrr.create_branch(branch)
88
+ end
89
+
67
90
  Then 'the puppet module {string} from {string} should have a branch {string} with a file named {string} which contains:' do |name, namespace, branch, filename, content|
68
91
  pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
69
92
  expect(pmrr.read_file(filename, branch)).to include(content)
@@ -83,3 +106,8 @@ Then('the puppet module {string} from {string} should not have a tag named {stri
83
106
  pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
84
107
  expect(pmrr.tags).not_to include(tag)
85
108
  end
109
+
110
+ Given 'the branch {string} of the puppet module {string} from {string} is deleted' do |branch, name, namespace|
111
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
112
+ pmrr.delete_branch(branch)
113
+ end
@@ -1,3 +1,7 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.command_name 'Cucumber'
4
+
1
5
  require 'aruba/cucumber'
2
6
 
3
7
  require_relative '../../spec/helpers/faker'
@@ -6,4 +10,9 @@ ModuleSync::Faker.working_directory = File.expand_path('faker', Aruba.config.wor
6
10
 
7
11
  Before do
8
12
  @aruba_timeout_seconds = 5
13
+
14
+ # This enables coverage when aruba runs `msync` executable (cf. `bin/msync`)
15
+ set_environment_variable('COVERAGE', '1')
16
+
17
+ aruba.config.activate_announcer_on_command_failure = %i[stdout stderr]
9
18
  end
@@ -16,9 +16,8 @@ Feature: Bump a new version after an update
16
16
  """
17
17
  <%= @configs['content'] %>
18
18
  """
19
- When I run `msync update --message "Add new-file" --bump --changelog --tag`
20
- Then the exit status should be 0
21
- And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
19
+ When I successfully run `msync update --verbose --message "Add new-file" --bump --changelog --tag`
20
+ Then the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
22
21
  And the stdout should contain:
23
22
  """
24
23
  Bumped to version 0.4.3
@@ -44,9 +43,8 @@ Feature: Bump a new version after an update
44
43
  """
45
44
  <%= @configs['content'] %>
46
45
  """
47
- When I run `msync update --message "Add new-file" --bump`
48
- Then the exit status should be 0
49
- And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
46
+ When I successfully run `msync update --message "Add new-file" --bump`
47
+ Then the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
50
48
  And the stdout should contain:
51
49
  """
52
50
  Bumped to version 0.4.3
@@ -67,9 +65,8 @@ Feature: Bump a new version after an update
67
65
  """
68
66
  <%= @configs['content'] %>
69
67
  """
70
- When I run `msync update --message "Add new-file" --bump --changelog`
71
- Then the exit status should be 0
72
- And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
68
+ When I successfully run `msync update --message "Add new-file" --bump --changelog`
69
+ Then the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
73
70
  And the stdout should contain:
74
71
  """
75
72
  Bumped to version 0.4.3
@@ -81,7 +78,6 @@ Feature: Bump a new version after an update
81
78
  Scenario: Dont bump the module version after an update that produces no changes
82
79
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
83
80
  And a directory named "moduleroot"
84
- When I run `msync update --message "Add new-file" --bump --tag`
85
- Then the exit status should be 0
86
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
81
+ When I successfully run `msync update --message "Add new-file" --bump --tag`
82
+ Then the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
87
83
  And the puppet module "puppet-test" from "fakenamespace" should not have a tag named "0.4.3"
@@ -0,0 +1,52 @@
1
+ Feature: Update using a `.sync.yml` file
2
+ ModuleSync needs to apply templates according to `.sync.yml` content
3
+
4
+ Scenario: Updating a module with a .sync.yml file
5
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
6
+ And a file named "config_defaults.yml" with:
7
+ """
8
+ ---
9
+ :global:
10
+ variable: 'global'
11
+ template_with_specific_config:
12
+ variable: 'specific'
13
+ """
14
+ And a file named "moduleroot/template_with_specific_config.erb" with:
15
+ """
16
+ ---
17
+ <%= @configs['variable'] %>
18
+ """
19
+ And a file named "moduleroot/template_with_only_global_config.erb" with:
20
+ """
21
+ ---
22
+ <%= @configs['variable'] %>
23
+ """
24
+ And the puppet module "puppet-test" from "fakenamespace" has a branch named "target"
25
+ And the puppet module "puppet-test" from "fakenamespace" has, in branch "target", a file named ".sync.yml" with:
26
+ """
27
+ ---
28
+ :global:
29
+ variable: 'overwritten by globally defined value in .sync.yml'
30
+ template_with_specific_config:
31
+ variable: 'overwritten by file-specific defined value in .sync.yml'
32
+ """
33
+ When I successfully run `msync update --message 'Apply ModuleSync templates to target source code' --branch 'target'`
34
+ Then the file named "modules/fakenamespace/puppet-test/template_with_specific_config" should contain:
35
+ """
36
+ overwritten by file-specific defined value in .sync.yml
37
+ """
38
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba"
39
+ When the puppet module "puppet-test" from "fakenamespace" has, in branch "target", a file named ".sync.yml" with:
40
+ """
41
+ ---
42
+ :global:
43
+ variable: 'overwritten by globally defined value in .sync.yml'
44
+ template_with_specific_config:
45
+ variable: 'overwritten by newly file-specific defined value in .sync.yml'
46
+ """
47
+ And I successfully run `msync update --message 'Apply ModuleSync templates to target source code' --branch 'target'`
48
+ Then the file named "modules/fakenamespace/puppet-test/template_with_specific_config" should contain:
49
+ """
50
+ overwritten by newly file-specific defined value in .sync.yml
51
+ """
52
+ And the puppet module "puppet-test" from "fakenamespace" should have 2 commits made by "Aruba"
@@ -0,0 +1,180 @@
1
+ Feature: Create a pull-request/merge-request after update
2
+
3
+ Scenario: Run update in no-op mode and ask for GitHub PR
4
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
5
+ And a file named "managed_modules.yml" with:
6
+ """
7
+ ---
8
+ puppet-test:
9
+ github: {}
10
+ """
11
+ And I set the environment variables to:
12
+ | variable | value |
13
+ | GITHUB_TOKEN | foobar |
14
+ | GITHUB_BASE_URL | https://github.example.com |
15
+ And a file named "config_defaults.yml" with:
16
+ """
17
+ ---
18
+ test:
19
+ name: aruba
20
+ """
21
+ And a file named "moduleroot/test.erb" with:
22
+ """
23
+ <%= @configs['name'] %>
24
+ """
25
+ When I successfully run `msync update --noop --branch managed_update --pr`
26
+ Then the output should contain "Would submit PR "
27
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
28
+
29
+ Scenario: Run update in no-op mode and ask for GitLab MR
30
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
31
+ And a file named "managed_modules.yml" with:
32
+ """
33
+ ---
34
+ puppet-test:
35
+ gitlab: {
36
+ base_url: 'https://gitlab.example.com'
37
+ }
38
+ """
39
+ And I set the environment variables to:
40
+ | variable | value |
41
+ | GITLAB_TOKEN | foobar |
42
+ And a file named "config_defaults.yml" with:
43
+ """
44
+ ---
45
+ test:
46
+ name: aruba
47
+ """
48
+ And a file named "moduleroot/test.erb" with:
49
+ """
50
+ <%= @configs['name'] %>
51
+ """
52
+ When I successfully run `msync update --noop --branch managed_update --pr`
53
+ Then the output should contain "Would submit MR "
54
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
55
+
56
+ Scenario: Run update without changes in no-op mode and ask for GitLab MR
57
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
58
+ And a directory named "moduleroot"
59
+ And a file named "managed_modules.yml" with:
60
+ """
61
+ ---
62
+ puppet-test:
63
+ gitlab: {
64
+ base_url: 'https://gitlab.example.com'
65
+ }
66
+ """
67
+ And I set the environment variables to:
68
+ | variable | value |
69
+ | GITLAB_TOKEN | foobar |
70
+ When I successfully run `msync update --noop --branch managed_update --pr`
71
+ Then the output should not contain "Would submit MR "
72
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
73
+
74
+ Scenario: Ask for PR without credentials
75
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
76
+ And a file named "managed_modules.yml" with:
77
+ """
78
+ ---
79
+ puppet-test:
80
+ gitlab: {
81
+ base_url: https://gitlab.example.com
82
+ }
83
+ """
84
+ And a file named "config_defaults.yml" with:
85
+ """
86
+ ---
87
+ test:
88
+ name: aruba
89
+ """
90
+ And a file named "moduleroot/test.erb" with:
91
+ """
92
+ <%= @configs['name'] %>
93
+ """
94
+ When I run `msync update --noop --pr`
95
+ Then the stderr should contain "A token is required to use services from gitlab"
96
+ And the exit status should be 1
97
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
98
+
99
+ Scenario: Ask for PR/MR with modules from GitHub and from GitLab
100
+ Given a basic setup with a puppet module "puppet-github" from "fakenamespace"
101
+ And a basic setup with a puppet module "puppet-gitlab" from "fakenamespace"
102
+ And a file named "managed_modules.yml" with:
103
+ """
104
+ ---
105
+ puppet-github:
106
+ github:
107
+ base_url: https://github.example.com
108
+ token: 'secret'
109
+ puppet-gitlab:
110
+ gitlab:
111
+ base_url: https://gitlab.example.com
112
+ token: 'secret'
113
+ """
114
+ And a file named "config_defaults.yml" with:
115
+ """
116
+ ---
117
+ test:
118
+ name: aruba
119
+ """
120
+ And a file named "moduleroot/test.erb" with:
121
+ """
122
+ <%= @configs['name'] %>
123
+ """
124
+ When I successfully run `msync update --noop --branch managed_update --pr`
125
+ Then the output should contain "Would submit PR "
126
+ And the output should contain "Would submit MR "
127
+ And the puppet module "puppet-github" from "fakenamespace" should have no commits made by "Aruba"
128
+ And the puppet module "puppet-gitlab" from "fakenamespace" should have no commits made by "Aruba"
129
+
130
+ Scenario: Ask for PR with same source and target branch
131
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
132
+ And a file named "managed_modules.yml" with:
133
+ """
134
+ ---
135
+ puppet-test:
136
+ gitlab:
137
+ token: 'secret'
138
+ base_url: 'https://gitlab.example.com'
139
+ """
140
+ And a file named "config_defaults.yml" with:
141
+ """
142
+ ---
143
+ test:
144
+ name: aruba
145
+ """
146
+ And a file named "moduleroot/test.erb" with:
147
+ """
148
+ <%= @configs['name'] %>
149
+ """
150
+ When I run `msync update --noop --branch managed_update --pr --pr-target-branch managed_update`
151
+ Then the stderr should contain "Unable to open a pull request with the same source and target branch: 'managed_update'"
152
+ And the exit status should be 1
153
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
154
+
155
+ Scenario: Ask for PR with the default branch as source and target
156
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
157
+ And the puppet module "puppet-test" from "fakenamespace" has the default branch named "custom_default_branch"
158
+ And a file named "managed_modules.yml" with:
159
+ """
160
+ ---
161
+ puppet-test:
162
+ github:
163
+ token: 'secret'
164
+ base_url: 'https://gitlab.example.com'
165
+ """
166
+ And a file named "config_defaults.yml" with:
167
+ """
168
+ ---
169
+ test:
170
+ name: aruba
171
+ """
172
+ And a file named "moduleroot/test.erb" with:
173
+ """
174
+ <%= @configs['name'] %>
175
+ """
176
+ And a directory named "moduleroot"
177
+ When I run `msync update --noop --pr`
178
+ Then the stderr should contain "Unable to open a pull request with the same source and target branch: 'custom_default_branch'"
179
+ And the exit status should be 1
180
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"