Skip to content

Commit

Permalink
Do not alter swift_versions attribute when calculating Swift versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkoutso committed Sep 27, 2019
1 parent 1800804 commit f1f63b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

##### Bug Fixes

* None.
* Do not alter `swift_versions` attribute when calculating Swift versions.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#XXX](https://github.com/CocoaPods/Core/pull/XXX)


## 1.8.0 (2019-09-23)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def swift_version
#
def swift_versions
@swift_versions ||= begin
swift_versions = Array(attributes_hash['swift_versions'])
swift_versions = Array(attributes_hash['swift_versions']).dup
# Pre 1.7.0, the DSL was singularized as it supported only a single version of Swift. In 1.7.0 the DSL
# is now pluralized always and a specification can support multiple versions of Swift. This ensures
# we parse the old JSON serialized format and include it as part of the Swift versions supported.
Expand Down
11 changes: 11 additions & 0 deletions spec/specification/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ module Pod
hash['swift_version'].should == '1.0'
end

it 'does not alter the attribute hash when loading swift versions' do
@spec.swift_versions = ['4.2', '5.0']
first_hash = @spec.to_hash
first_hash['swift_versions'].should == ['4.2', '5.0']
first_hash['swift_version'].should == '5.0'
spec_from_hash = Specification.from_hash(first_hash)
second_hash = spec_from_hash.to_hash
second_hash['swift_versions'].should == ['4.2', '5.0']
second_hash['swift_version'].should == '5.0'
end

it 'reads swift version from a string' do
hash = {
'name' => 'BananaLib',
Expand Down

0 comments on commit f1f63b4

Please sign in to comment.