From 26833110ea7d8356ac771d23d8f63f3dce75c75f Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 5 Dec 2017 01:24:35 -0800 Subject: Flush the repository cache after GitHub importer runs This eliminates the need to wait for the FinishImportWorker to run and ensures that the repository is in a consistent state right away. Closes #40107 --- changelogs/unreleased/sh-fix-github-importer-cache-expiry.yml | 5 +++++ lib/gitlab/github_import/importer/repository_importer.rb | 1 + spec/lib/gitlab/github_import/importer/repository_importer_spec.rb | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 changelogs/unreleased/sh-fix-github-importer-cache-expiry.yml diff --git a/changelogs/unreleased/sh-fix-github-importer-cache-expiry.yml b/changelogs/unreleased/sh-fix-github-importer-cache-expiry.yml new file mode 100644 index 00000000000..936482e8654 --- /dev/null +++ b/changelogs/unreleased/sh-fix-github-importer-cache-expiry.yml @@ -0,0 +1,5 @@ +--- +title: Flush the repository cache after GitHub importer runs +merge_request: +author: +type: fixed diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb index 9cf2e7fd871..602abcd0dba 100644 --- a/lib/gitlab/github_import/importer/repository_importer.rb +++ b/lib/gitlab/github_import/importer/repository_importer.rb @@ -47,6 +47,7 @@ module Gitlab refmap = Gitlab::GithubImport.refmap project.repository.fetch_as_mirror(project.import_url, refmap: refmap, forced: true, remote_name: 'github') + project.repository.after_import true rescue Gitlab::Git::Repository::NoRepository, Gitlab::Shell::Error => e diff --git a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb index 168e5d07504..5eb0aef7a02 100644 --- a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb @@ -164,6 +164,9 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do expect(project) .to receive(:ensure_repository) + expect(repository) + .to receive(:after_import) + expect(repository) .to receive(:fetch_as_mirror) .with(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: true, remote_name: 'github') @@ -175,6 +178,9 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do expect(project).to receive(:ensure_repository) .and_raise(Gitlab::Git::Repository::NoRepository) + expect(repository) + .not_to receive(:after_import) + expect(importer) .to receive(:fail_import) .and_return(false) -- cgit v1.2.1