Commit Graph

51 Commits

Author SHA1 Message Date
GitLab Bot b3bdfebdb7 Add latest changes from gitlab-org/gitlab@master 2024-12-10 18:31:27 +00:00
GitLab Bot f3b09181be Add latest changes from gitlab-org/gitlab@master 2024-07-10 21:35:01 +00:00
GitLab Bot 881435f2a3 Add latest changes from gitlab-org/gitlab@master 2023-10-19 12:11:29 +00:00
GitLab Bot 5cbf24858e Add latest changes from gitlab-org/gitlab@master 2023-10-17 18:10:11 +00:00
GitLab Bot 672c5fcf46 Add latest changes from gitlab-org/gitlab@master 2023-08-28 18:11:00 +00:00
GitLab Bot 5ff1f808ad Add latest changes from gitlab-org/gitlab@master 2023-05-15 18:10:04 +00:00
GitLab Bot 5db6a7a014 Add latest changes from gitlab-org/gitlab@master 2023-01-05 15:08:39 +00:00
GitLab Bot 17c478bc80 Add latest changes from gitlab-org/gitlab@master 2022-12-15 00:08:38 +00:00
GitLab Bot 4279dbc29c Add latest changes from gitlab-org/gitlab@master 2022-11-15 15:08:26 +00:00
GitLab Bot e55ef824f5 Add latest changes from gitlab-org/gitlab@master 2022-10-10 12:10:24 +00:00
GitLab Bot 146284d119 Add latest changes from gitlab-org/gitlab@master 2022-10-05 12:09:04 +00:00
GitLab Bot e99d2e196c Add latest changes from gitlab-org/gitlab@master 2022-09-30 12:08:43 +00:00
GitLab Bot 99aa31992d Add latest changes from gitlab-org/gitlab@master 2022-09-15 18:10:36 +00:00
GitLab Bot 16daf112d6 Add latest changes from gitlab-org/gitlab@master 2022-09-14 12:12:34 +00:00
GitLab Bot 91035102b4 Add latest changes from gitlab-org/gitlab@master 2022-08-03 12:11:38 +00:00
GitLab Bot fee19ef336 Add latest changes from gitlab-org/gitlab@master 2021-11-23 18:12:49 +00:00
GitLab Bot 21db5294d4 Add latest changes from gitlab-org/gitlab@master 2021-08-19 18:10:32 +00:00
GitLab Bot 1c568d834d Add latest changes from gitlab-org/gitlab@master 2021-05-05 09:10:02 +00:00
GitLab Bot 1361891b0a Add latest changes from gitlab-org/gitlab@master 2020-12-09 12:09:42 +00:00
GitLab Bot 8e9cf65bd7 Add latest changes from gitlab-org/gitlab@master 2020-11-29 18:09:41 +00:00
GitLab Bot bde0c40776 Add latest changes from gitlab-org/gitlab@master 2020-11-28 06:09:28 +00:00
GitLab Bot c19dce027b Add latest changes from gitlab-org/gitlab@master 2020-11-13 21:09:31 +00:00
GitLab Bot a22f031743 Add latest changes from gitlab-org/gitlab@master 2020-10-28 03:08:41 +00:00
GitLab Bot 85e494935a Add latest changes from gitlab-org/gitlab@master 2020-01-14 15:07:55 +00:00
manojmj c93ce83693 Do not allow localhost url redirection in GitHub Integration 2019-07-05 15:09:04 +05:30
Rubén Dávila afe2c15e6b Fix provider server URL used when listing repos to import
Also use Gitlab::Auth::OAuth::Provider.config_for to access OmniAuth config
2018-03-12 16:01:43 -05:00
Lin Jen-Shin 4f00a05152 Introduce PredicateMemoization cop and fix offenses
with StrongMemoize
2018-01-12 17:54:55 +08:00
Yorick Peterse f37fe2edc8
Support importing GH projects without rate limits
GitHub Enterprise disables rate limiting for the API, resulting in HTTP
404 errors when requesting rate limiting details. This changes
Gitlab::GithubImport::Client so it can deal with rate limiting being
disabled.
2017-11-08 21:37:01 +01:00
Yorick Peterse 2b886a7815
Restore Enterprise support in the GH importer
This was removed by accident as the old GitHub importer handled this
deep down the codebase, making it easy to miss.
2017-11-08 18:06:03 +01:00
Yorick Peterse 4dfe26cd8b
Rewrite the GitHub importer from scratch
Prior to this MR there were two GitHub related importers:

* Github::Import: the main importer used for GitHub projects
* Gitlab::GithubImport: importer that's somewhat confusingly used for
  importing Gitea projects (apparently they have a compatible API)

This MR renames the Gitea importer to Gitlab::LegacyGithubImport and
introduces a new GitHub importer in the Gitlab::GithubImport namespace.
This new GitHub importer uses Sidekiq for importing multiple resources
in parallel, though it also has the ability to import data sequentially
should this be necessary.

The new code is spread across the following directories:

* lib/gitlab/github_import: this directory contains most of the importer
  code such as the classes used for importing resources.
* app/workers/gitlab/github_import: this directory contains the Sidekiq
  workers, most of which simply use the code from the directory above.
* app/workers/concerns/gitlab/github_import: this directory provides a
  few modules that are included in every GitHub importer worker.

== Stages

The import work is divided into separate stages, with each stage
importing a specific set of data. Stages will schedule the work that
needs to be performed, followed by scheduling a job for the
"AdvanceStageWorker" worker. This worker will periodically check if all
work is completed and schedule the next stage if this is the case. If
work is not yet completed this worker will reschedule itself.

Using this approach we don't have to block threads by calling `sleep()`,
as doing so for large projects could block the thread from doing any
work for many hours.

== Retrying Work

Workers will reschedule themselves whenever necessary. For example,
hitting the GitHub API's rate limit will result in jobs rescheduling
themselves. These jobs are not processed until the rate limit has been
reset.

== User Lookups

Part of the importing process involves looking up user details in the
GitHub API so we can map them to GitLab users. The old importer used
an in-memory cache, but this obviously doesn't work when the work is
spread across different threads.

The new importer uses a Redis cache and makes sure we only perform
API/database calls if absolutely necessary.  Frequently used keys are
refreshed, and lookup misses are also cached; removing the need for
performing API/database calls if we know we don't have the data we're
looking for.

== Performance & Models

The new importer in various places uses raw INSERT statements (as
generated by `Gitlab::Database.bulk_insert`) instead of using Rails
models. This allows us to bypass any validations and callbacks,
drastically reducing the number of SQL queries and Gitaly RPC calls
necessary to import projects.

To ensure the code produces valid data the corresponding tests check if
the produced rows are valid according to the model validation rules.
2017-11-07 23:24:59 +01:00
Robert Speicher 260c8da060 Whitelist or fix additional `Gitlab/PublicSend` cop violations
An upcoming update to rubocop-gitlab-security added additional
violations.
2017-08-14 12:14:11 -04:00
Douglas Barbosa Alexandre 7da13fee84 Add a simple cache for Gitlab::GithubImport::Client#user 2017-02-20 14:48:12 -03:00
Rémy Coutable 99ddd1dcbe Modify GithubImport to support Gitea
The reason is that Gitea plan to be GitHub-compatible so it makes sense
to just modify GitHubImport a bit for now, and hopefully we can change
it to GitHubishImport once Gitea is 100%-compatible.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-19 17:35:51 +01:00
Kim "BKC" Carlbäcker 5d4531db25 Gogs Importer 2016-12-19 17:35:51 +01:00
Ahmad Sherif f68d9261b0 Fix typos 2016-10-28 11:30:20 +02:00
Ahmad Sherif 4259334fb6 Fix applying labels for GitHub-imported MRs 2016-10-27 15:42:28 +02:00
Ahmad Sherif 333c02a8c8 Fix broken handling of certain calls in GitHub importer client
Closes #22998
2016-10-06 11:14:25 +02:00
Ahmad Sherif 395a9301b2 Process each page of GitHub resources instead of concating them then processing
This should avoid having large memory growth when importing GitHub repos
with lots of resources.
2016-09-27 20:45:07 +02:00
Douglas Barbosa Alexandre 78a5de99e9 Memoize response from `has_rate_limit?` to avoid extra API call 2016-07-12 12:14:17 -03:00
Douglas Barbosa Alexandre be9262dd95 Checks if rate limit is enabled instead of stubbing response 2016-07-12 12:14:17 -03:00
Douglas Barbosa Alexandre 38a58978aa Fix GItHub client requests when rate limit is disabled 2016-07-12 12:14:17 -03:00
Eric K Idema 12aa1f898d Import from Github using Personal Access Tokens.
This stands as an alternative to using OAuth to access a user's Github
repositories.  This is setup in such a way that it can be used without OAuth
configuration.

From a UI perspective, the how to import modal has been replaced by a full
page, which includes a form for posting a personal access token back to the
Import::GithubController.

If the user has logged in via GitHub, skip the Personal Access Token and go
directly to Github for an access token via OAuth.
2016-06-30 18:48:17 +02:00
Douglas Barbosa Alexandre cef3fd2899 Wrap all rate limiting logic inside GitHub API client 2016-06-09 12:43:06 -03:00
Stan Hu eede032345 Backport GitHub Enterprise import support from EE
These changes were pulled from GitLab EE to support configuring
an alternative API URL than the default https://api.github.com.
In addition, the `verify_ssl` flag allows users to disable SSL cert
checking.

One modification: add a default `args` option if it does not exist
to avoid breaking existing configurations.
2016-04-26 21:00:55 -07:00
Valery Sizov e92ceb7b57 fix specs 2015-11-30 16:12:31 +02:00
Stan Hu 5cce0645b0 Fix OAuth2 issue importing a new project from GitHub and GitLab
Closes #1268
2015-03-22 18:16:48 -07:00
Douwe Maan 2718955441 Fix import pages not working after first load. 2015-03-13 13:47:26 +01:00
Douwe Maan ad6d623234 Add Bitbucket importer. 2015-02-24 15:07:24 +01:00
Valery Sizov b3c90dd514 GitHub importer refactoring 2015-02-05 21:48:21 -08:00
Valery Sizov 33349dd549 GitLab.com integration: refactoring 2015-02-05 12:50:34 -08:00