Skip to content

Commit

Permalink
fix: create repository use same path with project_name
Browse files Browse the repository at this point in the history
  • Loading branch information
icyleaf committed Apr 26, 2018
1 parent c4d70fb commit 7660c04
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/hpr/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Hpr

def create_repository(url : String, name : String? = nil, mirror_only = false)
repo = Repository.new url
project_name = name ? name : repo.mirror_name
project_name = (name && !name.empty?) ? name : repo.mirror_name

raise RepositoryExistsError.new "Exists Repository: #{project_name}" if reopsitory_stored?(project_name)

Expand All @@ -38,6 +38,7 @@ module Hpr
begin
Hpr.gitlab.create_project project_name, {
"namespace_id" => @namespace["id"].to_s,
"path" => project_name,
"description" => "Mirror of #{url}",
"visibility" => (Hpr.config.gitlab.project_public ? "public" : "private"),
"issues_enabled" => Hpr.config.gitlab.project_issue.to_s,
Expand All @@ -60,7 +61,10 @@ module Hpr
end

def update_repository(name : String)
raise NotFoundRepositoryError.new "Not found repository: #{name}" unless reopsitory_stored?(name)
unless reopsitory_stored?(name)
Hpr.logger.error "repository not exists ... #{name}"
raise NotFoundRepositoryError.new "Not found repository: #{name}"
end

UpdateRepositoryWorker.async.perform name
end
Expand All @@ -70,7 +74,7 @@ module Hpr
unless projects.as_a.empty?
project = projects[0]

Hpr.logger.info "destroying repository in gitlab ... #{@group["name"]}/#{name}"
Hpr.logger.info "destroying project ... #{@group["name"]}/#{name}"
r = Hpr.gitlab.delete_project project["id"].as_i
end

Expand Down

0 comments on commit 7660c04

Please sign in to comment.