Skip to content

Commit

Permalink
Merge pull request #1207 from travis-ci/fix_same_name_branch_env_vars_am
Browse files Browse the repository at this point in the history
[SUPP-105] Allow setting env vars with same name for different branches in v3 API
  • Loading branch information
travis-architect authored Nov 30, 2021
2 parents 2d5f2e8 + b54d6d3 commit dc7fba9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/travis/api/v3/models/env_var.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Models::EnvVar < Travis::Settings::Model
validates :name, presence: true
validates_each :id, :name do |record, attr, value|
others = record.repository.env_vars.select { |ev| ev.id != record.id }
record.errors.add(:base, :duplicate_resource) if others.find { |ev| ev.send(attr) == record.send(attr) }
record.errors.add(:base, :duplicate_resource) if others.find { |ev| ev.send(attr) == record.send(attr) && ev.send(:branch) == record.send(:branch) }
end

def repository
Expand Down

0 comments on commit dc7fba9

Please sign in to comment.