Class: Avm::Git::Commit::DiffTreeLine
- Inherits:
-
Object
- Object
- Avm::Git::Commit::DiffTreeLine
- Defined in:
- lib/avm/git/commit/diff_tree_line.rb
Constant Summary collapse
- DIFF_TREE_PATTERN =
/\A:(\d{6}) (\d{6}) (\S+) (\S+) (\S+)\t(\S.*)\z/.freeze
- FIELDS =
%w[src_mode dst_mode src_sha1 dst_sha1 status path].freeze
- GIT_COMMAND_ARGS =
%w[-c core.quotepath=off diff-tree --no-commit-id -r --full-index].freeze
Instance Method Summary collapse
- #fields ⇒ Object
-
#initialize(line) ⇒ DiffTreeLine
constructor
line: a line of command “git [GIT_COMMAND_ARGS]”‘s output.
Constructor Details
#initialize(line) ⇒ DiffTreeLine
line: a line of command “git [GIT_COMMAND_ARGS]”‘s output. Reference: git-scm.com/docs/git-diff-tree
15 16 17 18 19 20 |
# File 'lib/avm/git/commit/diff_tree_line.rb', line 15 def initialize(line) m = DIFF_TREE_PATTERN.match(line.strip) raise "\"#{line}\" did not match pattern" unless m FIELDS.count.times { |i| send("#{FIELDS[i]}=", m[i + 1]) } end |
Instance Method Details
#fields ⇒ Object
22 23 24 |
# File 'lib/avm/git/commit/diff_tree_line.rb', line 22 def fields FIELDS.index_with { |field| send(field) } end |