Class: RubyGit::Status::Entry
- Inherits:
-
Object
- Object
- RubyGit::Status::Entry
- Defined in:
- lib/ruby_git/status/entry.rb
Overview
Base class for git status entries
Direct Known Subclasses
IgnoredEntry, OrdinaryEntry, RenamedEntry, UnmergedEntry, UntrackedEntry
Constant Summary collapse
- STATUS_CODES =
Status code mapping to symbols
{ '.': :unmodified, M: :modified, T: :type_changed, A: :added, D: :deleted, R: :renamed, C: :copied, U: :updated_but_unmerged, '?': :untracked, '!': :ignored }.freeze
- RENAME_OPERATIONS =
Rename operation mapping to symbols
{ 'R' => :rename # git status doesn't actually try to detect copies # 'C' => :copy }.freeze
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
The path of the file.
Class Method Summary collapse
-
.rename_operation_to_symbol(code) ⇒ Symbol
Convert a rename operation to a symbol.
-
.status_to_symbol(code) ⇒ Symbol
Convert a status code to a symbol.
Instance Method Summary collapse
-
#fully_staged? ⇒ Boolean
Does the entry have staged changes in the index with no unstaged changes?.
-
#ignored? ⇒ Boolean
Is the entry an ignored file?.
-
#index_status ⇒ Symbol?
Get the staging status.
-
#initialize(path) ⇒ Entry
constructor
Initialize a new entry.
-
#staged? ⇒ Boolean
Does the entry have staged changes in the index?.
-
#unmerged? ⇒ Boolean
Does the entry represent a merge conflict?.
-
#unstaged? ⇒ Boolean
Does the entry have unstaged changes in the worktree?.
-
#untracked? ⇒ Boolean
Is the entry an untracked file?.
-
#worktree_status ⇒ Symbol?
Get the worktree status.
Constructor Details
#initialize(path) ⇒ Entry
Initialize a new entry
48 49 50 |
# File 'lib/ruby_git/status/entry.rb', line 48 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ String (readonly)
The path of the file
39 40 41 |
# File 'lib/ruby_git/status/entry.rb', line 39 def path @path end |
Class Method Details
.rename_operation_to_symbol(code) ⇒ Symbol
Convert a rename operation to a symbol
72 73 74 |
# File 'lib/ruby_git/status/entry.rb', line 72 def self.rename_operation_to_symbol(code) RENAME_OPERATIONS[code] || :unknown end |
.status_to_symbol(code) ⇒ Symbol
Convert a status code to a symbol
60 61 62 |
# File 'lib/ruby_git/status/entry.rb', line 60 def self.status_to_symbol(code) STATUS_CODES[code.to_sym] || :unknown end |
Instance Method Details
#fully_staged? ⇒ Boolean
Does the entry have staged changes in the index with no unstaged changes?
- An entry can have both staged and unstaged changes
148 |
# File 'lib/ruby_git/status/entry.rb', line 148 def fully_staged? = staged? && !unstaged? |
#ignored? ⇒ Boolean
Is the entry an ignored file?
- Ignored entries are not considered untracked
103 |
# File 'lib/ruby_git/status/entry.rb', line 103 def ignored? = false |
#index_status ⇒ Symbol?
Get the staging status
83 |
# File 'lib/ruby_git/status/entry.rb', line 83 def index_status = nil |
#staged? ⇒ Boolean
Does the entry have staged changes in the index?
- An entry can have both staged and unstaged changes
137 |
# File 'lib/ruby_git/status/entry.rb', line 137 def staged? = false |
#unmerged? ⇒ Boolean
Does the entry represent a merge conflict?
- Merge conflicts are not considered untracked, staged or unstaged
159 |
# File 'lib/ruby_git/status/entry.rb', line 159 def unmerged? = false |
#unstaged? ⇒ Boolean
Does the entry have unstaged changes in the worktree?
- An entry can have both staged and unstaged changes
- All untracked entries are considered unstaged
126 |
# File 'lib/ruby_git/status/entry.rb', line 126 def unstaged? = false |
#untracked? ⇒ Boolean
Is the entry an untracked file?
- Ignored entries are not considered untracked
114 |
# File 'lib/ruby_git/status/entry.rb', line 114 def untracked? = false |
#worktree_status ⇒ Symbol?
Get the worktree status
92 |
# File 'lib/ruby_git/status/entry.rb', line 92 def worktree_status = nil |