2018-09-28 05:00:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Git
|
|
|
|
class Push
|
2018-09-28 06:08:11 -04:00
|
|
|
attr_reader :oldrev, :newrev
|
|
|
|
|
2018-09-28 05:00:30 -04:00
|
|
|
def initialize(project, oldrev, newrev, ref)
|
2018-09-28 06:08:11 -04:00
|
|
|
@project = project
|
|
|
|
@oldrev = oldrev
|
|
|
|
@newrev = newrev
|
|
|
|
@ref = ref
|
|
|
|
end
|
|
|
|
|
|
|
|
def branch_name
|
|
|
|
@branch_name ||= Gitlab::Git.ref_name(@ref)
|
2018-09-28 05:00:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def branch_added?
|
|
|
|
Gitlab::Git.blank_ref?(@oldrev)
|
|
|
|
end
|
|
|
|
|
|
|
|
def branch_removed?
|
|
|
|
Gitlab::Git.blank_ref?(@newrev)
|
|
|
|
end
|
|
|
|
|
|
|
|
def force_push?
|
|
|
|
Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev)
|
|
|
|
end
|
2018-09-28 06:08:11 -04:00
|
|
|
|
|
|
|
def branch_push?
|
|
|
|
Gitlab::Git.branch_ref?(@ref)
|
|
|
|
end
|
2018-09-28 05:00:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|