Skip to content

Commit

Permalink
TOOL-30 Updated to check for gems.locked. (#56)
Browse files Browse the repository at this point in the history
* TOOL-30 Updated to check for gems.locked.

* TOOL-30 Dep update.

* TOOL-30 Log update.
  • Loading branch information
richard-bogdan-bitrise authored and godrei committed Nov 8, 2019
1 parent 34056f1 commit 83813b4
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.bitrise*
_tmp
.idea
29 changes: 9 additions & 20 deletions gemfile_lock.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
package main

import (
"fmt"
"path/filepath"

"github.com/bitrise-io/go-utils/command/gems"
"github.com/bitrise-io/go-utils/fileutil"
"github.com/bitrise-io/go-utils/log"
"github.com/bitrise-io/go-utils/pathutil"
)

type gemVersions struct {
fastlane, bundler gems.Version
}

func parseGemfileLock(searchDir string) (gemVersions, error) {
gemfileLockPth := filepath.Join(searchDir, "Gemfile.lock")
log.Printf("Checking Gemfile.lock (%s) for fastlane and bundler gem", gemfileLockPth)

if exist, err := pathutil.IsPathExists(gemfileLockPth); err != nil {
return gemVersions{}, fmt.Errorf("failed to check if Gemfile.lock exist at (%s), error: %s", gemfileLockPth, err)
} else if !exist {
log.Printf("Gemfile.lock does not exist")
return gemVersions{}, nil
}

content, err := fileutil.ReadStringFromFile(gemfileLockPth)
content, err := gems.GemFileLockContent(searchDir)
if err != nil {
if err == gems.ErrGemLockNotFound {
log.Printf("Gem lockfile does not exist")
return gemVersions{}, nil
}
return gemVersions{}, err
}

Expand All @@ -37,19 +26,19 @@ func parseGemfileLock(searchDir string) (gemVersions, error) {
return gemVersions, err
}
if gemVersions.fastlane.Found {
log.Infof("Gemfile.lock defined fastlane version: %s", gemVersions.fastlane.Version)
log.Infof("Gem lockfile defined Fastlane version: %s", gemVersions.fastlane.Version)
} else {
log.Infof("No fastlane version defined in Gemfile.lock")
log.Infof("No Fastlane version defined in gem lockfile")
}

gemVersions.bundler, err = gems.ParseBundlerVersion(content)
if err != nil {
return gemVersions, err
}
if gemVersions.bundler.Found {
log.Infof("Gemfile.lock defined bundler version: %s", gemVersions.bundler.Version)
log.Infof("Gem lockfile defined bundler version: %s", gemVersions.bundler.Version)
} else {
log.Infof("No bundler version defined in Gemfile.lock")
log.Infof("No bundler version defined in gem lockfile")
}

return gemVersions, nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/bitrise-io/bitrise-init v0.0.0-20190813135927-7ff42ba329cb
github.com/bitrise-io/envman v0.0.0-20190813133714-27a300a1ed43 // indirect
github.com/bitrise-io/go-steputils v0.0.0-20190806143347-f540824d77df
github.com/bitrise-io/go-utils v0.0.0-20190814105345-ad86bf775472
github.com/bitrise-io/go-utils v0.0.0-20191108114511-5067a2a682f2
github.com/bitrise-io/go-xcode v0.0.0-20190718082554-07ccf582b6b1 // indirect
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27 // indirect
github.com/bitrise-io/stepman v0.0.0-20190813144014-10564a4888a6 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/bitrise-io/go-steputils v0.0.0-20190806143347-f540824d77df h1:UaDw6nA
github.com/bitrise-io/go-steputils v0.0.0-20190806143347-f540824d77df/go.mod h1:GXgBV3Frd3qcnsg+NryQTyx1CHjZHr/2w7Bx4WAcB4o=
github.com/bitrise-io/go-utils v0.0.0-20190814105345-ad86bf775472 h1:jM4pIBkBUOucinQ2IdlfbpIZxJqgS/k1TZZrENFej8A=
github.com/bitrise-io/go-utils v0.0.0-20190814105345-ad86bf775472/go.mod h1:Pp48eQd8BSNEzWWTBxdFUd/ufS5b5Bgkmt9D5NedjWg=
github.com/bitrise-io/go-utils v0.0.0-20191108114511-5067a2a682f2 h1:8tMyx5oOXSeVEG5VCxfLmwcqYEApVHKn/y6vU7an1Z8=
github.com/bitrise-io/go-utils v0.0.0-20191108114511-5067a2a682f2/go.mod h1:Pp48eQd8BSNEzWWTBxdFUd/ufS5b5Bgkmt9D5NedjWg=
github.com/bitrise-io/go-xcode v0.0.0-20190718082554-07ccf582b6b1 h1:Om1A4iSAyR4G8sEi1VYRfJrEHbmskSpeSeK0+uAVqqc=
github.com/bitrise-io/go-xcode v0.0.0-20190718082554-07ccf582b6b1/go.mod h1:EFvdJln2CESNPSz2+ChAGOtfHNN/l56csk1nuRnz8nI=
github.com/bitrise-io/goinp v0.0.0-20190611131639-bd18a8681e27 h1:NuGIfwKcZvdR1RT4sQ32kE8h35w9XQjQrrCJPJqS4ek=
Expand Down
12 changes: 12 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/command/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/command/gems/gemfile_lock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/bitrise-io/go-utils/log/severity.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ github.com/bitrise-io/envman/models
github.com/bitrise-io/go-steputils/cache
github.com/bitrise-io/go-steputils/stepconf
github.com/bitrise-io/go-steputils/tools
# github.com/bitrise-io/go-utils v0.0.0-20190814105345-ad86bf775472
# github.com/bitrise-io/go-utils v0.0.0-20191108114511-5067a2a682f2
github.com/bitrise-io/go-utils/command
github.com/bitrise-io/go-utils/command/gems
github.com/bitrise-io/go-utils/command/rubycommand
Expand Down

0 comments on commit 83813b4

Please sign in to comment.