|
|
|
@@ -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 |
|
|
|
|