Commit Graph

391 Commits

Author SHA1 Message Date
GitLab Bot ec3483bd18 Add latest changes from gitlab-org/gitlab@master 2021-07-26 09:09:00 +00:00
GitLab Bot d81dc2a54e Add latest changes from gitlab-org/gitlab@master 2021-07-22 18:08:29 +00:00
GitLab Bot e1189e4c3b Add latest changes from gitlab-org/gitlab@master 2021-07-13 15:08:38 +00:00
GitLab Bot dd18ae74af Add latest changes from gitlab-org/gitlab@master 2021-07-08 12:08:30 +00:00
GitLab Bot 098ec8c914 Add latest changes from gitlab-org/gitlab@master 2021-07-01 12:08:37 +00:00
GitLab Bot dbb27a9153 Add latest changes from gitlab-org/gitlab@master 2021-06-30 03:07:30 +00:00
GitLab Bot 92e314ffe8 Add latest changes from gitlab-org/gitlab@master 2021-06-22 19:11:50 +00:00
GitLab Bot 3ab7e70965 Add latest changes from gitlab-org/gitlab@master 2021-06-21 09:10:07 +00:00
GitLab Bot d715acda3b Add latest changes from gitlab-org/gitlab@master 2021-06-10 18:10:05 +00:00
GitLab Bot 03c84e0de5 Add latest changes from gitlab-org/gitlab@master 2021-05-27 06:10:47 +00:00
GitLab Bot f24e50f0a5 Add latest changes from gitlab-org/gitlab@master 2021-05-18 03:10:38 +00:00
GitLab Bot 170926ba28 Add latest changes from gitlab-org/gitlab@master 2021-05-17 09:10:26 +00:00
GitLab Bot 0ae8428c8e Add latest changes from gitlab-org/gitlab@master 2021-05-11 21:10:21 +00:00
GitLab Bot f020d5dc9b Add latest changes from gitlab-org/gitlab@master 2021-05-11 18:10:36 +00:00
GitLab Bot 1c568d834d Add latest changes from gitlab-org/gitlab@master 2021-05-05 09:10:02 +00:00
GitLab Bot e5e0589e09 Add latest changes from gitlab-org/gitlab@master 2021-04-26 12:09:44 +00:00
GitLab Bot 7fcda12793 Add latest changes from gitlab-org/gitlab@master 2021-03-03 15:10:53 +00:00
GitLab Bot b2452a3692 Add latest changes from gitlab-org/gitlab@master 2021-02-25 12:11:01 +00:00
GitLab Bot fcef382cb9 Add latest changes from gitlab-org/gitlab@master 2021-01-19 09:10:32 +00:00
GitLab Bot 1361891b0a Add latest changes from gitlab-org/gitlab@master 2020-12-09 12:09:42 +00:00
GitLab Bot 259aa13174 Add latest changes from gitlab-org/gitlab@master 2020-12-01 00:09:28 +00:00
GitLab Bot ace0df53d3 Add latest changes from gitlab-org/gitlab@master 2020-11-30 18:09:46 +00:00
GitLab Bot b84dc94fbd Add latest changes from gitlab-org/gitlab@master 2020-11-29 21:09:24 +00:00
GitLab Bot 8e9cf65bd7 Add latest changes from gitlab-org/gitlab@master 2020-11-29 18:09:41 +00:00
GitLab Bot 518aebfe14 Add latest changes from gitlab-org/gitlab@master 2020-11-29 09:09:27 +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 71da5de44f Add latest changes from gitlab-org/gitlab@master 2020-08-05 15:09:59 +00:00
GitLab Bot 86e1f47cd1 Add latest changes from gitlab-org/gitlab@master 2020-06-05 15:08:23 +00:00
GitLab Bot 0d8e625e4c Add latest changes from gitlab-org/gitlab@master 2020-05-25 15:07:58 +00:00
GitLab Bot 0f59ad0c29 Add latest changes from gitlab-org/gitlab@master 2020-04-28 09:09:34 +00:00
GitLab Bot 04baa85554 Add latest changes from gitlab-org/gitlab@master 2020-04-03 09:09:31 +00:00
GitLab Bot 154b9bae14 Add latest changes from gitlab-org/gitlab@master 2020-03-17 21:09:16 +00:00
GitLab Bot 8957ace315 Add latest changes from gitlab-org/gitlab@master 2020-03-14 00:09:30 +00:00
GitLab Bot 85e494935a Add latest changes from gitlab-org/gitlab@master 2020-01-14 15:07:55 +00:00
GitLab Bot 5eb11b697d Add latest changes from gitlab-org/gitlab@master 2020-01-06 18:08:01 +00:00
GitLab Bot d10a462fed Add latest changes from gitlab-org/gitlab@master 2019-12-16 12:07:43 +00:00
GitLab Bot 8cc5f27909 Add latest changes from gitlab-org/gitlab@master 2019-12-13 12:07:41 +00:00
GitLab Bot b570d73ecd Add latest changes from gitlab-org/gitlab@master 2019-11-19 12:06:00 +00:00
GitLab Bot d96abbee0b Add latest changes from gitlab-org/gitlab@master 2019-10-10 15:06:07 +00:00
GitLab Bot 759cd6c298 Add latest changes from gitlab-org/gitlab@master 2019-09-26 09:06:04 +00:00
GitLab Bot d46287cc16 Add latest changes from gitlab-org/gitlab@master 2019-09-20 12:05:52 +00:00
GitLab Bot b7dfe2ae40 Add latest changes from gitlab-org/gitlab@master 2019-09-13 13:26:31 +00:00
dineshpanda e908e11776 Avoid calling freeze on already frozen strings in lib/gitlab 2019-09-04 09:52:02 +05:30
Cindy Pallares 🦉 2b30423935 Add a field for released_at to GH importer 2019-08-09 00:06:21 +00:00
GitLab Release Tools Bot c4bc5dffa4 Merge branch 'security-github-ssrf-redirect' into 'master'
Do not allow localhost url redirection in GitHub Integration

