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/settings.rb,
lib/gitlab/github_import/exceptions.rb,
lib/gitlab/github_import/client_pool.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/clients/proxy.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/markdown/attachment.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/clients/search_repos.rb,
lib/gitlab/github_import/job_delay_calculator.rb,
lib/gitlab/github_import/representation/issue.rb,
lib/gitlab/github_import/project_relation_type.rb,
app/workers/concerns/gitlab/github_import/queue.rb,
lib/gitlab/github_import/attachments_downloader.rb,
lib/gitlab/github_import/importer/events/closed.rb,
lib/gitlab/github_import/importer/note_importer.rb,
lib/gitlab/github_import/representation/to_hash.rb,
lib/gitlab/github_import/importer/events/renamed.rb,
lib/gitlab/github_import/importer/issue_importer.rb,
lib/gitlab/github_import/importer/notes_importer.rb,
lib/gitlab/github_import/importer/events/reopened.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/note_text.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,
lib/gitlab/github_import/representation/issue_event.rb,
app/workers/gitlab/github_import/import_issue_worker.rb,
lib/gitlab/github_import/importer/diff_note_importer.rb,
lib/gitlab/github_import/representation/collaborator.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/events/base_importer.rb,
lib/gitlab/github_import/importer/events/changed_label.rb,
lib/gitlab/github_import/importer/issue_event_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/collaborator_importer.rb,
lib/gitlab/github_import/importer/issue_events_importer.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/collaborators_importer.rb,
lib/gitlab/github_import/importer/pull_requests_importer.rb,
lib/gitlab/github_import/representation/expose_attribute.rb,
lib/gitlab/github_import/representation/protected_branch.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,
lib/gitlab/github_import/importer/events/changed_assignee.rb,
lib/gitlab/github_import/importer/events/changed_reviewer.rb,
lib/gitlab/github_import/importer/events/cross_referenced.rb,
app/workers/gitlab/github_import/import_issue_event_worker.rb,
app/workers/gitlab/github_import/refresh_import_jid_worker.rb,
app/workers/gitlab/github_import/stage/import_notes_worker.rb,
lib/gitlab/github_import/importer/events/changed_milestone.rb,
app/workers/gitlab/github_import/import_collaborator_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/importer/attachments/base_importer.rb,
lib/gitlab/github_import/importer/note_attachments_importer.rb,
lib/gitlab/github_import/importer/protected_branch_importer.rb,
lib/gitlab/github_import/representation/pull_request_review.rb,
lib/gitlab/github_import/importer/attachments/notes_importer.rb,
lib/gitlab/github_import/importer/attachments/issues_importer.rb,
lib/gitlab/github_import/importer/protected_branches_importer.rb,
app/workers/concerns/gitlab/github_import/rescheduling_methods.rb,
app/workers/gitlab/github_import/stage/import_base_data_worker.rb,
app/workers/gitlab/github_import/attachments/import_note_worker.rb,
app/workers/gitlab/github_import/import_protected_branch_worker.rb,
app/workers/gitlab/github_import/stage/import_repository_worker.rb,
lib/gitlab/github_import/importer/attachments/releases_importer.rb,
lib/gitlab/github_import/importer/pull_requests/review_importer.rb,
app/workers/gitlab/github_import/attachments/import_issue_worker.rb,
app/workers/gitlab/github_import/stage/import_attachments_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/representation/diff_notes/discussion_id.rb,
app/workers/gitlab/github_import/stage/import_issue_events_worker.rb,
app/workers/gitlab/github_import/attachments/import_release_worker.rb,
app/workers/gitlab/github_import/stage/import_collaborators_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/pull_requests/import_review_worker.rb,
lib/gitlab/github_import/importer/attachments/merge_requests_importer.rb,
lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer.rb,
lib/gitlab/github_import/representation/pull_requests/review_requests.rb,
app/workers/gitlab/github_import/pull_requests/import_merged_by_worker.rb,
lib/gitlab/github_import/importer/pull_requests/all_merged_by_importer.rb,
lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer.rb,
app/workers/gitlab/github_import/stage/import_protected_branches_worker.rb,
lib/gitlab/github_import/importer/pull_requests/review_request_importer.rb,
lib/gitlab/github_import/importer/single_endpoint_issue_events_importer.rb,
lib/gitlab/github_import/representation/diff_notes/suggestion_formatter.rb,
app/workers/gitlab/github_import/attachments/import_merge_request_worker.rb,
lib/gitlab/github_import/importer/pull_requests/review_requests_importer.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/pull_requests/import_review_request_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,
app/workers/gitlab/github_import/stage/import_pull_requests_review_requests_worker.rb
Defined Under Namespace
Modules: Attachments, BulkImporting, Clients, Exceptions, Importer, JobDelayCalculator, Markdown, ObjectImporter, ParallelScheduling, PullRequests, Queue, Representation, ReschedulingMethods, SingleEndpointNotesImporting, Stage, StageMethods Classes: AdvanceStageWorker, AttachmentsDownloader, Client, ClientPool, ImportCollaboratorWorker, ImportDiffNoteWorker, ImportIssueEventWorker, ImportIssueWorker, ImportLfsObjectWorker, ImportNoteWorker, ImportProtectedBranchWorker, ImportPullRequestWorker, IssuableFinder, LabelFinder, Logger, MarkdownText, MilestoneFinder, ObjectCounter, PageCounter, ParallelImporter, ProjectRelationType, RefreshImportJidWorker, SequentialImporter, Settings, 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
-
.formatted_import_url(project) ⇒ Object
Get formatted GitHub import URL.
-
.ghost_user_id ⇒ Object
Returns the ID of the ghost user.
- .new_client_for(project, token: nil, host: nil, parallel: true) ⇒ Object
- .per_page(project) ⇒ Object
- .refmap ⇒ Object
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
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gitlab/github_import.rb', line 33 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_id ⇒ Object
Returns the ID of the ghost user.
26 27 28 29 30 |
# File 'lib/gitlab/github_import.rb', line 26 def self.ghost_user_id key = 'github-import/ghost-user-id' Gitlab::Cache::Import::Caching.read_integer(key) || Gitlab::Cache::Import::Caching.write(key, Users::Internal.ghost.id) end |
.new_client_for(project, token: nil, host: nil, parallel: true) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# 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) token_pool = project.import_data&.credentials&.dig(:additional_access_tokens) = { host: host.presence || self.formatted_import_url(project), per_page: self.per_page(project), parallel: parallel } if token_pool ClientPool.new(token_pool: token_pool.append(token_to_use), **) else Client.new(token_to_use, **) end end |
.per_page(project) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/gitlab/github_import.rb', line 44 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 |
.refmap ⇒ Object
5 6 7 |
# File 'lib/gitlab/github_import.rb', line 5 def self.refmap [:heads, :tags, '+refs/pull/*/head:refs/merge-requests/*/head'] end |