# Module PushEvent

- app/roles/push_event.rb

Methods

B
  - branch?,
  - branch_name
C
  - commit_from,
  - commit_to,
  - commits,
  - commits_count
L
  - last_commit,
  - last_push_to_non_root?
M
  - md_ref?
N
  - new_branch?,
  - new_ref?
P
  - parent_commit,
  - push_action_name,
  - push_with_commits?
R
  - ref_name,
  - ref_type,
  - rm_ref?
T
  - tag?,
  - tag_name
V
  - valid_push?

Instance Public methods
branch?() Link

Source: show

    # File app/roles/push_event.rb, line 12
    def branch?
      data[:ref]["refs/heads"]
    end

branch_name() Link

Source: show

    # File app/roles/push_event.rb, line 48
    def branch_name
      @branch_name ||= data[:ref].gsub("refs/heads/", "")
    end

commit_from() Link

Source: show

    # File app/roles/push_event.rb, line 32
    def commit_from
      data[:before]
    end

commit_to() Link

Source: show

    # File app/roles/push_event.rb, line 36
    def commit_to
      data[:after]
    end

commits() Link

Max 20 commits from push DESC

Source: show

    # File app/roles/push_event.rb, line 57
    def commits
      @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse
    end

commits_count() Link

Source: show

    # File app/roles/push_event.rb, line 61
    def commits_count
      data[:total_commits_count] || commits.count || 0
    end

last_commit() Link

Source: show

    # File app/roles/push_event.rb, line 85
    def last_commit
      project.commit(commit_to)
    rescue => ex
      nil
    end

last_push_to_non_root?() Link

Source: show

    # File app/roles/push_event.rb, line 97
    def last_push_to_non_root?
      branch? && project.default_branch != branch_name
    end

md_ref?() Link

Source: show

    # File app/roles/push_event.rb, line 28
    def md_ref?
      !(rm_ref? || new_ref?)
    end

new_branch?() Link

Source: show

    # File app/roles/push_event.rb, line 16
    def new_branch?
      commit_from =~ %r^00000/
    end

new_ref?() Link

Source: show

    # File app/roles/push_event.rb, line 20
    def new_ref?
      commit_from =~ %r^00000/
    end

parent_commit() Link

Source: show

    # File app/roles/push_event.rb, line 79
    def parent_commit
      project.commit(commit_from)
    rescue => ex
      nil
    end

push_action_name() Link

Source: show

    # 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?() Link

Source: show

    # 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() Link

Source: show

    # File app/roles/push_event.rb, line 40
    def ref_name
      if tag?
        tag_name
      else
        branch_name
      end
    end

ref_type() Link

Source: show

    # File app/roles/push_event.rb, line 65
    def ref_type
      tag? ? "tag" : "branch"
    end

rm_ref?() Link

Source: show

    # File app/roles/push_event.rb, line 24
    def rm_ref?
      commit_to =~ %r^00000/
    end

tag?() Link

Source: show

    # File app/roles/push_event.rb, line 8
    def tag?
      data[:ref]["refs/tags"]
    end

tag_name() Link

Source: show

    # File app/roles/push_event.rb, line 52
    def tag_name
      @tag_name ||= data[:ref].gsub("refs/tags/", "")
    end

valid_push?() Link

Source: show

    # File app/roles/push_event.rb, line 2
    def valid_push?
      data[:ref]
    rescue => ex
      false
    end