Skip to content

Commit

Permalink
fix: last tag being current commit (#43)
Browse files Browse the repository at this point in the history
* fix: last tag being current commit

* chore: fix lint
  • Loading branch information
stanogn authored Apr 17, 2023
1 parent 62536de commit e41bdaa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def self.get_beginning_of_next_sprint(params)

# Tag's format is v2.3.4-5-g7685948
# See git describe man page for more info
tag_name = tag.split('-')[0...-2].join('-').strip
# It can be also v2.3.4-5 if there is no commit after tag
tag_name = tag
if tag.split('-').length >= 3
tag_name = tag.split('-')[0...-2].join('-').strip
end
parsed_version = tag_name.match(params[:tag_version_match])

if parsed_version.nil?
Expand Down
18 changes: 18 additions & 0 deletions spec/analyze_commits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ def test_analyze_commits(commits)
allow(Fastlane::Actions::AnalyzeCommitsAction).to receive(:get_commits_from_hash).and_return(commits)
end

def test_analyze_commits_same_commit_as_tag
# for simplicity, these two actions are grouped together because they need to be run for every test,
# but require different commits to be passed each time. So we can't use the "before :each" for this
# this is the same as test_analyze_commits, but the last commit is the same as the last tag
allow(Fastlane::Actions::AnalyzeCommitsAction).to receive(:get_last_tag).and_return('v1.0.8')
end

def execute_lane_test(params)
Fastlane::FastFile.new.parse("lane :test do analyze_commits( #{params} ) end").runner.execute(:test)
end
Expand Down Expand Up @@ -168,6 +175,17 @@ def execute_lane_test(params)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::RELEASE_NEXT_VERSION]).to eq("1.0.8")
end

it "should return false when we are on the same commit as the last tag" do
commits = [
"Merge ...|",
"Custom ...|"
]
test_analyze_commits_same_commit_as_tag

expect(execute_lane_test(match: 'v*')).to eq(false)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::RELEASE_NEXT_VERSION]).to eq("1.0.8")
end

it "should deal with multiline comments" do
commits = [
"fix: add alpha deploy (#10)|* chore: test alpha build with CircleCI
Expand Down

0 comments on commit e41bdaa

Please sign in to comment.