Module: Gitlab::GithubImport

Defined in:
lib/gitlab/github_import.rb,
lib/gitlab/github_import/client.rb,
lib/gitlab/github_import/logger.rb,
lib/gitlab/github_import/user_finder.rb,
lib/gitlab/github_import/label_finder.rb,
lib/gitlab/github_import/page_counter.rb,
lib/gitlab/github_import/markdown_text.rb,
lib/gitlab/github_import/bulk_importing.rb,
lib/gitlab/github_import/object_counter.rb,
lib/gitlab/github_import/representation.rb,
lib/gitlab/github_import/issuable_finder.rb,
lib/gitlab/github_import/milestone_finder.rb,
lib/gitlab/github_import/rate_limit_error.rb,
lib/gitlab/github_import/parallel_importer.rb,
lib/gitlab/github_import/parallel_scheduling.rb,
lib/gitlab/github_import/representation/note.rb,
lib/gitlab/github_import/representation/user.rb,
lib/gitlab/github_import/sequential_importer.rb,
lib/gitlab/github_import/representation/issue.rb,
app/workers/concerns/gitlab/github_import/queue.rb,
lib/gitlab/github_import/importer/note_importer.rb,
lib/gitlab/github_import/representation/to_hash.rb,
lib/gitlab/github_import/importer/issue_importer.rb,
lib/gitlab/github_import/importer/notes_importer.rb,
lib/gitlab/github_import/importer/issues_importer.rb,
lib/gitlab/github_import/importer/labels_importer.rb,
lib/gitlab/github_import/representation/diff_note.rb,
lib/gitlab/github_import/representation/lfs_object.rb,
app/workers/gitlab/github_import/import_note_worker.rb,
lib/gitlab/github_import/importer/releases_importer.rb,
app/workers/gitlab/github_import/import_issue_worker.rb,
lib/gitlab/github_import/importer/diff_note_importer.rb,
lib/gitlab/github_import/representation/pull_request.rb,
app/workers/gitlab/github_import/advance_stage_worker.rb,
lib/gitlab/github_import/importer/diff_notes_importer.rb,
lib/gitlab/github_import/importer/lfs_object_importer.rb,
lib/gitlab/github_import/importer/milestones_importer.rb,
lib/gitlab/github_import/importer/repository_importer.rb,
lib/gitlab/github_import/importer/label_links_importer.rb,
lib/gitlab/github_import/importer/lfs_objects_importer.rb,
app/workers/concerns/gitlab/github_import/stage_methods.rb,
lib/gitlab/github_import/importer/pull_request_importer.rb,
app/workers/gitlab/github_import/import_diff_note_worker.rb,
lib/gitlab/github_import/importer/pull_requests_importer.rb,
lib/gitlab/github_import/representation/expose_attribute.rb,
lib/gitlab/github_import/single_endpoint_notes_importing.rb,
app/workers/concerns/gitlab/github_import/object_importer.rb,
app/workers/gitlab/github_import/import_lfs_object_worker.rb,
app/workers/gitlab/github_import/refresh_import_jid_worker.rb,
app/workers/gitlab/github_import/stage/import_notes_worker.rb,
app/workers/gitlab/github_import/import_pull_request_worker.rb,
app/workers/gitlab/github_import/stage/finish_import_worker.rb,
lib/gitlab/github_import/representation/pull_request_review.rb,
app/workers/concerns/gitlab/github_import/rescheduling_methods.rb,
app/workers/gitlab/github_import/stage/import_base_data_worker.rb,
lib/gitlab/github_import/importer/pull_request_review_importer.rb,
app/workers/gitlab/github_import/stage/import_repository_worker.rb,
app/workers/gitlab/github_import/stage/import_lfs_objects_worker.rb,
lib/gitlab/github_import/importer/issue_and_label_links_importer.rb,
lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb,
lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb,
app/workers/gitlab/github_import/import_pull_request_review_worker.rb,
app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb,
lib/gitlab/github_import/importer/pull_requests_merged_by_importer.rb,
app/workers/gitlab/github_import/import_pull_request_merged_by_worker.rb,
lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer.rb,
lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer.rb,
lib/gitlab/github_import/representation/diff_notes/suggestion_formatter.rb,
app/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker.rb,
app/workers/gitlab/github_import/stage/import_pull_requests_reviews_worker.rb,
app/workers/gitlab/github_import/stage/import_pull_requests_merged_by_worker.rb,
lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer.rb

Defined Under Namespace

Modules: BulkImporting, Importer, ObjectImporter, ParallelScheduling, Queue, Representation, ReschedulingMethods, SingleEndpointNotesImporting, Stage, StageMethods Classes: AdvanceStageWorker, Client, ImportDiffNoteWorker, ImportIssueWorker, ImportLfsObjectWorker, ImportNoteWorker, ImportPullRequestMergedByWorker, ImportPullRequestReviewWorker, ImportPullRequestWorker, IssuableFinder, LabelFinder, Logger, MarkdownText, MilestoneFinder, ObjectCounter, PageCounter, ParallelImporter, RefreshImportJidWorker, SequentialImporter, UserFinder

Constant Summary collapse

RateLimitError =

Error that will be raised when we're about to reach (or have reached) the GitHub API's rate limit.

Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.formatted_import_url(project) ⇒ Object

Get formatted GitHub import URL. If github.com is in the import URL, this will return nil and octokit will use the default github.com API URL


27
28
29
30
31
32
33
34
35
36
# File 'lib/gitlab/github_import.rb', line 27

def self.formatted_import_url(project)
  url = URI.parse(project.import_url)

  unless url.host == 'github.com'
    url.user = nil
    url.password = nil
    url.path = "/api/v3"
    url.to_s
  end
end

.ghost_user_idObject

Returns the ID of the ghost user.


20
21
22
23
24
# File 'lib/gitlab/github_import.rb', line 20

def self.ghost_user_id
  key = 'github-import/ghost-user-id'

  Gitlab::Cache::Import::Caching.read_integer(key) || Gitlab::Cache::Import::Caching.write(key, User.select(:id).ghost.id)
end

.new_client_for(project, token: nil, host: nil, parallel: true) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/gitlab/github_import.rb', line 9

def self.new_client_for(project, token: nil, host: nil, parallel: true)
  token_to_use = token || project.import_data&.credentials&.fetch(:user)
  Client.new(
    token_to_use,
    host: host.presence || self.formatted_import_url(project),
    per_page: self.per_page(project),
    parallel: parallel
  )
end

.per_page(project) ⇒ Object


38
39
40
41
42
43
44
# File 'lib/gitlab/github_import.rb', line 38

def self.per_page(project)
  if project.group.present? && Feature.enabled?(:github_importer_lower_per_page_limit, project.group, type: :ops)
    Gitlab::GithubImport::Client::LOWER_PER_PAGE
  else
    Gitlab::GithubImport::Client::DEFAULT_PER_PAGE
  end
end

.refmapObject


5
6
7
# File 'lib/gitlab/github_import.rb', line 5

def self.refmap
  [:heads, :tags, '+refs/pull/*/head:refs/merge-requests/*/head']
end