diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-15 22:40:35 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-15 22:40:35 +0200 |
commit | e21deaee8ee0d453bf899c1b3fb46262cc60dab9 (patch) | |
tree | 59b04c9cb1c8ce6c510a78ee787fb31817619835 /app/workers | |
parent | 7e2dbcbe0915cfd75e91d78e943c153f284df37d (diff) | |
parent | 0ad669bb5ba08d012d3daa50b51a3a6b069e3e83 (diff) | |
download | gitlab-ce-e21deaee8ee0d453bf899c1b3fb46262cc60dab9.tar.gz |
Merge remote-tracking branch 'origin/master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g
# Conflicts:
# Gemfile.lock
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/repository_fork_worker.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/workers/repository_fork_worker.rb b/app/workers/repository_fork_worker.rb new file mode 100644 index 00000000000..acd1c43f06b --- /dev/null +++ b/app/workers/repository_fork_worker.rb @@ -0,0 +1,34 @@ +class RepositoryForkWorker + include Sidekiq::Worker + include Gitlab::ShellAdapter + + sidekiq_options queue: :gitlab_shell + + def perform(project_id, source_path, target_path) + project = Project.find_by_id(project_id) + + unless project.present? + logger.error("Project #{project_id} no longer exists!") + return + end + + result = gitlab_shell.fork_repository(source_path, target_path) + + unless result + logger.error("Unable to fork project #{project_id} for repository #{source_path} -> #{target_path}") + project.import_fail + project.save + return + end + + if project.valid_repo? + ProjectCacheWorker.perform_async(project.id) + project.import_finish + else + project.import_fail + logger.error("Project #{id} had an invalid repository after fork") + end + + project.save + end +end |