Skip to content

Commit

Permalink
feat: raise errors when versions are not supported
Browse files Browse the repository at this point in the history
There were scenarios where an upgrade was not compatible because of
peerDependencies not being valid.  This caused the version to be
upgraded to a lower version than what we intended.  Instead
of allowing that to happen, we will now raise an error that communicates
why we were not able to upgrade to the newer version.
  • Loading branch information
kylemellander committed Oct 1, 2024
1 parent 9a784b1 commit c981a82
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions deploy/lib/deployer/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,16 @@ class AutoMergeFailure < BaseError

class VersionCompareFailure < BaseError
end

class RequirementsNotMet < BaseError
def initialize(version)
super(build_message(version))
end

def build_message(version)
"Upgrade does not satisfy requirements. The latest upgradable verison is #{version}. " \
"Verify that the requirement allows for an upgrade to this version and check that all " \
"peer dependencies are satisfied."
end
end
end
13 changes: 13 additions & 0 deletions deploy/lib/deployer/repo/dependabot_pull_request_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Repo
class DependabotPullRequestUpdater < PullRequestUpdater
def run
setup_runner
verify_upgrade_satisfies
create_pr
automerge_pr if config.automerge
end
Expand Down Expand Up @@ -198,6 +199,18 @@ def sanitize_yarnrc_yml(fetcher)
yarnrc_yml_file.content =
yarnrc_yml_file.content.gsub("yarnPath:", "# yarnPath:")
end

def verify_upgrade_satisfies
if Gem::Version.new(resolvable_version) >= Gem::Version.new(version)
return
end

raise RequirementsNotMet, resolvable_version
end

def resolvable_version
checker.latest_resolvable_version
end
end
end
end

0 comments on commit c981a82

Please sign in to comment.