Class: Git::Status::StatusFile Deprecated

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

Overview

Deprecated.

Use Git::StatusFileInfo, held by Git::StatusInfo#files, instead; this class will be removed in v6.0.0

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.

API:

  • public

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, hash) ⇒ StatusFile

Initialize a new StatusFile with the given git object and data hash

Parameters:

  • the git object

  • raw status data for this file

API:

  • public



272
273
274
275
276
277
278
279
280
281
282
# File 'lib/git/status.rb', line 272

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_indexString? (readonly)

The file mode recorded in the index

Returns:

  • the octal file mode (e.g. "100644"), or nil

API:

  • public



244
245
246
# File 'lib/git/status.rb', line 244

def mode_index
  @mode_index
end

#mode_repoString? (readonly)

The file mode recorded in HEAD

Returns:

  • the octal file mode (e.g. "100644"), or nil

API:

  • public



249
250
251
# File 'lib/git/status.rb', line 249

def mode_repo
  @mode_repo
end

#pathString (readonly)

The repository-relative file path

Returns:

  • the path

API:

  • public



227
228
229
# File 'lib/git/status.rb', line 227

def path
  @path
end

#sha_indexString? (readonly)

The SHA of the index version of this file

Returns:

  • the SHA-1 hex digest, or nil if unavailable

API:

  • public



254
255
256
# File 'lib/git/status.rb', line 254

def sha_index
  @sha_index
end

#sha_repoString? (readonly)

The SHA of the HEAD version of this file

Returns:

  • the SHA-1 hex digest, or nil if unavailable

API:

  • public



259
260
261
# File 'lib/git/status.rb', line 259

def sha_repo
  @sha_repo
end

#stageString? (readonly)

The merge stage for this file

Returns:

  • "0" for normal entries, or a non-zero value during a merge conflict

API:

  • public



239
240
241
# File 'lib/git/status.rb', line 239

def stage
  @stage
end

#typeString? (readonly)

The change type for this file

Returns:

  • "M" for modified, "A" for added, "D" for deleted, or nil when not applicable

API:

  • public



233
234
235
# File 'lib/git/status.rb', line 233

def type
  @type
end

#untrackedBoolean? (readonly)

Whether this file is untracked

Returns:

  • true when the file is not tracked by git

API:

  • public



264
265
266
# File 'lib/git/status.rb', line 264

def untracked
  @untracked
end

Instance Method Details

#blob(type = :index) ⇒ Git::Object::Blob?

Return a blob object for the index or repo version of this file

Parameters:

  • (defaults to: :index)

    :index (default) for the index version, or :repo for the HEAD version

Returns:

  • the blob object, or nil if no SHA is available for the requested version

API:

  • public



292
293
294
295
# File 'lib/git/status.rb', line 292

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