blob: 214c727bc6374c0ecfee7e7cc8707aed2a53a2fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# frozen_string_literal: true
require_relative 'base_service'
class ValidateNewBranchService < BaseService
def execute(branch_name, force)
valid_branch = Gitlab::GitRefValidator.validate(branch_name)
unless valid_branch
return error('Branch name is invalid')
end
if project.repository.branch_exists?(branch_name) && force == false
return error('Branch already exists')
end
success
rescue Gitlab::Git::PreReceiveError => ex
error(ex.message)
end
end
|