Class: EacGit::Local::ChangedFile
- Inherits:
-
Object
- Object
- EacGit::Local::ChangedFile
- Defined in:
- lib/eac_git/local/changed_file.rb
Constant Summary collapse
- QUOTED_PATH_PATTERN =
/\A"(.+)"\z/.freeze
- STATUS_LINE_PATTERN =
/\A(.)(.)\s(.+)\z/.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.by_porcelain_v1_line(local_repo, line) ⇒ Object
10 11 12 13 14 |
# File 'lib/eac_git/local/changed_file.rb', line 10 def by_porcelain_v1_line(local_repo, line) STATUS_LINE_PATTERN.match(line.gsub(/\n\z/, '')).then do |m| new(local_repo, m[1], m[2], parse_status_line_path(m[3]).to_pathname) end end |
.parse_status_line_path(path) ⇒ String
18 19 20 21 |
# File 'lib/eac_git/local/changed_file.rb', line 18 def parse_status_line_path(path) m = QUOTED_PATH_PATTERN.match(path) m ? m[1] : path end |
Instance Method Details
#absolute_path ⇒ Pathname
27 28 29 |
# File 'lib/eac_git/local/changed_file.rb', line 27 def absolute_path path.(local_repo.root_path) end |
#add? ⇒ Boolean
32 33 34 |
# File 'lib/eac_git/local/changed_file.rb', line 32 def add? (index == '?' && worktree == '?') || (index == 'A' && worktree == ' ') end |
#delete? ⇒ Boolean
37 38 39 |
# File 'lib/eac_git/local/changed_file.rb', line 37 def delete? [index, worktree].include?('D') end |
#modify? ⇒ Boolean
42 43 44 |
# File 'lib/eac_git/local/changed_file.rb', line 42 def modify? [index, worktree].include?('M') end |