class Git::PreReceiveHookParser

Attributes

new_sha1[R]
old_sha1[R]
ref_name[R]

Public Class Methods

new(input) click to toggle source
# File lib/git_hook-pre_receive/pre_receive_hook_parser.rb, line 10
def initialize(input)
  @old_sha1, @new_sha1, @ref_name = input.split(" ")
end

Public Instance Methods

files() click to toggle source
# File lib/git_hook-pre_receive/pre_receive_hook_parser.rb, line 14
def files
  if old_sha1 == '0' * 40
    result = Git::Command.diff_tree(new_sha1)
    result.delete_at(0)
    result.delete_if { |l| l['0000000... D'] != nil }.collect { |l| File.new(l) }
  else
    result = Git::Command.diff(old_sha1, new_sha1)
    result.delete_if { |l| l['0000000... D'] != nil }.collect { |l| File.new(l) }
  end
end