Class: Bringit::RevList

Inherits:
Object
  • Object
show all
Defined in:
lib/bringit/rev_list.rb

Constant Summary collapse

ALLOWED_VARIABLES =
%w[GIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIES].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oldrev, newrev, repository:, env: nil) ⇒ RevList

Returns a new instance of RevList.



7
8
9
10
11
12
13
14
15
16
# File 'lib/bringit/rev_list.rb', line 7

def initialize(oldrev, newrev, repository:, env: nil)
  @repository = repository
  @env = env.presence || {}
  @args = ["git",
            "--git-dir=#{repository.path}",
            "rev-list",
            "--max-count=1",
            oldrev,
            "^#{newrev}"]
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



3
4
5
# File 'lib/bringit/rev_list.rb', line 3

def env
  @env
end

#repositoryObject (readonly)

Returns the value of attribute repository.



3
4
5
# File 'lib/bringit/rev_list.rb', line 3

def repository
  @repository
end

Instance Method Details

#executeObject



18
19
20
# File 'lib/bringit/rev_list.rb', line 18

def execute
  Bringit::Popen.popen(@args, nil, parse_environment_variables)
end

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/bringit/rev_list.rb', line 22

def valid?
  environment_variables.all? do |(name, value)|
    value.to_s.start_with?(repository.path)
  end
end