Skip to content
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

Report active Ruby version #95

Merged
merged 11 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func (f FastlaneRunner) getWorkDir(config Config) (string, error) {
func (f FastlaneRunner) checkForRbenv(workDir string) {
f.logger.Println()
f.logger.Infof("Checking rbenv version")
if _, err := f.cmdLocator.LookPath("rbenv"); err != nil {
if _, err := f.cmdLocator.LookPath("rbenv"); err == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The err check needs to be flipped


cmd := f.rbyFactory.Create("rbenv", []string{"versions"}, &command.Opts{
Stderr: os.Stderr,
Stdout: os.Stdout,
Expand All @@ -194,6 +195,8 @@ func (f FastlaneRunner) checkForRbenv(workDir string) {
if err := cmd.Run(); err != nil {
f.logger.Warnf(err.Error())
}
} else {
f.logger.Warnf("rbenv not found: %s", err)
}
}

Expand Down
30 changes: 30 additions & 0 deletions dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"os"
"strings"

"github.com/bitrise-io/go-utils/v2/command"
)
Expand All @@ -16,6 +17,8 @@ type EnsureDependenciesOpts struct {

// InstallDependencies ...
func (f FastlaneRunner) InstallDependencies(opts EnsureDependenciesOpts) error {
f.reportRubyVersion(opts.UseBundler, opts.GemVersions.bundler.Version)

// Install desired Fastlane version
if opts.UseBundler {
f.logger.Println()
Expand Down Expand Up @@ -99,3 +102,30 @@ func (f FastlaneRunner) InstallDependencies(opts EnsureDependenciesOpts) error {

return nil
}

func (f FastlaneRunner) reportRubyVersion(useBundler bool, bundlerVersion string) {
var versionCmd command.Command
if useBundler {
versionCmd = f.rbyFactory.CreateBundleExec("ruby", []string{"--version"}, bundlerVersion, nil)
ofalvai marked this conversation as resolved.
Show resolved Hide resolved
} else {
versionCmd = f.rbyFactory.Create("ruby", []string{"--version"}, nil)
}
output, err := versionCmd.RunAndReturnTrimmedCombinedOutput()
if err != nil {
f.logger.Warnf("Failed to check active Ruby version: %s", err)
f.logger.Printf("Output: %s", output)
return
}
// Example output:
// ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22]
versionSlice := strings.Split(output, " ")
if len(versionSlice) < 2 {
f.logger.Warnf("Unrecognized Ruby version: %s", versionSlice)
}
version := versionSlice[1]

f.logger.Println()
f.logger.Infof("Active Ruby version: %s", version)

logRubyVersion(version)
}
5 changes: 5 additions & 0 deletions tracker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

func logRubyVersion(versionString string) {

}