Skip to content
Merged
Changes from 2 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
13 changes: 11 additions & 2 deletions pub/lib/dependabot/pub/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "digest"

require "dependabot/errors"
require "dependabot/logger"
require "dependabot/shared_helpers"
require "dependabot/pub/requirement"

Expand Down Expand Up @@ -106,6 +107,11 @@ def check_out_flutter_ref(ref)
def ensure_right_flutter_release
@ensure_right_flutter_release ||= begin
versions = Helpers.run_infer_sdk_versions url: options[:flutter_releases_url]
if versions
Dependabot.logger.info(prefixed_log_message("Installing the Flutter SDK version: #{versions['flutter']} from channel #{versions['channel']} with Dart #{versions['dart']}"))
else
Dependabot.logger.info(prefixed_log_message("Failed to infer the flutter version. Attempting to use latest stable release."))
end
flutter_ref = if versions
"refs/tags/#{versions['flutter']}"
else
Expand Down Expand Up @@ -138,9 +144,12 @@ def ensure_right_flutter_release
end

parsed = JSON.parse(stdout)
flutter_version = parsed["frameworkVersion"]
dart_version = parsed["dartSdkVersion"].split.first

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
dart_version = parsed["dartSdkVersion"].split.first
dart_version = parsed["dartSdkVersion"]&.split&.first

Should we add this to safe-guard against parsed["dartSdkVersion"] being nil? This would now raise an error if it's nil.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should always have a dart version. I made the check such that the error message will become nicer.

Dependabot.logger.info(prefixed_log_message("Installed the Flutter SDK version: #{flutter_version} with Dart #{dart_version}."))
{
"flutter" => parsed["frameworkVersion"],
"dart" => parsed["dartSdkVersion"].split.first
"flutter" => flutter_version,
"dart" => dart_version
}
end
end
Expand Down