更改:创建同步不需要验证分支是否存在

This commit is contained in:
yystopf 2024-05-14 15:01:04 +08:00
parent 5559330706
commit 871904fb9c
1 changed files with 7 additions and 7 deletions

View File

@ -8,7 +8,7 @@ class Api::V1::Projects::SyncRepositories::CreateService < ApplicationService
validates :type, inclusion: {in: %w(SyncRepositories::Gitee SyncRepositories::Github)}
validates :external_repo_address, format: { with: CustomRegexp::URL_REGEX, multiline: true, message: "地址格式不正确" }
validates :sync_granularity, :first_sync_direction, inclusion: {in: [1,2]}
validate :check_gitlink_branch_name
# validate :check_gitlink_branch_name
def initialize(project, params)
@project = project
@ -40,12 +40,12 @@ class Api::V1::Projects::SyncRepositories::CreateService < ApplicationService
[@sync_repository1, @sync_repository2, @sync_repository_branch1, @sync_repository_branch2]
end
def check_gitlink_branch_name
if sync_granularity == 2
result = $gitea_hat_client.get_repos_branch_name_set_by_owner_repo(project&.owner&.login, project&.identifier) rescue nil
raise Error, '分支不存在' if !result.include?(gitlink_branch_name)
end
end
# def check_gitlink_branch_name
# if sync_granularity == 2
# result = $gitea_hat_client.get_repos_branch_name_set_by_owner_repo(project&.owner&.login, project&.identifier) rescue nil
# raise Error, '分支不存在' if !result.include?(gitlink_branch_name)
# end
# end
private
def create_sync_repository