Skip to content

Commit eee6689

Browse files
authored
Merge pull request #391 from wordpress-mobile/fix/milestones-being-compared-as-strings
Fixes milestones being compared as strings
2 parents b4bfe77 + 778091b commit eee6689

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ _None_
1313
- Add `tools:ignore="InconsistentArrays"` to `available_languages.xml` to avoid a linter warning on repos hosting multiple app flavors. [#390]
1414

1515
### Bug Fixes
16+
* Fixes milestones being compared as strings instead of integers in `github_helper.get_last_milestone` [#391]
1617

1718
_None_
1819

lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def self.get_last_milestone(repository)
7070
else
7171
begin
7272
last_vcomps = last_stone[:title].split[0].split('.')
73-
last_stone = mile if mile_vcomps[0] > last_vcomps[0] || mile_vcomps[1] > last_vcomps[1]
73+
last_stone = mile if Integer(mile_vcomps[0]) > Integer(last_vcomps[0]) || Integer(mile_vcomps[1]) > Integer(last_vcomps[1])
7474
rescue StandardError
7575
puts 'Found invalid milestone'
7676
end

spec/github_helper_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,30 @@
9292
end
9393
end
9494

95+
describe 'get_last_milestone' do
96+
let(:test_repo) { 'repo-test/project-test' }
97+
let(:last_stone) { mock_milestone('10.0') }
98+
let(:client) do
99+
instance_double(
100+
Octokit::Client,
101+
list_milestones: ['9.8 ❄️', '9.9'].map { |title| mock_milestone(title) }.append(last_stone)
102+
)
103+
end
104+
105+
before do
106+
allow(described_class).to receive(:github_client).and_return(client)
107+
end
108+
109+
it 'returns correct milestone' do
110+
expect(client).to receive(:list_milestones)
111+
expect(described_class.get_last_milestone(repository: test_repo)).to eq(last_stone)
112+
end
113+
114+
def mock_milestone(title)
115+
{ title: title }
116+
end
117+
end
118+
95119
describe 'comment_on_pr' do
96120
let(:client) do
97121
instance_double(

0 commit comments

Comments
 (0)