Class: V::Adapters::Git::Index

Inherits:
Object
  • Object
show all
Includes:
V::Adapters::Git
Defined in:
lib/v/adapters/git/index.rb

Overview

Constant Summary

Constants included from V::Adapters::Git

VERSION

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Index

Returns a new instance of Index.



8
9
10
# File 'lib/v/adapters/git/index.rb', line 8

def initialize(environment)
  @environment = environment
end

Instance Method Details

#+(other) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/v/adapters/git/index.rb', line 21

def +(other)
  raise NotImplementedError, 'TODO: implement Index#+(other)'
end

#-(other) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/v/adapters/git/index.rb', line 25

def -(other)
  other.is_a? Git::Object or
  raise ArgumentError, 'expected Git::Object'

  name = case other
  when Commit
    other.name
  when Tree
    other.name
  when Tag
    other.name
  when Blob
    raise NotImplementedError, 'TODO: implement Index#-(other)'
  else raise p(other)
  end

  @environment.diff_index name,
      :name_status => true, :cached => true do |out, err|
    Status.new out
  end
end

#add(*files) ⇒ Object Also known as: <<



12
13
14
# File 'lib/v/adapters/git/index.rb', line 12

def add(*files)
  @environment.add *files
end

#commit(*args) ⇒ Object



47
48
49
# File 'lib/v/adapters/git/index.rb', line 47

def commit(*args)
  @environment.commit *args
end

#include?(filename) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/v/adapters/git/index.rb', line 17

def include?(filename)
  @environment.ls_files(filename) !~ /^\s*$/
end

#reset(*args) ⇒ Object



50
51
52
# File 'lib/v/adapters/git/index.rb', line 50

def reset(*args)
  @environment.reset *args
end