Skip to content

Add exclude parameter to find_previous_tag action#696

Merged
iangmaia merged 5 commits intotrunkfrom
iangmaia/add-exclude-param-to-find-previous-tag
Feb 24, 2026
Merged

Add exclude parameter to find_previous_tag action#696
iangmaia merged 5 commits intotrunkfrom
iangmaia/add-exclude-param-to-find-previous-tag

Conversation

@iangmaia
Copy link
Contributor

@iangmaia iangmaia commented Feb 24, 2026

Fixes AINFRA-2056

What does it do?

Adds an optional exclude parameter to the find_previous_tag action that maps to git's --exclude flag, allowing callers to skip beta/pre-release tags when searching for the previous stable release tag — e.g. find_previous_tag(pattern: 'v*', exclude: '*beta*').

Checklist before requesting a review

  • Run bundle exec rubocop to test for code style violations and recommendations.
  • Add Unit Tests (aka specs/*_spec.rb) if applicable.
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass.
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the MIGRATION.md file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.

@iangmaia iangmaia self-assigned this Feb 24, 2026
@iangmaia iangmaia added the enhancement New feature or request label Feb 24, 2026
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock but while we're here I wonder if we shouldn't allow multiple exclude patterns (by allowing to pass an array to the argument/ConfigItem), for example if we want to exclude both -alpha* and -beta* patterns 🤔

@iangmaia iangmaia force-pushed the iangmaia/add-exclude-param-to-find-previous-tag branch from 0d5c716 to 4208ed7 Compare February 24, 2026 12:53
@iangmaia
Copy link
Contributor Author

Approving to unblock but while we're here I wonder if we shouldn't allow multiple exclude patterns (by allowing to pass an array to the argument/ConfigItem), for example if we want to exclude both -alpha* and -beta* patterns 🤔

Great idea! Added on 4208ed7.

'Can be a single string or an array of strings',
optional: true,
default_value: nil,
is_string: false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of is_string: is deprecated in ConfigItem, and has been replaced by type: instead.

Suggested change
is_string: false),
type: Array),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed, though the type could be a string as well (single string or Array)... will that work with type? 🤔 Or better to restrict it to be always an array?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe if the ConfigItem's type is Array but you pass a String it gets auto-converted into an array and validation should thus pass in those cases too.

Though wouldn't hurt to add a small spec example if you want to ensure this case is covered as expected anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated on d09c29d, enforcing it to be always array (thinking about it, it's fine as it's a new parameter anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and the auto-conversion works! 4121687 (chef's kiss)

Comment on lines +100 to +114
it 'auto-converts a single exclude string into an array' do
# Arrange
stub_current_commit_tag(nil)
stub_main_command(
%w[git describe --tags --abbrev=0 --match v* --exclude *beta*],
stdout: 'v1.7.3'
)
# Act — Fastlane's ConfigItem auto-converts a String to Array when type is Array
tag = run_described_fastlane_action(
pattern: 'v*',
exclude: '*beta*'
)
# Assert
expect(tag).to eq('v1.7.3')
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have that confirmed by a unit test 👍

@iangmaia iangmaia merged commit 0a4a20f into trunk Feb 24, 2026
6 checks passed
@iangmaia iangmaia deleted the iangmaia/add-exclude-param-to-find-previous-tag branch February 24, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants