Class: Overcommit::HookContext::PrePush::PushedRef

Inherits:
Struct
  • Object
show all
Defined in:
lib/overcommit/hook_context/pre_push.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#local_refObject

Returns the value of attribute local_ref

Returns:

  • (Object)

    the current value of local_ref



31
32
33
# File 'lib/overcommit/hook_context/pre_push.rb', line 31

def local_ref
  @local_ref
end

#local_sha1Object

Returns the value of attribute local_sha1

Returns:

  • (Object)

    the current value of local_sha1



31
32
33
# File 'lib/overcommit/hook_context/pre_push.rb', line 31

def local_sha1
  @local_sha1
end

#remote_refObject

Returns the value of attribute remote_ref

Returns:

  • (Object)

    the current value of remote_ref



31
32
33
# File 'lib/overcommit/hook_context/pre_push.rb', line 31

def remote_ref
  @remote_ref
end

#remote_sha1Object

Returns the value of attribute remote_sha1

Returns:

  • (Object)

    the current value of remote_sha1



31
32
33
# File 'lib/overcommit/hook_context/pre_push.rb', line 31

def remote_sha1
  @remote_sha1
end

Instance Method Details

#created?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/overcommit/hook_context/pre_push.rb', line 36

def created?
  remote_sha1 == '0' * 40
end

#deleted?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/overcommit/hook_context/pre_push.rb', line 40

def deleted?
  local_sha1 == '0' * 40
end

#destructive?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/overcommit/hook_context/pre_push.rb', line 44

def destructive?
  deleted? || forced?
end

#forced?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/overcommit/hook_context/pre_push.rb', line 32

def forced?
  !(created? || deleted? || overwritten_commits.empty?)
end

#modified_filesObject



48
49
50
# File 'lib/overcommit/hook_context/pre_push.rb', line 48

def modified_files
  Overcommit::GitRepo.modified_files(refs: ref_range)
end

#modified_lines_in_file(file) ⇒ Object



52
53
54
# File 'lib/overcommit/hook_context/pre_push.rb', line 52

def modified_lines_in_file(file)
  Overcommit::GitRepo.extract_modified_lines(file, refs: ref_range)
end

#to_sObject



56
57
58
# File 'lib/overcommit/hook_context/pre_push.rb', line 56

def to_s
  "#{local_ref} #{local_sha1} #{remote_ref} #{remote_sha1}"
end