-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add handling of origin
to method point_to_same_commit?
#590
Conversation
origin
to method point_to_same_commit?
origin
to method point_to_same_commit?
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.
Interesting. CI reports failures in tests that are stubbing point_to_same_commit?
(a good case for avoiding stubs, however that's easier said than done in this repo...).
Example:
FastlaneCore::Helper::GitHelper received :point_to_same_commit? with unexpected arguments
| expected: ("origin/release/30.6", "origin/release/30.7")
| got: ("trunk", "release/30.7")
| Please stub a default value first if message might be received with other args as well.
7b9ca71
to
9d1f017
Compare
True, I should've updated - allow(Fastlane::Helper::GitHelper).to receive(:point_to_same_commit?).with("origin/#{target_branch}", "origin/#{source_branch}").and_return(point_to_same_commit)
+ allow(Fastlane::Helper::GitHelper).to receive(:point_to_same_commit?).with(target_branch, source_branch).and_return(point_to_same_commit) It should be fixed now. |
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.
Only a non-blocking suggestion for clarity in the tests.
spec/git_helper_spec.rb
Outdated
@@ -145,37 +145,37 @@ | |||
end | |||
|
|||
it 'checks if a tag and a branch point to the same commit' do | |||
same_commit = described_class.point_to_same_commit?('1.0', 'another-branch') | |||
same_commit = described_class.point_to_same_commit?('1.0', 'another-branch', remote_name: nil) |
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.
Added a test using remote_name: 'origin'
,
it 'checks if commits between the same branch point to the same commit' do
same_commit = described_class.point_to_same_commit?('feature-branch', 'feature-branch', remote_name: 'origin')
expect(same_commit).to be true
end
And got this failure:
1) FastlaneCore::Helper::GitHelper point_to_same_commit?(ref1, ref2) checks if commits between the same branch point to the same commit
Failure/Error: ref1_commit.sha == ref2_commit.sha
Git::FailedError:
git '--git-dir=/private/var/folders/dq/cdqxvx3s5ps75564rpmb_dc00000gn/T/d20240906-32427-fzffvl/.git' '--work-tree=/private/var/folders/dq/cdqxvx3s5ps75564rpmb_dc00000gn/T/d20240906-32427-fzffvl' '-c' 'core.quotePath=true' '-c' 'color.ui=false' 'rev-parse' 'origin/feature-branch' 2>&1
status: pid 32722 exit 128
output: "fatal: ambiguous argument 'origin/feature-branch': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\norigin/feature-branch\n"
I think that's expected because the local branches used in this test do not have a remote. Am I right?
What do you think of adding a note about this, e.g. at the start of the context
(why not describe
?) for this method.
# We cannot test the happy using a remote name because the repo we use for the tests does not have a remote.
let(:remote_name) { nil }
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.
Great suggestions, thanks! Updated on 36cd7bc.
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.
Thanks for following up @iangmaia !
What does it do?
Starting from the comment #587 (comment), I realized we already have checks and logic in place to make sure the head and base branches start with
release/
and that it would make more sense to have any logic related to thepoint_to_same_commit?
check locally vs. on remote in the method itself, so this PR updatespoint_to_same_commit?
for that.Checklist before requesting a review
bundle exec rubocop
to test for code style violations and recommendationsspecs/*_spec.rb
) if applicablebundle exec rspec
to run the whole test suite and ensure all your tests passCHANGELOG.md
file to describe your changes under the appropriate existing###
subsection of the existing## Trunk
section.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.