See merge request gitlab/gitlabhq!3188
2019-07-26 13:41:05 +00:00
Mayra Cabrera 0ab89d8e36 Add a rubocop for Rails.logger
Suggests to use a JSON structured log instead

Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/54102
2019-07-10 19:26:47 +00:00
manojmj c93ce83693 Do not allow localhost url redirection in GitHub Integration 2019-07-05 15:09:04 +05:30
Bob Van Landuyt 589b2db06c Setup Phabricator import
This sets up all the basics for importing Phabricator tasks into
GitLab issues.

To import all tasks from a Phabricator instance into GitLab, we'll
import all of them into a new project that will have its repository
disabled.

The import is hooked into a regular ProjectImport setup, but similar
to the GitHub parallel importer takes care of all the imports itself.

In this iteration, we're importing each page of tasks in a separate
sidekiq job.

The first thing we do when requesting a new page of tasks is schedule
the next page to be imported. But to avoid deadlocks, we only allow a
single job per worker type to run at the same time.

For now we're only importing basic Issue information, this should be
extended to richer information.
2019-05-31 09:40:54 +02:00
Felipe Artur c40bad741f Fix issuables state_id nil when importing projects from GitHub
Issues and merge requests imported from GitHub are having state_id
set to null. This fixes the GitHub project importer and schedule
migrations to fix state_id.
2019-05-06 19:45:17 +00:00
Stan Hu f93b2e02a5 Run rubocop -a on CE files 2019-05-05 03:24:28 -07:00
Stan Hu d7c1bed80d GitHub import: Run housekeeping after initial import
After an initial fetch, the repository will have many loose objects
and refs. Running a `git gc` will compact refs into `packed-refs` and
objects into `.pack` files, which should make importing pull
requests faster.

