Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Find and use the correct schema #57

Merged
merged 1 commit into from
Dec 17, 2018
Merged

Find and use the correct schema #57

merged 1 commit into from
Dec 17, 2018

Conversation

johnrogers
Copy link
Contributor

@johnrogers johnrogers commented Dec 13, 2018

You can see my motivation for creating this pull request here: #56

In my case, scheme_conf = conf.first was not sufficient enough to locate the scheme - the key-pair __xctestrun_metadata__ comes first in my xctestrun file.

It seems to me, in any case, it's safer to look for the schema that's not __xctestrun_metadata__ after performing the bundle size check?

I'm not very experienced with Ruby - created this to offer a possible solution.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@johnrogers
Copy link
Contributor Author

johnrogers commented Dec 13, 2018 via email

@googlebot
Copy link

CLAs look good, thanks!

@MartyCatawiki
Copy link
Contributor

I didn't realise that the __xctestrun_metadata__ could be situated as first key, so this looks like a nice solution. I tested it and it works also for my files where the key is situated as the last one. I'm not into Ruby either, so it would be nice that @powerivq can check the code too.

_, scheme_conf = conf.first

scheme_conf = nil
conf.each_key { |key|
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use conf.each since you need the value as well (rather than conf[key]).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. I've updated the commit.

conf.each_key { |key|
if key != '__xctestrun_metadata__'
scheme_conf = conf[key]
end
Copy link
Contributor

Choose a reason for hiding this comment

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

We can move the line 22 logic here:

if scheme_conf.nil?
  scheme_conf = value
else
  UI.user_error!("The app bundle may contain only one scheme.")
end

Copy link
Contributor Author

@johnrogers johnrogers Dec 13, 2018

Choose a reason for hiding this comment

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

Yes! Nice. I've force-pushed an update. Check it out.

I've used your suggestion, however in the body of the if we still need to check if the key is __xctestrun_metadata__, otherwise that schema will be set first if it's encountered first. :)

@powerivq
Copy link
Contributor

@johnrogers thanks for the help! have some minor comments but otherwise look good!

@johnrogers
Copy link
Contributor Author

johnrogers commented Dec 13, 2018

No problem at all @powerivq . Happy to help contribute to the development of great software.

scheme_conf = nil
conf.each do |key, value|
if scheme_conf.nil?
unless key == '__xctestrun_metadata__'
Copy link
Contributor

Choose a reason for hiding this comment

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

This "unless" needs to be outside of the if block. If you got an input:
ARandomScheme
xctestrun_metadata

It will cause the one-scheme-only error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair comment.

I've re-introduced the size check and fixed this up.

Copy link

@armcburney armcburney left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

@powerivq powerivq merged commit 16cafa3 into FirebaseExtended:master Dec 17, 2018
@powerivq
Copy link
Contributor

@johnrogers 1.0.2 is released to rubygem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants