Commit Graph

39 Commits

Author SHA1 Message Date
GitLab Bot c753fd0bf4 Add latest changes from gitlab-org/gitlab@master 2021-09-30 18:11:31 +00:00
GitLab Bot dd18ae74af Add latest changes from gitlab-org/gitlab@master 2021-07-08 12:08:30 +00:00
GitLab Bot be4b3134a2 Add latest changes from gitlab-org/gitlab@master 2021-05-04 15:10:36 +00:00
GitLab Bot e5e0589e09 Add latest changes from gitlab-org/gitlab@master 2021-04-26 12:09:44 +00:00
GitLab Bot 7b2635a55d Add latest changes from gitlab-org/gitlab@master 2020-12-01 12:09:17 +00:00
GitLab Bot a662b146ac Add latest changes from gitlab-org/gitlab@master 2020-11-05 12:09:05 +00:00
GitLab Bot a22f031743 Add latest changes from gitlab-org/gitlab@master 2020-10-28 03:08:41 +00:00
GitLab Bot eb004dc626 Add latest changes from gitlab-org/gitlab@master 2020-10-27 12:08:33 +00:00
GitLab Bot 0790cf032c Add latest changes from gitlab-org/gitlab@master 2020-08-06 21:10:15 +00:00
GitLab Bot 58320d8e03 Add latest changes from gitlab-org/gitlab@master 2020-07-29 15:09:39 +00:00
GitLab Bot f697dc5e76 Add latest changes from gitlab-org/gitlab@master 2020-04-14 18:09:54 +00:00
GitLab Bot 0d0cddc9ce Add latest changes from gitlab-org/gitlab@master 2020-03-31 12:08:09 +00:00
GitLab Bot 154b9bae14 Add latest changes from gitlab-org/gitlab@master 2020-03-17 21:09:16 +00:00
GitLab Bot 85e494935a Add latest changes from gitlab-org/gitlab@master 2020-01-14 15:07:55 +00:00
GitLab Bot d96abbee0b Add latest changes from gitlab-org/gitlab@master 2019-10-10 15:06:07 +00:00
GitLab Bot 80f61b4035 Add latest changes from gitlab-org/gitlab@master 2019-09-18 14:02:45 +00:00
manojmj c93ce83693 Do not allow localhost url redirection in GitHub Integration 2019-07-05 15:09:04 +05:30
Jason Goodman 7ecffe2987 Show upcoming status for releases
Add released_at field to releases API
Add released_at column to releases table
Return releases to the API sorted by released_at
2019-07-03 09:12:15 +00:00
John Kristensen e47d9b3d04 Don't import pull request comments from Gitea repos
The Gitea API does not provide the following API endpoint for pull request
comments:

  /api/v1/repos/{owner}/{repo}/pulls/comments

When the importer attempts to request this endpoint it receives a '404
Not Found' error which causes the import to fail. By skipping any
attempts to import pull requests comments from Gitea we can ensure that
the import can complete successfully.
2019-06-12 00:52:54 +00:00
Douwe Maan e861af409d Merge branch '47327-fix-github-project-import-visibility' into 'master'
Fix GitHub project import visibility

See merge request gitlab-org/gitlab-ce!27133
2019-04-10 09:10:37 +00:00
Jason Goodman 5b7003282b Set release name when adding release notes to an existing tag
Also set the release sha and author
2019-04-09 06:52:15 +00:00
Daniel Wyatt 26fdcf7b61 Fix GitHub project import visibility 2019-04-08 11:39:57 -04:00
Nick Thomas 9f05e97aad
Run rubocop -a 2019-03-13 13:42:43 +00:00
Andrew Newdigate 3288e1a874 Adds the Rubocop ReturnNil cop
This style change enforces `return if ...` instead of
`return nil if ...` to save maintainers a few minor review points
2019-03-06 17:51:56 +02:00
Stan Hu a9ab6dbc63 Refactor use of Shell.import_repository for Wikis
The previous behavior would pass in a list of parameters
to Shell, but we can improve this by using the WikiFormatter
and Project models to give us the same information.
2019-02-05 21:33:09 -08:00
Stan Hu 82b6e5378a Send project name with Gitaly repository requests
When hashed storage is in use, it's helpful to have the project
name associated with the request.

Closes https://gitlab.com/gitlab-org/gitaly/issues/1394
2019-02-05 21:33:09 -08:00
Tiago Botelho 4bd8a427d4
Removes all the irrelevant import related code and columns
Clears the import related columns and code from the Project
model over to the ProjectImportState model
2018-11-27 12:58:13 +00:00
gfyoung 7ec8af5017 Enable even more frozen string for lib/gitlab
Enables frozen string for the following:

* lib/gitlab/hook_data/**/*.rb
* lib/gitlab/i18n/**/*.rb
* lib/gitlab/import/**/*.rb
* lib/gitlab/import_export/**/*.rb
* lib/gitlab/kubernetes/**/*.rb
* lib/gitlab/legacy_github_import/**/*.rb
* lib/gitlab/manifest_import/**/*.rb
* lib/gitlab/metrics/**/*.rb
* lib/gitlab/middleware/**/*.rb

Partially addresses gitlab-org/gitlab-ce#47424.
2018-11-16 17:41:14 -08:00
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Imre Farkas c5e44dc5d1
Use Github repo visibility during import while respecting restricted visibility levels 2018-06-06 12:00:15 +02:00
Tiago Botelho bddbcaefc2 Backports every CE related change from ee-44542 to CE 2018-05-04 17:33:26 +02:00
Ahmad Sherif ddfc661f79 Use shard name in Git::GitlabProjects instead of shard path
Closes gitaly#1110
2018-04-03 16:22:13 +02:00
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
Rubén Dávila d179f002d9 CE backport for creating CI/CD projects from GitHub 2018-03-07 10:58:50 -05:00
Mario de la Ossa eaada9d706 use Gitlab::UserSettings directly as a singleton instead of including/extending it 2018-02-02 18:39:55 +00:00
Douwe Maan 7a1e93d35b Rename fetch_refs to refmap 2017-11-23 16:59:58 +01:00
Douwe Maan 0e6beaf50c Clean up repository fetch and mirror methods 2017-11-23 16:59:50 +01:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +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