Part of https://gitlab.com/gitlab-org/gitlab-ce/issues/59477
2019-04-07 06:56:49 -07:00
Stan Hu d0336ae88f GitHub importer: Use the project creator to create branches from forks
The project owner may actually be a group, in which case the branch
creation would fail due to a lack of username.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59396
2019-03-23 07:29:35 -07:00
Kamil Trzciński 98194f1766 Set proper default-branch on GitHub Import 2019-03-22 18:40:50 +00:00
Stan Hu 1e6ea914a1 GitHub import: Create new branches as project owner
This avoids permission errors when importing merge requests whose
authors don't have direct access to push to the main repository.
2019-03-19 11:23:00 -07:00
Diana Stanley 63b89f0485 Protect against nil due_on value in imported data 2019-02-26 12:04:12 -08:00
Diana Stanley d24ea868ab Capture due date when importing milestones from Github 2019-02-20 15:09:27 -08:00
Stan Hu e34a321327 Create the source branch for a GitHub import
When the GitHub importer creates a merge request, it retrieves the SHA
but does not actually create the source branch. This makes it impossible
to merge an open merge request, particularly if the source branch were
from a forked project. In that case, the branch will never exist because
the original `project-name:source-branch` name is never created, nor
is it a valid branch name.

To prevent possible branch name conflicts, forked source branches
are now renamed `github/fork/project-name/source-branch` and created
when necessary.

Note that we only create the source branch if the merge request
is open. For projects that have many merge requests, the project
would end up with a lot of possibly dead branches.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/57370
2019-02-11 22:00:05 -08: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
Francisco Javier López b3c13bbb3c
Added validations to prevent LFS object forgery 2019-01-31 16:51:54 +01:00
Andreas Brandl 820739eb09
Revert "Trigger iid logic from GitHub importer for issues."
This reverts commit b78a69b06c.
2019-01-29 15:38:40 +01:00
Andreas Brandl 852e68fd95
Revert "Trigger iid logic from GitHub importer for milestones."
This reverts commit 358675d09f.
2019-01-29 15:38:40 +01: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
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
Jacopo c6bddeacf4 Updates code using class_methods over module ClassMethods 2018-08-29 16:56:34 +02:00
Stan Hu 0377c015cf Refactor GitHub Importer database helpers into helper methods
This in preparation for addressing idle-in-transaction timeouts for other importers.

Part of #50021
2018-08-24 05:34:38 -07:00
Yorick Peterse 6f3c490107
Refactor AutocompleteController
This refactors the AutocompleteController according to the guidelines
and boundaries discussed in
https://gitlab.com/gitlab-org/gitlab-ce/issues/49653. Specifically,
ActiveRecord logic is moved to different finders, which are then used in
the controller. View logic in turn is moved to presenters, instead of
directly using ActiveRecord's "to_json" method.

The finder MoveToProjectFinder is also adjusted according to the
abstraction guidelines and boundaries, resulting in a much more simple
finder.

By using finders (and other abstractions) more actively, we can push a
lot of logic out of the controller. We also remove the need for various
"before_action" hooks, though this could be achieved without using
finders as well.

The various finders related to AutcompleteController have also been
moved into a namespace. This removes the need for calling everything
"AutocompleteSmurfFinder", instead you can use
"Autocomplete::SmurfFinder".
2018-08-20 13:53:00 +02:00
Andreas Brandl fb98496f49
Trigger iid logic from GitHub importer for merge requests. 2018-08-16 10:01:02 +02:00
Andreas Brandl 358675d09f
Trigger iid logic from GitHub importer for milestones. 2018-08-16 10:01:02 +02:00
Andreas Brandl b78a69b06c
Trigger iid logic from GitHub importer for issues. 2018-08-16 10:01:02 +02:00
Yorick Peterse 9e29408ee6
Don't expose project names in various counters
Various counters would expose either project names, or full project
paths (e.g. "gitlab-org/gitlab-ce"). This commit changes various places
where we use "add_event" so we no longer expose (potentially) private
information.
2018-06-21 16:56:40 +02:00
Lin Jen-Shin c61392b4e4 Bring changes from EE for parallel_importer.rb 2018-06-14 02:05:01 +08:00
Yorick Peterse e4612df0e2
Ensure MR diffs always exist in the PR importer
In rare cases it could happen that an MR was created, but creating the
MR diffs somehow failed (e.g. due to an error). This commit adds an
additional check to make sure MR diffs are always present when importing
GitHub pull requests.
2018-06-12 13:30:41 +02:00
Stan Hu 6defeb0a7d Expire Wiki content cache after importing a repository
The cache state for Wikis that were imported via GitHub or Bitbucket does
not appear to have been flushed after a successful import.

