Class: RubyGit::Status::UntrackedEntry

Inherits:
Entry
  • Object
show all
Defined in:
lib/ruby_git/status/untracked_entry.rb

Overview

Represents an untracked file in git status

Constant Summary

Constants inherited from Entry

Entry::RENAME_OPERATIONS, Entry::STATUS_CODES

Instance Attribute Summary

Attributes inherited from Entry

#path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entry

#fully_staged?, #ignored?, #index_status, rename_operation_to_symbol, #staged?, status_to_symbol, #unmerged?, #worktree_status

Constructor Details

#initialize(path:) ⇒ UntrackedEntry

Initialize with the path

Examples:

UntrackedEntry.new(path: 'file.txt')

Parameters:

  • path (String)

    the path of the untracked file



31
32
33
# File 'lib/ruby_git/status/untracked_entry.rb', line 31

def initialize(path:)
  super(path)
end

Class Method Details

.parse(line) ⇒ RubyGit::Status::UntrackedEntry

Parse a git status line to create an untracked entry

Examples:

UntrackedEntry.parse('?? lib/example.rb') #=> #<RubyGit::Status::UntrackedEntry:0x00000001046bd488 ...>

Parameters:

  • line (String)

    line from git status

Returns:



19
20
21
22
# File 'lib/ruby_git/status/untracked_entry.rb', line 19

def self.parse(line)
  tokens = line.split(' ', 2)
  new(path: tokens[1])
end

Instance Method Details

#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

Examples:

entry.ignored? #=> false

Returns:

  • (Boolean)


49
# File 'lib/ruby_git/status/untracked_entry.rb', line 49

def unstaged? = true

#untracked?Boolean

Is the entry an untracked file?

Examples:

entry.ignored? #=> false

Returns:

  • (Boolean)


39
# File 'lib/ruby_git/status/untracked_entry.rb', line 39

def untracked? = true