Factor '0' * 40 blank ref constants
This commit is contained in:
parent
1b1403804e
commit
c3be1517ae
|
@ -160,19 +160,19 @@ class GitPushService
|
||||||
ref_parts = ref.split('/')
|
ref_parts = ref.split('/')
|
||||||
|
|
||||||
# Return if this is not a push to a branch (e.g. new commits)
|
# Return if this is not a push to a branch (e.g. new commits)
|
||||||
ref_parts[1] =~ /heads/ && oldrev != "0000000000000000000000000000000000000000"
|
ref_parts[1] =~ /heads/ && oldrev != Gitlab::Git::BLANK_SHA
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_to_new_branch?(ref, oldrev)
|
def push_to_new_branch?(ref, oldrev)
|
||||||
ref_parts = ref.split('/')
|
ref_parts = ref.split('/')
|
||||||
|
|
||||||
ref_parts[1] =~ /heads/ && oldrev == "0000000000000000000000000000000000000000"
|
ref_parts[1] =~ /heads/ && oldrev == Gitlab::Git::BLANK_SHA
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_remove_branch?(ref, newrev)
|
def push_remove_branch?(ref, newrev)
|
||||||
ref_parts = ref.split('/')
|
ref_parts = ref.split('/')
|
||||||
|
|
||||||
ref_parts[1] =~ /heads/ && newrev == "0000000000000000000000000000000000000000"
|
ref_parts[1] =~ /heads/ && newrev == Gitlab::Git::BLANK_SHA
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_to_branch?(ref)
|
def push_to_branch?(ref)
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Spinach::Features::EventFilters < Spinach::FeatureSteps
|
||||||
|
|
||||||
step 'this project has push event' do
|
step 'this project has push event' do
|
||||||
data = {
|
data = {
|
||||||
before: "0000000000000000000000000000000000000000",
|
before: Gitlab::Git::BLANK_SHA,
|
||||||
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
|
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
|
||||||
ref: "refs/heads/new_design",
|
ref: "refs/heads/new_design",
|
||||||
user_id: @user.id,
|
user_id: @user.id,
|
||||||
|
|
|
@ -32,7 +32,7 @@ module SharedProject
|
||||||
@project = Project.find_by(name: "Shop")
|
@project = Project.find_by(name: "Shop")
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
before: "0000000000000000000000000000000000000000",
|
before: Gitlab::Git::BLANK_SHA,
|
||||||
after: "6d394385cf567f80a8fd85055db1ab4c5295806f",
|
after: "6d394385cf567f80a8fd85055db1ab4c5295806f",
|
||||||
ref: "refs/heads/fix",
|
ref: "refs/heads/fix",
|
||||||
user_id: @user.id,
|
user_id: @user.id,
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
module Gitlab
|
||||||
|
module Git
|
||||||
|
BLANK_SHA = '0' * 40
|
||||||
|
end
|
||||||
|
end
|
|
@ -36,7 +36,7 @@ describe Event do
|
||||||
@user = project.owner
|
@user = project.owner
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
before: "0000000000000000000000000000000000000000",
|
before: Gitlab::Git::BLANK_SHA,
|
||||||
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
|
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
|
||||||
ref: "refs/heads/master",
|
ref: "refs/heads/master",
|
||||||
user_id: @user.id,
|
user_id: @user.id,
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe GitPushService do
|
||||||
let (:service) { GitPushService.new }
|
let (:service) { GitPushService.new }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@blankrev = '0000000000000000000000000000000000000000'
|
@blankrev = Gitlab::Git::BLANK_SHA
|
||||||
@oldrev = sample_commit.parent_id
|
@oldrev = sample_commit.parent_id
|
||||||
@newrev = sample_commit.id
|
@newrev = sample_commit.id
|
||||||
@ref = 'refs/heads/master'
|
@ref = 'refs/heads/master'
|
||||||
|
|
Loading…
Reference in New Issue