Closes #47546
2018-06-11 08:33:06 -07:00
Francisco Javier López e8f49b4bee Support LFS objects when creating a project by import 2018-06-06 16:42:18 +00:00
Yorick Peterse 71ed7987d3
Perform pull request IO work outside a transaction
When importing a GitHub pull request we would perform all work in a
single database transaction. This is less than ideal, because we perform
various slow Git operations when creating a merge request. This in turn
can lead to many DB connections being used, while just waiting for an IO
operation to complete.

To work around this, we now move most of the heavy lifting out of the
database transaction. Some extra error handling is added to ensure we
can resume importing a partially imported pull request, instead of just
throwing an error.

This commit also changes the specs for IssueImporter so they don't rely
on deprecated RSpec methods.
2018-06-04 18:33:56 +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
Zeger-Jan van de Weg 11a483649e
Test if remote repository exists before cloning
When a repository does not exist on a remote, Gitaly won't be able to
clone it. This is correct behaviour, but from the clients perspective a
change in behaviour.

This change implements the client side changes that allows Gitaly to
execute a `git ls-remote <remote-url> HEAD`. This way the client has no
need to shell out to Git.

In the situation where multiple Gitalies are available, one is chosen at
random.

This commit closes https://gitlab.com/gitlab-org/gitlab-ce/issues/43929,
while its also a part of https://gitlab.com/gitlab-org/gitaly/issues/1084
2018-03-27 14:43:21 +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
Valery Sizov 69b750aee9 [GH Import] Create an empty wiki if wiki import failed 2018-02-19 17:56:33 +00:00
Takuya Noguchi 2b6307f6ad Enable RuboCop Style/RegexpLiteral 2018-02-01 02:06:07 +09:00
Jacob Vosmaer 6d6f7536bd Look for rugged with static analysis 2018-01-25 14:05:11 +01:00
Lin Jen-Shin 4f00a05152 Introduce PredicateMemoization cop and fix offenses
with StrongMemoize
2018-01-12 17:54:55 +08:00
Zeger-Jan van de Weg 338f1eaf35
Migrate to Project#empty_repo? 2017-12-20 19:13:11 +01: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
Douwe Maan 8da236611b Prefer polymorphism over specific type checks in Import service 2017-11-15 13:40:35 +01: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
Nick Thomas 314e5b5f20
Use wiki.disk_path 2017-10-18 12:53:06 +01:00
Alejandro Rodríguez 9fdde3693b Move line code generation into Gitlab::Git
Having a distinct class just for that was a bit overkill
2017-10-12 22:13:05 -03:00
Alejandro Rodríguez faa9bd402d Create a Gitlab::Git submodule for conlict-related files
Rename classes to (hopefully) clearer names while we're doing that.
2017-10-12 22:03:15 -03:00
Alejandro Rodríguez f72598b659 Move Gitlab::Diff::LineCode to module Gitlab::Git 2017-10-12 21:45:16 -03:00
Ahmad Sherif 41ef94e777 Migrate creating/deleting a branch to Gitaly 2017-09-06 17:25:17 +02: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
Gabriel Mazetto fb06a4d8fe Rename more path_with_namespace -> full_path or disk_path 2017-08-01 07:28:13 +02:00
Gabriel Mazetto abb878326c Rename many path_with_namespace -> full_path 2017-08-01 07:26:58 +02:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Douglas Barbosa Alexandre a6affc66dc Rename skip_metrics to imported on the importable concern 2017-04-03 15:50:22 -03:00
Douglas Barbosa Alexandre 20486593bd Skip MR metrics when importing projects from GitHub 2017-04-03 15:50:22 -03:00
Douglas Barbosa Alexandre 336ba94a7b Fetch GitHub project as a mirror to get all refs at once 2017-04-03 15:50:22 -03:00
Gabriel Mazetto 3c75ee2823 Minor refactor 2017-04-03 12:45:31 +02:00
Douglas Barbosa Alexandre c8273ba858 Fix BrachFormatter for removed users 2017-04-03 12:45:31 +02:00
Gabriel Mazetto 291bd873d3 One more change to the branch names to preserve metadata 2017-04-03 12:45:31 +02:00
Douglas Barbosa Alexandre 59588ebac0 Prefixes source branch name with short SHA to avoid collision 2017-04-03 12:45:31 +02:00
Gabriel Mazetto a3e65ef021 Fix GitHub importer for PRs of deleted forked repositories 2017-04-03 12:45:31 +02:00
Gabriel Mazetto a996880bf7 Using guard clause and added more specs 2017-03-10 21:13:45 +01:00
Gabriel Mazetto 9b53cb6c88 Fix GitHub Import for open PRs from a fork 2017-03-10 21:08:21 +01:00
Gabriel Mazetto ce35dcbc81 Refactor some code 2017-03-08 19:42:21 +01:00
Gabriel Mazetto 26fa716dd2 Fix name colision when importing GitHub pull requests from forked repositories 2017-03-08 19:42:21 +01:00
Douglas Barbosa Alexandre ec4b03a4c6 Fix 'Object not found - no match for id (sha)' when importing GitHub PRs 2017-03-07 15:59:07 -03:00
Douwe Maan 56de781a2c Revert "Enable Style/DotPosition"
This reverts commit e00fb2bdc2090e9cabeb1eb35a2672a882cc96e9.

# Conflicts:
#	.rubocop.yml
#	.rubocop_todo.yml
#	lib/gitlab/ci/config/entry/global.rb
#	lib/gitlab/ci/config/entry/jobs.rb
#	spec/lib/gitlab/ci/config/entry/factory_spec.rb
#	spec/lib/gitlab/ci/config/entry/global_spec.rb
#	spec/lib/gitlab/ci/config/entry/job_spec.rb
#	spec/lib/gitlab/ci/status/build/factory_spec.rb
#	spec/lib/gitlab/incoming_email_spec.rb
2017-02-23 09:33:19 -06:00
Douwe Maan 1fe7501b49 Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
2017-02-23 09:33:05 -06:00
Douwe Maan 75f5fa997d Enable Rails/Delegate 2017-02-23 09:32:42 -06:00
Douwe Maan 206953a430 Prefer leading style for Style/DotPosition 2017-02-23 09:32:22 -06:00
Douwe Maan 030baf70d2 Enable Performance/RedundantMerge 2017-02-23 09:31:57 -06:00
Douwe Maan 3dadf306dd Enable Style/DotPosition 2017-02-23 09:31:56 -06:00
Douglas Barbosa Alexandre 43b1f5e40d Reuse User#find_by_any_email on UserFormatter#find_by_email 2017-02-20 14:48:12 -03:00
Douglas Barbosa Alexandre 20128693eb Use leading periods on UserFormatter#find_by_external_uid 2017-02-20 14:48:12 -03:00
Douglas Barbosa Alexandre 7da13fee84 Add a simple cache for Gitlab::GithubImport::Client#user 2017-02-20 14:48:12 -03:00
Douglas Barbosa Alexandre 2d1e0a0811 GitHub Importer - Find users based on their email address
The returned email by the GitHub API is the user's publicly visible
email address (or null if the user has not specified a public email
address in their profile)
2017-02-20 14:48:12 -03:00
Robert Speicher 414d695db7 Merge branch 'fix-github-import-MR-wrong-project' into 'security'
Fix labels being applied to wrong merge requests on GitHub import

