Class: Git::Status Deprecated
- Inherits:
-
Object
- Object
- Git::Status
- Includes:
- Enumerable
- Defined in:
- lib/git/status.rb,
lib/git/status.rb,
lib/git/status.rb
Overview
Use StatusInfo, returned by Repository#status_info, instead; this class will be removed in v6.0.0
The Status class gets the status of a git repository. It identifies which files have been modified, added, or deleted, including untracked files. The Status object is an Enumerable of StatusFile objects.
Defined Under Namespace
Classes: StatusFile, StatusFileFactory
Instance Method Summary collapse
-
#[](file) ⇒ Git::Status::StatusFile?
Return the StatusFile for the given path.
-
#added ⇒ Hash{String => Git::Status::StatusFile}
Return files added to the index that are not yet in HEAD.
-
#added?(file) ⇒ Boolean
Return
trueiffilehas been added to the index. -
#changed ⇒ Hash{String => Git::Status::StatusFile}
Return files modified in the index and/or working tree.
-
#changed?(file) ⇒ Boolean
Return
trueiffilehas been modified in the index or working tree. -
#deleted ⇒ Hash{String => Git::Status::StatusFile}
Return files deleted from the index.
-
#deleted?(file) ⇒ Boolean
Return
trueiffilehas been deleted from the index. -
#each
Iterate over all status files.
-
#initialize(base) ⇒ Status
constructor
deprecated
Deprecated.
Use Repository#status_info instead
-
#pretty ⇒ String
Return a formatted multi-line string representation of the status.
-
#untracked ⇒ Hash{String => Git::Status::StatusFile}
Return files present in the working tree but not tracked by git.
-
#untracked?(file) ⇒ Boolean
Return
trueiffileis not tracked by git.
Constructor Details
#initialize(base) ⇒ Status
Use Repository#status_info instead
Create a new Status for the given repository
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git/status.rb', line 30 def initialize(base) if defined?(Git::Deprecation) Git::Deprecation.warn( 'Git::Status is deprecated and will be removed in v6.0.0. ' \ 'Use Git::Repository#status_info instead.' ) end @base = base # The factory returns a hash of file paths to StatusFile objects. @files = StatusFileFactory.new(base).construct_files end |
Instance Method Details
#[](file) ⇒ Git::Status::StatusFile?
Return the StatusFile for the given path
107 |
# File 'lib/git/status.rb', line 107 def [](file) = @files[file] |
#added ⇒ Hash{String => Git::Status::StatusFile}
Return files added to the index that are not yet in HEAD
55 |
# File 'lib/git/status.rb', line 55 def added = @added ||= select_files { |f| f.type == 'A' } |
#added?(file) ⇒ Boolean
Return true if file has been added to the index
83 |
# File 'lib/git/status.rb', line 83 def added?(file) = file_in_collection?(:added, file) |
#changed ⇒ Hash{String => Git::Status::StatusFile}
Return files modified in the index and/or working tree
Includes both staged modifications (index vs HEAD) and unstaged modifications (working tree vs index).
49 |
# File 'lib/git/status.rb', line 49 def changed = @changed ||= select_files { |f| f.type == 'M' } |
#changed?(file) ⇒ Boolean
Return true if file has been modified in the index or working tree
75 |
# File 'lib/git/status.rb', line 75 def changed?(file) = file_in_collection?(:changed, file) |
#deleted ⇒ Hash{String => Git::Status::StatusFile}
Return files deleted from the index
61 |
# File 'lib/git/status.rb', line 61 def deleted = @deleted ||= select_files { |f| f.type == 'D' } |
#deleted?(file) ⇒ Boolean
Return true if file has been deleted from the index
91 |
# File 'lib/git/status.rb', line 91 def deleted?(file) = file_in_collection?(:deleted, file) |
#each ⇒ Enumerator<Git::Status::StatusFile> #each {|file| ... } ⇒ Array<Git::Status::StatusFile>
Iterate over all status files
125 |
# File 'lib/git/status.rb', line 125 def each(&) = @files.values.each(&) |
#pretty ⇒ String
Return a formatted multi-line string representation of the status
132 133 134 |
# File 'lib/git/status.rb', line 132 def pretty map { |file| pretty_file(file) }.join << "\n" end |
#untracked ⇒ Hash{String => Git::Status::StatusFile}
Return files present in the working tree but not tracked by git
67 |
# File 'lib/git/status.rb', line 67 def untracked = @untracked ||= select_files(&:untracked) |
#untracked?(file) ⇒ Boolean
Return true if file is not tracked by git
99 |
# File 'lib/git/status.rb', line 99 def untracked?(file) = file_in_collection?(:untracked, file) |