-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat: adds xcodes
step
#643
Conversation
Huh, I'll check Rustfmt again. |
I am sorry @DottoDev that I accidentially hit that request review button:D, and sorry about this ping... |
src/steps/os/macos.rs
Outdated
let releases = ctx.run_type() | ||
.execute(&xcodes) | ||
.args(["update"]) | ||
.output_checked_utf8()?.stdout; |
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.
Would you like to give me a output of xcodes update
so that I can understand the code better?
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.
1.0 (7B85)
1.5 (7K571)
2.2.1 (8G1165)
2.3 (8M1780)
2.4 (8K1079)
...
15.1 Beta 2 (15C5042i)
15.1 Beta 3 (15C5059c)
15.1 (15C65)
15.2 Beta (15C5500c) (Installed)
15.2 (15C500b)
It just updates the list of releases available. As shown above, it also outputs the list at the same time. I can also run this on it's own and run xcodes list
separately if it's more visibly sensible, for now I'll put a comment explaining this.
src/steps/os/macos.rs
Outdated
if !releases_filtered | ||
.last() |
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.
It seems that I am missing something? Why are we only doing this to the .last()
one?
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.
The last one is the most recent release on the list. If it contains the "(Installed)" substring, then Xcode is fully up to date. On the contrary, it'll then ask if one would like to upgrade to the newest release.
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.
Assume xcodes update
gives the following output:
1.0 GM (0) (Installed)
1.1 GM (1)
1.4 Beta (0) (Installed)
1.5 Beta (1)
2.2.1 (0) (Installed)
2.2.2 (1)
allow_gm
, allow_beta
and allow_regular
will all be true
, releases_filtered
will contain all the listed versions, in this case, if I understand correctly, we should install 1.1 GM (1)
, 1.5 Beta (1)
and 2.2.2 (1)
all rather than only the last one?
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.
So update each release? I can do that, will commit that soon :^)
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.
So update each release?
Emm, I am sorry, I thought this was the original implementation plan :<
I can do that, will commit that soon :^)
Thanks for doing that!
Each release type will now be upgraded if a release of that type is installed. (Sorry for the messy commits, by the way) |
if releases_filtered | ||
.last() | ||
.map(|s| !s.contains("(Installed)")) | ||
.unwrap_or(true) |
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.
If releases_filtered
is empty, then .last()
will return None
, and we treat None
as true
, then we will run:
$ xcodes install <an empty string>
I believe this won't happen in reality as there are so many Xcode releases, but I believe we should check if releases_filtered
is empty or not before actually involving this function, if it is empty, we should directly return.
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.
If I remember correctly, this is already checked in it's calls, but I do agree that it is a good idea to directly return in the scenario that it is empty.
src/steps/os/macos.rs
Outdated
.filter(|release| release.contains("(Installed)")) | ||
.collect(); | ||
|
||
if should_ask && releases_new_installed.len() == 2 { |
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.
If we update every kind of Xcode, should we also do this respectively?
src/steps/os/macos.rs
Outdated
let _ = process_xcodes_releases(releases_gm, should_ask, ctx); | ||
} | ||
if installed_beta { | ||
let _ = process_xcodes_releases(releases_beta, should_ask, ctx); | ||
} | ||
if installed_regular { | ||
let _ = process_xcodes_releases(releases_regular, should_ask, ctx); |
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.
Why are we ignoring the result of process_xcodes_releases
, this could hide the possible errors
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.
That makes sense, I'll add an error checker. Should process_xcodes_releases
return a boolean indicating success?
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.
Should process_xcodes_releases return a boolean indicating success?
It already returns a Result
, which will be Err(error value)
on failure, we can simply propagate the error if happens:
let _ = process_xcodes_releases(releases_gm, should_ask, ctx); | |
} | |
if installed_beta { | |
let _ = process_xcodes_releases(releases_beta, should_ask, ctx); | |
} | |
if installed_regular { | |
let _ = process_xcodes_releases(releases_regular, should_ask, ctx); | |
process_xcodes_releases(releases_gm, should_ask, ctx)?; | |
} | |
if installed_beta { | |
process_xcodes_releases(releases_beta, should_ask, ctx)?; | |
} | |
if installed_regular { | |
process_xcodes_releases(releases_regular, should_ask, ctx)?; |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #643 +/- ##
========================================
- Coverage 5.57% 4.02% -1.56%
========================================
Files 37 32 -5
Lines 11675 5893 -5782
========================================
- Hits 651 237 -414
+ Misses 11024 5656 -5368 ☔ View full report in Codecov by Sentry. |
No need to worry about the codecov CI failures:) |
Applied those changes, but I just realized that I might want to also sort release candidates with the golden masters. Edit: Done :^) |
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!
Standards checklist:
CONTRIBUTING.md
cargo build
)cargo fmt
)cargo clippy
)cargo test
)This pull request is respondent to #630, by adding support for the tool
xcodes
, which manages Xcode versions. The step upgrades the tool directly in this order:For new steps
--dry-run
option works with this step--yes
option works with this stepif it is supported by the underlying command, the command might require an Apple ID 2FA verification to install the new release regardless