Exception: Git::VersionError

Inherits:
Error
  • Object
show all
Defined in:
lib/git/errors.rb

Overview

Raised when the installed git version does not meet requirements

This error is raised when:

  • The installed git version is below Git::MINIMUM_GIT_VERSION
  • A command requires a minimum git version that isn't met
  • A command was removed in a git version older than the installed version

Examples:

Rescuing a version error

begin
  git.some_command
rescue Git::VersionError => e
  puts "Git version #{e.actual_version} does not meet requirements"
  puts "  #{e.subject}: requires #{e.constraint}"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject:, constraint:, actual_version:) ⇒ VersionError

Create a VersionError

Parameters:

  • subject (#to_s)

    the entity with the version requirement (e.g., "The git gem", a Class)

  • constraint (Git::VersionConstraint)

    the version constraint that was violated

  • actual_version (Git::Version)

    the installed git version



240
241
242
243
244
245
# File 'lib/git/errors.rb', line 240

def initialize(subject:, constraint:, actual_version:)
  @subject = subject
  @constraint = constraint
  @actual_version = actual_version
  super(build_message)
end

Instance Attribute Details

#actual_versionGit::Version (readonly)

The installed git version that caused the error

Returns:



263
264
265
# File 'lib/git/errors.rb', line 263

def actual_version
  @actual_version
end

#constraintGit::VersionConstraint (readonly)

The version constraint that was violated



257
258
259
# File 'lib/git/errors.rb', line 257

def constraint
  @constraint
end

#subject#to_s (readonly)

The entity that has the version requirement

Returns:

  • (#to_s)


251
252
253
# File 'lib/git/errors.rb', line 251

def subject
  @subject
end