-
Notifications
You must be signed in to change notification settings - Fork 9
Adds ensure_current_branch_using_HEAD git helper #520
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
105b123
Adds ensure_current_branch_using_HEAD git helper
oguzkocer 37e6182
Adds unit tests for ensure_current_branch_using_HEAD git helper
oguzkocer dd816ab
Deprecate ensure_on_branch! git helper
oguzkocer 0b0669c
Adds changelog for ensure_current_branch_using_HEAD
oguzkocer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the name of the method is up for discussion, I'll wait until it's resolved to address this lint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I get that this method relies on
current_branch_name_using_HEADand that's probably what the name you picked come from, I think this is a bit over-verbose (and would make it named like this mostly only as a counterpoint to the fastlane one that uses env vars, while we should already in our own implementations inrelease-toolkitthat we don't want to rely on ENV vars, so imho the precision in the naming is likely unnecessary)As such, I'd suggest just
ensure_current_branch!— the!in the name being a common Ruby convention to indicate that the method will crash on purpose / interrupt the code and exit if the precondition is not met.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, given
branchis taken as a regex, I'd make this explicit in the parameter name. Finally, I'd also suggest to use keyword parameters rather than just positional parameters, to enforce the call site having to provide the parameter name and make it even more explicit that this is a RegExp pattern.or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I like the
ensure_on_branch!method name, so I wonder if we shouldn't instead keep that method, update its implementation, and just fix all the call sites.After all, (1) this method being a helper, it's expected to only be used internally by the
release-toolkit, not externally (as things that are meant to be used externally should be made into actions), so changing its behavior/implementation should only affect therelease-toolkititself, not its clients and (2) the only usages I see ofensure_on_branch!in therelease-toolkitare 4 occurrences, which all look likeensure_on_branch!('release'), and which would be easy to change toensure_on_branch!(pattern: '^release/')to match the new behavior of usingcurrent_branch.match?(/#{pattern}/).That way, no deprecation needed, still having a nice name for that helper, and making it more robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if that's the expectation - it's very likely that it's used in the clients so I don't think we should do that. This work is something that popped up as something extra and I want to finish it as quickly as I can to focus on my project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then another option would be to make the existing
ensure_on_branch!keep the same (legacy) implementation (withinclude?if the parameter is aString(for backwards compatibility, until we stop the client projects from using the helper directly, which they shouldn't do), and use the new implementation if the parameter is aRegExp.