summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-26 09:26:12 -0500
committerStan Hu <stanhu@gmail.com>2019-04-07 06:56:49 -0700
commitd7c1bed80d55611ca297c5c7664658d1144c5a85 (patch)
treed9efba6f9bd17c9eb1b9399c6479c381107bd3c5 /lib
parent33316f7f176d76b05bcf8bd0ff4d9dbc43e7c061 (diff)
downloadgitlab-ce-d7c1bed80d55611ca297c5c7664658d1144c5a85.tar.gz
GitHub import: Run housekeeping after initial importsh-git-gc-after-initial-fetch
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
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/github_import/importer/repository_importer.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb
index 6d48c6a15b4..6aad7955415 100644
--- a/lib/gitlab/github_import/importer/repository_importer.rb
+++ b/lib/gitlab/github_import/importer/repository_importer.rb
@@ -54,6 +54,11 @@ module Gitlab
project.repository.fetch_as_mirror(project.import_url, refmap: refmap, forced: true, remote_name: 'github')
project.change_head(default_branch) if default_branch
+
+ # The initial fetch can bring in lots of loose refs and objects.
+ # Running a `git gc` will make importing pull requests faster.
+ Projects::HousekeepingService.new(project, :gc).execute
+
true
rescue Gitlab::Git::Repository::NoRepository, Gitlab::Shell::Error => e
fail_import("Failed to import the repository: #{e.message}")