Class: Git::Status::StatusFile

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

Overview

Represents a single file's status in the git repository. Each instance holds information about a file's state in the index and working tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, hash) ⇒ StatusFile

Returns a new instance of StatusFile.



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/status.rb', line 94

def initialize(base, hash)
  @base       = base
  @path       = hash[:path]
  @type       = hash[:type]
  @stage      = hash[:stage]
  @mode_index = hash[:mode_index]
  @mode_repo  = hash[:mode_repo]
  @sha_index  = hash[:sha_index]
  @sha_repo   = hash[:sha_repo]
  @untracked  = hash[:untracked]
end

Instance Attribute Details

#mode_index (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def mode_index
  @mode_index
end

#mode_repo (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def mode_repo
  @mode_repo
end

#path (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def path
  @path
end

#sha_index (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def sha_index
  @sha_index
end

#sha_repo (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def sha_repo
  @sha_repo
end

#stage (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def stage
  @stage
end

#type (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def type
  @type
end

#untracked (readonly)



91
92
93
# File 'lib/git/status.rb', line 91

def untracked
  @untracked
end

Instance Method Details

#blob(type = :index)

Returns a Git::Object::Blob for either the index or repo version of the file.



107
108
109
110
# File 'lib/git/status.rb', line 107

def blob(type = :index)
  sha = type == :repo ? sha_repo : (sha_index || sha_repo)
  @base.object(sha) if sha
end