debian-mirror-gitlab/app/services/validate_new_branch_service.rb

20 lines
458 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require_relative 'base_service'
class ValidateNewBranchService < BaseService
def execute(branch_name)
valid_branch = Gitlab::GitRefValidator.validate(branch_name)
unless valid_branch
return error('Branch name is invalid')
end
if project.repository.branch_exists?(branch_name)
return error('Branch already exists')
end
success
2018-03-17 18:26:18 +05:30
rescue Gitlab::Git::HooksService::PreReceiveError => ex
2017-08-17 22:00:37 +05:30
error(ex.message)
end
end