Class: RepositoryForkWorker

Inherits:
Object
  • Object
show all
Includes:
Gitlab::ShellAdapter, Sidekiq::Worker
Defined in:
app/workers/repository_fork_worker.rb

Instance Method Summary collapse

Methods included from Gitlab::ShellAdapter

#gitlab_shell

Instance Method Details

#perform(project_id, source_path, target_path) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/workers/repository_fork_worker.rb', line 7

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.update(import_error: "The project could not be forked.")
    project.import_fail
    return
  end

  project.repository.after_import

  unless project.valid_repo?
    logger.error("Project #{project_id} had an invalid repository after fork")
    project.update(import_error: "The forked repository is invalid.")
    project.import_fail
    return
  end

  project.import_finish
end