Skip to content

Commit 630a8f2

Browse files
authored
Merge pull request #1094 from travis-ci/sf-raw-config-merge-mode
add merge_mode to raw_configurations
2 parents c21b133 + 861dfa9 commit 630a8f2

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

lib/travis/api/v3/models/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class RequestConfigs < Struct.new(:data)
44
def raw_configs
55
Array(data[:raw_configs]).map do |attrs|
66
raw_config = RequestRawConfig.new(config: attrs[:config])
7-
RequestRawConfiguration.new(source: attrs[:source], raw_config: raw_config)
7+
RequestRawConfiguration.new(source: attrs[:source], merge_mode: attrs[:mode], raw_config: raw_config)
88
end
99
end
1010

lib/travis/api/v3/renderer/request_raw_configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Travis::API::V3
22
class Renderer::RequestRawConfiguration < ModelRenderer
3-
representation(:minimal, :config, :source)
3+
representation(:minimal, :config, :source, :merge_mode)
44
representation(:standard, *representations[:minimal])
55

66
def config

lib/travis/api/v3/services/requests/create.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Services::Requests::Create < Service
55
private_constant :TIME_FRAME, :LIMIT
66

77
result_type :request
8-
params "request", "user", :merge_mode, :config, :message, :branch, :sha, :token
8+
params "request", "user", :merge_mode, :config, :configs, :message, :branch, :sha, :token
99

1010
def run
1111
repository = check_login_and_find(:repository)

spec/v3/service_index_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ module Routes
7777
"accepted_params" => %w(
7878
request.merge_mode
7979
request.config
80+
request.configs
8081
request.message
8182
request.branch
8283
request.sha

spec/v3/services/request/find_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
let(:one) { request.raw_configs.build(key: '123', config: 'language: ruby') }
4141
let(:two) { request.raw_configs.build(key: '234', config: 'rvm: 2.5.1') }
4242

43-
before { request.raw_configurations.create!(raw_config: one, source: '.travis.yml') }
44-
before { request.raw_configurations.create!(raw_config: two, source: 'other.yml') }
45-
before { request.raw_configurations.create!(raw_config: one, source: '.travis.yml') } # accidental duplicate
43+
before { request.raw_configurations.create!(raw_config: one, source: '.travis.yml', merge_mode: 'one') }
44+
before { request.raw_configurations.create!(raw_config: two, source: 'other.yml', merge_mode: 'two') }
45+
before { request.raw_configurations.create!(raw_config: one, source: '.travis.yml', merge_mode: 'one') } # accidental duplicate
4646

4747
before { get("/v3/repo/#{repo.id}/request/#{request.id}?include=request.raw_configs") }
4848

@@ -55,13 +55,15 @@
5555
'@type' => 'request_raw_configuration',
5656
'@representation' => 'standard',
5757
'config' => 'language: ruby',
58-
'source' => '.travis.yml'
58+
'source' => '.travis.yml',
59+
'merge_mode' => 'one',
5960
},
6061
{
6162
'@type' => 'request_raw_configuration',
6263
'@representation' => 'standard',
6364
'config' => 'rvm: 2.5.1',
64-
'source' => 'other.yml'
65+
'source' => 'other.yml',
66+
'merge_mode' => 'two',
6567
}
6668
]
6769
)

spec/v3/services/request/preview_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
let(:configs) do
1010
{
11-
raw_configs: [source: 'travis-ci/travis-yml:.travis.yml@ref', config: 'script: true'],
11+
raw_configs: [source: 'travis-ci/travis-yml:.travis.yml@ref', config: 'script: true', mode: 'replace'],
1212
config: { script: ['true'] },
1313
matrix: [script: ['true']],
1414
messages: [type: :type, level: :info, key: :key, code: :code, args: { one: 'one' }, src: '.travis.yml', line: 1],
@@ -53,6 +53,7 @@ def parse(str)
5353
'@type': 'request_raw_configuration',
5454
'@representation': 'minimal',
5555
source: 'travis-ci/travis-yml:.travis.yml@ref',
56+
merge_mode: 'replace',
5657
config: 'script: true'
5758
],
5859
request_config: {

0 commit comments

Comments
 (0)