Class: PushEvent
Constant Summary
Constants inherited
from Event
Event::CONTRIBUTABLE_TARGET_TYPES, 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
Import::HasImportSource::IMPORT_SOURCES
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Event
#action_name, #authored_by?, #body?, #commit_note?, #created_project_action?, #created_target?, #created_wiki_page?, #design, #design?, #design_note?, #ensure_sharding_key, 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?, #project_snippet_note?, #reset_project_activity, #resource_parent, #snippet_note?, #target_iid, #target_title, target_types, #to_partial_path, #update_project, #updated_wiki_page?, #visible_to_user?, #wiki_page, #wiki_page?, #wiki_page_note?, #work_item?
#imported?
#present
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, 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
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.branch_events ⇒ Object
Returns events of pushes to a branch.
46
47
48
49
50
51
|
# File 'app/models/push_event.rb', line 46
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.
35
36
37
38
39
40
41
42
43
|
# File 'app/models/push_event.rb', line 35
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
72
73
74
|
# File 'app/models/push_event.rb', line 72
def self.sti_name
actions[:pushed]
end
|
.without_existing_merge_requests ⇒ Object
Returns PushEvent instances for which no merge requests have been created.
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'app/models/push_event.rb', line 54
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
107
108
109
|
# File 'app/models/push_event.rb', line 107
def commit_id
commit_to || commit_from
end
|
#last_push_to_non_root? ⇒ Boolean
111
112
113
|
# File 'app/models/push_event.rb', line 111
def last_push_to_non_root?
branch? && project.default_branch != branch_name
end
|
#md_ref? ⇒ Boolean
96
97
98
|
# File 'app/models/push_event.rb', line 96
def md_ref?
!(rm_ref? || new_ref?)
end
|
#new_ref? ⇒ Boolean
88
89
90
|
# File 'app/models/push_event.rb', line 88
def new_ref?
push_event_payload.created?
end
|
#push_action? ⇒ Boolean
76
77
78
|
# File 'app/models/push_event.rb', line 76
def push_action?
true
end
|
#push_with_commits? ⇒ Boolean
80
81
82
|
# File 'app/models/push_event.rb', line 80
def push_with_commits?
!!(commit_from && commit_to)
end
|
#ref_name ⇒ Object
Also known as:
branch_name, tag_name
100
101
102
|
# File 'app/models/push_event.rb', line 100
def ref_name
push_event_payload.ref
end
|
#rm_ref? ⇒ Boolean
92
93
94
|
# File 'app/models/push_event.rb', line 92
def rm_ref?
push_event_payload.removed?
end
|
#valid_push? ⇒ Boolean
84
85
86
|
# File 'app/models/push_event.rb', line 84
def valid_push?
push_event_payload.ref.present?
end
|
#validate_push_action ⇒ Object
115
116
117
118
119
|
# File 'app/models/push_event.rb', line 115
def validate_push_action
return if pushed_action?
errors.add(:action, "the action #{action.inspect} is not valid")
end
|