Class: PushEvent
Constant Summary
Constants inherited
from Event
Event::DESIGN_ACTIONS, Event::ISSUE_ACTIONS, Event::ISSUE_TYPES, Event::REPOSITORY_UPDATED_AT_INTERVAL, Event::RESET_PROJECT_ACTIVITY_INTERVAL, Event::TARGET_TYPES, Event::TEAM_ACTIONS, Event::WIKI_ACTIONS
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Event
#action_name, #authored_by?, #body?, #commit_note?, contributions, #created_project_action?, #created_target?, #created_wiki_page?, #design, #design?, #design_note?, find_sti_class, #has_no_project_and_group?, #issue, #issue?, #issue_note?, limit_recent, #membership_changed?, #merge_request, #merge_request?, #merge_request_note?, #milestone, #milestone?, model_name, #note, #note?, #note_target, #note_target_id, #note_target_reference, #personal_snippet_note?, #present, #project_snippet_note?, #reset_project_activity, #resource_parent, #snippet_note?, #target_iid, #target_title, target_types, #to_partial_path, #updated_wiki_page?, #visible_to_user?, #wiki_page, #wiki_page?, #work_item?
#present
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#serializable_hash
Class Method Details
.branch_events ⇒ Object
Returns events of pushes to a branch.
44
45
46
47
48
49
|
# File 'app/models/push_event.rb', line 44
def self.branch_events
ref_type = PushEventPayload.ref_types[:branch]
joins(:push_event_payload)
.where(push_event_payloads: { ref_type: ref_type })
end
|
.created_or_pushed ⇒ Object
Returns events of pushes that either pushed to an existing ref or created a new one.
33
34
35
36
37
38
39
40
41
|
# File 'app/models/push_event.rb', line 33
def self.created_or_pushed
actions = [
PushEventPayload.actions[:pushed],
PushEventPayload.actions[:created]
]
joins(:push_event_payload)
.where(push_event_payloads: { action: actions })
end
|
.sti_name ⇒ Object
70
71
72
|
# File 'app/models/push_event.rb', line 70
def self.sti_name
actions[:pushed]
end
|
.without_existing_merge_requests ⇒ Object
Returns PushEvent instances for which no merge requests have been created.
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/models/push_event.rb', line 52
def self.without_existing_merge_requests
existing_mrs = MergeRequest.except(:order, :where)
.select(1)
.where('merge_requests.source_project_id = events.project_id')
.where('merge_requests.source_branch = push_event_payloads.ref')
.with_state(:opened)
joins(:push_event_payload)
.where('NOT EXISTS (?)', existing_mrs)
.created_or_pushed
.branch_events
end
|
Instance Method Details
#commit_id ⇒ Object
105
106
107
|
# File 'app/models/push_event.rb', line 105
def commit_id
commit_to || commit_from
end
|
#last_push_to_non_root? ⇒ Boolean
109
110
111
|
# File 'app/models/push_event.rb', line 109
def last_push_to_non_root?
branch? && project.default_branch != branch_name
end
|
#md_ref? ⇒ Boolean
94
95
96
|
# File 'app/models/push_event.rb', line 94
def md_ref?
!(rm_ref? || new_ref?)
end
|
#new_ref? ⇒ Boolean
86
87
88
|
# File 'app/models/push_event.rb', line 86
def new_ref?
push_event_payload.created?
end
|
#push_action? ⇒ Boolean
74
75
76
|
# File 'app/models/push_event.rb', line 74
def push_action?
true
end
|
#push_with_commits? ⇒ Boolean
78
79
80
|
# File 'app/models/push_event.rb', line 78
def push_with_commits?
!!(commit_from && commit_to)
end
|
#ref_name ⇒ Object
Also known as:
branch_name, tag_name
98
99
100
|
# File 'app/models/push_event.rb', line 98
def ref_name
push_event_payload.ref
end
|
#rm_ref? ⇒ Boolean
90
91
92
|
# File 'app/models/push_event.rb', line 90
def rm_ref?
push_event_payload.removed?
end
|
#valid_push? ⇒ Boolean
82
83
84
|
# File 'app/models/push_event.rb', line 82
def valid_push?
push_event_payload.ref.present?
end
|
#validate_push_action ⇒ Object
113
114
115
116
117
|
# File 'app/models/push_event.rb', line 113
def validate_push_action
return if pushed_action?
errors.add(:action, "the action #{action.inspect} is not valid")
end
|