module PushEvent

Public Instance Methods

branch?() click to toggle source
# File app/roles/push_event.rb, line 12
def branch?
  data[:ref]["refs/heads"]
end
branch_name() click to toggle source
# File app/roles/push_event.rb, line 48
def branch_name
  @branch_name ||= data[:ref].gsub("refs/heads/", "")
end
commit_from() click to toggle source
# File app/roles/push_event.rb, line 32
def commit_from
  data[:before]
end
commit_to() click to toggle source
# File app/roles/push_event.rb, line 36
def commit_to
  data[:after]
end
commits() click to toggle source

Max 20 commits from push DESC

# File app/roles/push_event.rb, line 57
def commits
  @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse
end
commits_count() click to toggle source
# File app/roles/push_event.rb, line 61
def commits_count 
  data[:total_commits_count] || commits.count || 0
end
last_commit() click to toggle source
# File app/roles/push_event.rb, line 85
def last_commit
  project.commit(commit_to)
rescue => ex
  nil
end
last_push_to_non_root?() click to toggle source
# File app/roles/push_event.rb, line 97
def last_push_to_non_root?
  branch? && project.default_branch != branch_name
end
md_ref?() click to toggle source
# File app/roles/push_event.rb, line 28
def md_ref?
  !(rm_ref? || new_ref?)
end
new_branch?() click to toggle source
# File app/roles/push_event.rb, line 16
def new_branch?
  commit_from =~ %r^00000/
end
new_ref?() click to toggle source
# File app/roles/push_event.rb, line 20
def new_ref?
  commit_from =~ %r^00000/
end
parent_commit() click to toggle source
# File app/roles/push_event.rb, line 79
def parent_commit
  project.commit(commit_from)
rescue => ex
  nil
end
push_action_name() click to toggle source
# File app/roles/push_event.rb, line 69
def push_action_name
  if new_ref?
    "pushed new"
  elsif rm_ref?
    "deleted"
  else
    "pushed to"
  end
end
push_with_commits?() click to toggle source
# File app/roles/push_event.rb, line 91
def push_with_commits? 
  md_ref? && commits.any? && parent_commit && last_commit
rescue Grit::NoSuchPathError
  false
end
ref_name() click to toggle source
# File app/roles/push_event.rb, line 40
def ref_name
  if tag?
    tag_name
  else
    branch_name
  end
end
ref_type() click to toggle source
# File app/roles/push_event.rb, line 65
def ref_type
  tag? ? "tag" : "branch"
end
rm_ref?() click to toggle source
# File app/roles/push_event.rb, line 24
def rm_ref?
  commit_to =~ %r^00000/
end
tag?() click to toggle source
# File app/roles/push_event.rb, line 8
def tag?
  data[:ref]["refs/tags"]
end
tag_name() click to toggle source
# File app/roles/push_event.rb, line 52
def tag_name
  @tag_name ||= data[:ref].gsub("refs/tags/", "")
end
valid_push?() click to toggle source
# File app/roles/push_event.rb, line 2
def valid_push?
  data[:ref]
rescue => ex
  false
end