diff options
author | Robert Speicher <robert@gitlab.com> | 2017-04-04 00:26:41 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-04-04 00:26:41 +0300 |
commit | d9aca741155f456711e37ea68a28a46d349af698 (patch) | |
tree | 96967336d0e3387de1d261517537e6b0196b9f97 /lib | |
parent | e473a90700cad4dea6c883122f793b5d6453c7c8 (diff) | |
parent | a9af86250c5226505ccce03f4e4aae08fe976be7 (diff) |
Merge branch 'fix-github-importer-slowness' into 'master'
Improve performance of GitHub importer
Closes #28183
See merge request !10273
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/github_import/pull_request_formatter.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/shell.rb | 20 |
3 files changed, 23 insertions, 2 deletions
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index eea4a91f17d..a8c0b47e786 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -157,7 +157,7 @@ module Gitlab end def restore_source_branch(pull_request) - project.repository.fetch_ref(repo_url, "pull/#{pull_request.number}/head", pull_request.source_branch_name) + project.repository.create_branch(pull_request.source_branch_name, pull_request.source_branch_sha) end def restore_target_branch(pull_request) diff --git a/lib/gitlab/github_import/pull_request_formatter.rb b/lib/gitlab/github_import/pull_request_formatter.rb index 38660a7ccca..150afa31432 100644 --- a/lib/gitlab/github_import/pull_request_formatter.rb +++ b/lib/gitlab/github_import/pull_request_formatter.rb @@ -20,7 +20,8 @@ module Gitlab author_id: author_id, assignee_id: assignee_id, created_at: raw_data.created_at, - updated_at: raw_data.updated_at + updated_at: raw_data.updated_at, + imported: true } end diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 9864a9c7f1a..b631ef11ce7 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -88,6 +88,26 @@ module Gitlab true end + # Fetch remote for repository + # + # name - project path with namespace + # remote - remote name + # forced - should we use --force flag? + # no_tags - should we use --no-tags flag? + # + # Ex. + # fetch_remote("gitlab/gitlab-ci", "upstream") + # + def fetch_remote(storage, name, remote, forced: false, no_tags: false) + args = [gitlab_shell_projects_path, 'fetch-remote', storage, "#{name}.git", remote, '800'] + args << '--force' if forced + args << '--no-tags' if no_tags + + output, status = Popen.popen(args) + raise Error, output unless status.zero? + true + end + # Move repository # storage - project's storage path # path - project path with namespace |