See https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2064
2017-02-15 10:42:56 -05:00
Grzegorz Bizon 632c2939bb Revert "Merge branch 'revert-9cac0317' into 'master' "
This reverts commit c20934869f, reversing
changes made to 4b7ec44b91.
2017-01-23 16:35:24 +01:00
Grzegorz Bizon baeaa97ef4 Revert "Merge branch 'dont-persist-application-settings-in-test-env' into 'master'"
This reverts merge request !8573
2017-01-21 22:55:35 +00:00
Rémy Coutable f6cc29ed83 Don't persist ApplicationSetting in test env
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-15 01:07:29 -05:00
Rémy Coutable ab06313c36 Add Project#gitea_import?
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-19 17:35:51 +01: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
Douglas Barbosa Alexandre 8ca040d8ae Fix branch validation for GitHub PR where repo/fork was renamed/deleted 2016-12-01 00:03:12 -02:00
Andrew Smith 3228798b37
Refactor github import to reduce number of API calls
Ref #24073
2016-11-18 07:47:00 +10:00
Ahmad Sherif eaa0303b3d Cache imported GH labels no matter what 2016-11-04 15:59:53 +02:00
Ahmad Sherif 6a9fb20fe1 Fix applying GitHub-imported labels when importing job is interrupted
Closes #24075
2016-11-04 15:59:53 +02:00
Douwe Maan 44cbfeaba8 Merge branch 'adam-fix-labels-find-or-create' into 'master'
Pass user instance to Labels::FindOrCreateService or skip_authorization: true

## What does this MR do?

It fixes a bug described in #23694 when `project.owner` was passed to `Labels::FindOrCreateService`. `Labels::FindOrCreateService` expected a user instance and `project.owner` may return a group as well. This MR makes sure that we either pass a user instance or `skip_authorization: true`.

## Are there points in the code the reviewer needs to double check?

- places where we pass `skip_authorization: true`

## Does this MR meet the acceptance criteria?

- Tests
  - [x] Added for this feature/bug
  - [ ] All builds are passing
- [ ] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

Fixes #23694

See merge request !7093
2016-10-28 15:01:59 +00:00
Adam Niedzielski e2c603696a Pass user instance to Labels::FindOrCreateService or skip_authorization: true
Do not pass project.owner because it may return a group and Labels::FindOrCreateService
throws an error in this case.
Fixes #23694.
2016-10-28 11:31:45 +02:00
Ahmad Sherif f68d9261b0 Fix typos 2016-10-28 11:30:20 +02:00
Ahmad Sherif 07275dd79c Abstract the use of imported[!?] and {current,increment}_page in GitHub importer 2016-10-28 11:30:20 +02:00
Ahmad Sherif bc6302b942 Use public_send instead of send 2016-10-28 11:30:20 +02:00
Ahmad Sherif 14fbd25d06 Modify GitHub importer to be retryable 2016-10-28 11:30:20 +02:00
Ahmad Sherif ce38ae8ca1 Fix importing MR comments from GitHub 2016-10-27 15:42:29 +02:00
Ahmad Sherif 4259334fb6 Fix applying labels for GitHub-imported MRs 2016-10-27 15:42:28 +02:00
Douglas Barbosa Alexandre 4f6d1c1d70 Rename Labels::CreateService to Labels::FindOrCreateService 2016-10-19 14:58:28 -02:00
Douglas Barbosa Alexandre f0ad0ceff5 Fix GitHub importer spec 2016-10-19 14:58:28 -02:00
Douglas Barbosa Alexandre d009d38ed6 User Labes::CreateService to create labels 2016-10-19 14:58:27 -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
Douglas Barbosa Alexandre b5f9541778 Skip wiki creation when GitHub project has wiki enabled
If the GitHub project repository has wiki, we should not create
the default wiki. Otherwise the GitHub importer will fail because
the wiki repository already exist.

