Commit 38fe0e17 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'kassio/fix-bitbucket-server-importer-lfs' into 'master'

Download LFS files when importing from Bitbucket Server

See merge request gitlab-org/gitlab!45908
parents ba04974a c9a44e5d
---
title: Download LFS files when importing from Bitbucket Server
merge_request: 45908
author:
type: fixed
......@@ -41,6 +41,7 @@ module Gitlab
def execute
import_repository
import_pull_requests
download_lfs_objects
delete_temp_branches
handle_errors
metrics.track_finished_import
......@@ -148,6 +149,14 @@ module Gitlab
raise
end
def download_lfs_objects
result = Projects::LfsPointers::LfsImportService.new(project).execute
if result[:status] == :error
errors << { type: :lfs_objects, errors: "The Lfs import process failed. #{result[:message]}" }
end
end
# Bitbucket Server keeps tracks of references for open pull requests in
# refs/heads/pull-requests, but closed and merged requests get moved
# into hidden internal refs under stash-refs/pull-requests. Unless the
......
......@@ -525,4 +525,36 @@ RSpec.describe Gitlab::BitbucketServerImport::Importer do
expect { subject.execute }.to change { MergeRequest.count }.by(1)
end
end
context "lfs files" do
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
allow(subject).to receive(:import_repository)
allow(subject).to receive(:import_pull_requests)
end
it "downloads lfs objects if lfs_enabled is enabled for project" do
expect_next_instance_of(Projects::LfsPointers::LfsImportService) do |lfs_import_service|
expect(lfs_import_service).to receive(:execute).and_return(status: :success)
end
subject.execute
end
it "adds the error message when the lfs download fails" do
allow_next_instance_of(Projects::LfsPointers::LfsImportService) do |lfs_import_service|
expect(lfs_import_service).to receive(:execute).and_return(status: :error, message: "LFS server not reachable")
end
subject.execute
expect(project.import_state.reload.last_error).to eq(Gitlab::Json.dump({
message: "The remote data could not be fully imported.",
errors: [{
type: "lfs_objects",
errors: "The Lfs import process failed. LFS server not reachable"
}]
}))
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment