summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-12-05 01:24:35 -0800
committerStan Hu <stanhu@gmail.com>2017-12-05 01:55:10 -0800
commit26833110ea7d8356ac771d23d8f63f3dce75c75f (patch)
treec70287d1ce24630ed6cf661d526240aae0bf7127
parent61392168a0265e6c54cbccc6b7529822b123ff5b (diff)
downloadgitlab-ce-sh-fix-github-importer-cache-expiry.tar.gz
Flush the repository cache after GitHub importer runssh-fix-github-importer-cache-expiry
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
-rw-r--r--changelogs/unreleased/sh-fix-github-importer-cache-expiry.yml5
-rw-r--r--lib/gitlab/github_import/importer/repository_importer.rb1
-rw-r--r--spec/lib/gitlab/github_import/importer/repository_importer_spec.rb6
3 files changed, 12 insertions, 0 deletions
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
@@ -165,6 +165,9 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
.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)