This bug was introduced here
https://gitlab.com/gitlab-org/gitlab-ce/commit/892dea67717c0efbd6a28f763
9f34535ec0a8747
2016-10-04 13:06:45 -03:00
Ahmad Sherif dca1acd6a6 Call after_remove_branch only once after importing all GitHub PRs 2016-09-27 20:45:07 +02:00
Ahmad Sherif e30bfb809a Import all GitHub comments after importing issues and PRs 2016-09-27 20:45:07 +02:00
Ahmad Sherif dbcbbf262b Speed up label-applying process for GitHub importing
* No need to re-fetch issues from GH to read their labels, the labels
  are already there from the index request.
* No need to look up labels on the database for every application, so we
  cache them.
2016-09-27 20:45:07 +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
James Lopez 0c65112da7 modify github import JS and controller so we can now specify a namespace and/or name for a project.
- Fixed and added specs.
- Added different namespace options depending on user privilages
- Updated docs.
2016-09-20 10:14:39 +02:00
Andrew Smith 05b52e0f5e
Import GitHub release notes
# Conflicts:
#	lib/gitlab/github_import/importer.rb
2016-09-13 14:01:22 +10:00
Robert Speicher c87235a24d Merge branch '21569-dont-add-created-by-for-matched-users' into 'master'
Only add original author tag line when importing from GitHub if there isn't a linked GitLab account

## What does this MR do?
If there we've found a linked GitLab user for a creator of an issue or comment don't add the 'Created By:' line.

## What are the relevant issue numbers?

Closes #21569

See merge request !6081
2016-09-12 20:08:33 +00:00
Douglas Barbosa Alexandre 02761638f1 Avoid conflict with admin labels when importing GitHub labels 2016-09-09 11:22:38 -03:00
Andrew Smith 4a788f8a0c
Only add the original author if there isn't a linked GitLab account 2016-09-08 20:48:35 +10:00
Andrew Smith 9a9e22a88c
Rename `gl_user_id` to `gitlab_user_id` in importer classes 2016-09-08 11:57:22 +10:00
Douwe Maan d308a3f433 Merge branch 'issue_19734' into 'master'
Project tools visibility level

## part of #19734   

![project_features_access_level](/uploads/81ec7185d4e61d7578652020209af925/project_features_access_level.png)

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5606
2016-09-01 15:28:14 +00:00
Felipe Artur 892dea6771 Project tools visibility level 2016-09-01 11:47:59 -03:00
Douglas Barbosa Alexandre 9b376e772e GitHub importer use default project visibility for non-private projects 2016-08-31 18:27:42 -03:00
Douglas Barbosa Alexandre 80c4f10937 Don't touch Issue/Merge Request when importing GitHub comments 2016-08-31 13:20:28 -03:00
Douglas Barbosa Alexandre 52daddc0b7 Use updated_at as the last updated date when importing from GitHub 2016-08-31 13:20:28 -03:00
Douglas Barbosa Alexandre 2986de7c8c Add readable error message when remote data could not be fully imported 2016-08-24 12:17:13 -03:00
Douglas Barbosa Alexandre 3c09000e18 Does not halt the GitHub import process when an error occurs 2016-08-24 12:16:42 -03:00
Douglas Barbosa Alexandre 0a1535a9f4 Prefixes removed branches name with PR number when importing PR from GH 2016-08-08 20:24:40 -03:00
Douglas Barbosa Alexandre 167a0c7f0b Remove SHA suffix for removed branches name when importing PR from GH 2016-08-08 19:39:59 -03:00
Douglas Barbosa Alexandre 1e736fb527 Allow users to import cross-repository pull requests from GitHub 2016-08-04 17:16:50 -03:00
Douglas Barbosa Alexandre 51cf14b37c Does not need to disable GitHub webhooks since PRs are check out locally 2016-08-04 17:16:50 -03:00
Douglas Barbosa Alexandre ceff0c9170 Check out locally PRs where the source/target branch were removed 2016-08-04 17:16:50 -03: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
Douwe Maan 6ce25e7b4c Rename MergeRequest methods that return commits or shas to be more clear and consistent 2016-07-06 18:50:58 -04:00
Douglas Barbosa Alexandre 5f86a084f2 Consider that a GH exists only if both `ref`, and `sha` exist 2016-07-06 13:08:12 -03:00
Douglas Barbosa Alexandre 4e5de3e6ee Doesn't trigger Git hooks when cleaning up restored branches from GitHub 2016-07-06 13:08:12 -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
Alejandro Rodríguez 86359ec854 Refactor repository paths handling to allow multiple git mount points 2016-06-29 22:30:31 -04:00
Douglas Barbosa Alexandre 7a34c7997b Listing GH Webhooks doesn't stop import process for non GH admin users 2016-06-17 18:17:34 -03:00
Douglas Barbosa Alexandre cef3fd2899 Wrap all rate limiting logic inside GitHub API client 2016-06-09 12:43:06 -03:00
Douglas Barbosa Alexandre 59e5f4705b Check if GitHub rate limite API was reached before update Webhooks 2016-06-07 10:57:58 -03:00
Douwe Maan 8c5712a422 Merge branch 'gh-disable-webhooks' 2016-06-07 13:06:43 +02:00
Douwe Maan acef028d85 Merge branch 'gh-fix-comments-on-diff' 2016-06-07 13:04:32 +02:00
Douglas Barbosa Alexandre 67c02edccf Move create! method from formatters to the BaseFormatter 2016-06-06 14:26:28 -03:00
Douglas Barbosa Alexandre 7c072c76fc Fix importer for GitHub comments on diff
Fix comments on diff after LegacyDiffNote was extracted from Note
2016-06-06 12:19:03 -03:00
Douglas Barbosa Alexandre 9437b8a2e4 Import GitHub repositories respecting the API rate limit
While Octokit auto pagination set the page size to the maximum 100, and
seek to not overstep the rate limit. When the rate limit is reached its
raises an exception, and stop doing new requests.

