Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changelog_from_git_commits fix from command line #12477

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions fastlane/lib/fastlane/actions/changelog_from_git_commits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def self.run(params)
UI.success("Collecting the last #{params[:commits_count]} Git commits")
else
if params[:between]
from, to = params[:between]
if params[:between].kind_of?(String) && params[:between].include?(",") # :between is string
from, to = params[:between].split(",", 2)
elsif params[:between].kind_of?(Array)
from, to = params[:between]
end
else
from = Actions.last_git_tag_name(params[:match_lightweight_tag], params[:tag_match_pattern])
UI.verbose("Found the last Git tag: #{from}")
Expand Down Expand Up @@ -72,9 +76,13 @@ def self.available_options
is_string: false,
conflicting_options: [:commits_count],
verify_block: proc do |value|
UI.user_error!(":between must be of type array") unless value.kind_of?(Array)
UI.user_error!(":between must not contain nil values") if value.any?(&:nil?)
UI.user_error!(":between must be an array of size 2") unless (value || []).size == 2
if value.kind_of?(String)
UI.user_error!(":between must contain comma") unless value.include?(',')
else
UI.user_error!(":between must be of type array") unless value.kind_of?(Array)
UI.user_error!(":between must not contain nil values") if value.any?(&:nil?)
UI.user_error!(":between must be an array of size 2") unless (value || []).size == 2
end
end),
FastlaneCore::ConfigItem.new(key: :commits_count,
env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_COUNT',
Expand Down
28 changes: 20 additions & 8 deletions fastlane/spec/actions_specs/changelog_from_git_commits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
expect(result).to eq("git log --pretty=\"%B\" v1.8.0\\(30\\)...HEAD")
end

it "Does not accept a string value for between" do
expect do
Fastlane::FastFile.new.parse("lane :test do
changelog_from_git_commits(between: 'abcd...1234')
end").runner.execute(:test)
end.to raise_error(":between must be of type array")
end

it "Does not accept a :between array of size 1" do
expect do
Fastlane::FastFile.new.parse("lane :test do
Expand Down Expand Up @@ -163,6 +155,26 @@

expect(result).to eq("git log --pretty=\"%B\" git\\ describe\\ --tags\\ \\`git\\ rev-list\\ --tags\\ --max-count\\=1\\`...HEAD")
end

it "Runs between option from command line" do
expect(system("fastlane run changelog_from_git_commits between:123456,HEAD")).to be
end

it "Accepts string value for :between" do
result = Fastlane::FastFile.new.parse("lane :test do
changelog_from_git_commits(between: 'abcd,1234')
end").runner.execute(:test)

expect(result).to eq("git log --pretty=\"%B\" abcd...1234")
end

it "Does not accept string if it does not contain comma" do
expect do
result = Fastlane::FastFile.new.parse("lane :test do
changelog_from_git_commits(between: 'abcd1234')
end").runner.execute(:test)
end.to raise_error(":between must contain comma")
end
end
end
end