Here we use a custom pattern for traversing large lists, so we can
check if we’ll reach the rate limit and wait the API to reset the rate
limit before making new requests.
2016-06-06 12:12:18 -03:00
Douglas Barbosa Alexandre 659d5d4830 Disable Webhooks before proceeding with the GitHub import 2016-06-06 12:07:45 -03:00
Douglas Barbosa Alexandre 3b4f03de8f Ensure branch cleanup regardless of whether the import process succeeds 2016-06-02 19:48:11 -03:00
Grzegorz Bizon 86cf9dd253 Enable Lint/LiteralInCondition rubocop cop
Checks of literals used in conditions.

See #17478
2016-05-30 12:34:25 +02:00
Douglas Barbosa Alexandre 290aa75e6f Remove branches that does exist on GitHub after PRs were imported 2016-05-13 17:55:43 -05:00
Douglas Barbosa Alexandre ebaa19c162 Fix validation method for Gitlab::GithubImport::PullRequestFormatter 2016-05-13 17:55:43 -05:00
Douglas Barbosa Alexandre 795a7ca8f1 Extract GitHub branch formatter 2016-05-13 17:55:42 -05:00
Douglas Barbosa Alexandre e001bd5e3d Import PRs where branch names were reused across PRs 2016-05-13 17:55:42 -05:00
Douglas Barbosa Alexandre 7e1f14e215 Preserve commits/diff/comments for PRs that were merged on GitHub 2016-05-13 17:55:42 -05:00
Douglas Barbosa Alexandre 3b50867550 Fix spec for Gitlab::GithubImport::PullRequestFormatter 2016-05-13 16:49:27 -05:00
Douglas Barbosa Alexandre 9b4dc552cb Import pull requests from GitHub where the target branch was removed 2016-05-13 16:49:27 -05:00
Douglas Barbosa Alexandre 8532dc0d77 Import pull requests from GitHub where the source branch was removed 2016-05-13 16:49:27 -05:00
Douglas Barbosa Alexandre 6fbf6b2936 Fix the line code when importing PR review comments from GitHub
Pull Request Review Comments are comments on a portion of the unified
diff.
2016-05-05 10:45:14 -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