As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 37842fc8 authored by Tiago Botelho's avatar Tiago Botelho
Browse files

Adds --single-branch option to git clone

parent 76e75549
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -252,11 +252,16 @@ class GitlabProjects
@source = ARGV.shift
masked_source = mask_password_in_url(@source)
# clone with --single-branch ?
single_branch = ARGV.delete('--single-branch') if ARGV.include?('--single-branch')
# timeout for clone
timeout = (ARGV.shift || 120).to_i
$logger.info "Importing project #{@project_name} from <#{masked_source}> to <#{full_path}>."
cmd = %W(git clone --bare -- #{@source} #{full_path})
$logger.info "Importing project #{@project_name} from <#{masked_source}> to <#{full_path}>."
cmd = %W(git clone --bare)
cmd << single_branch if single_branch
cmd += %W(-- #{@source} #{full_path})
pid = Process.spawn(*cmd)
begin
Loading
Loading
Loading
Loading
@@ -450,16 +450,19 @@ describe GitlabProjects do
context 'success import' do
let(:gl_projects) { build_gitlab_projects('import-project', tmp_repos_path, repo_name, 'https://github.com/randx/six.git') }
it { gl_projects.exec.should be_true }
it { expect(gl_projects.exec).to be true }
it "should import a repo" do
it "imports a repo" do
gl_projects.exec
File.exists?(File.join(tmp_repo_path, 'HEAD')).should be_true
expect(File.exists?(File.join(tmp_repo_path, 'HEAD'))).to be true
end
it "should log an import-project event" do
it "logs an import-project event" do
message = "Importing project #{repo_name} from <https://github.com/randx/six.git> to <#{tmp_repo_path}>."
$logger.should_receive(:info).with(message)
expect($logger).to receive(:info).with(message)
gl_projects.exec
end
end
Loading
Loading
@@ -467,28 +470,39 @@ describe GitlabProjects do
context 'already exists' do
let(:gl_projects) { build_gitlab_projects('import-project', tmp_repos_path, repo_name, 'https://github.com/randx/six.git') }
it 'should import only once' do
gl_projects.exec.should be_true
gl_projects.exec.should be_false
it 'imports only once' do
expect(gl_projects.exec).to be true
expect(gl_projects.exec).to be false
end
end
context 'timeout' do
let(:gl_projects) { build_gitlab_projects('import-project', tmp_repos_path, repo_name, 'https://github.com/gitlabhq/gitlabhq.git', '1') }
it { gl_projects.exec.should be_false }
it { expect(gl_projects.exec).to be false }
it "should not import a repo" do
it "does not import a repo" do
gl_projects.exec
File.exists?(File.join(tmp_repo_path, 'HEAD')).should be_false
expect(File.exists?(File.join(tmp_repo_path, 'HEAD'))).to be false
end
it "should log an import-project event" do
it "logs an import-project event" do
message = "Importing project #{repo_name} from <https://github.com/gitlabhq/gitlabhq.git> failed due to timeout."
$logger.should_receive(:error).with(message)
expect($logger).to receive(:error).with(message)
gl_projects.exec
end
end
context 'single-branch' do
let(:gl_projects) { build_gitlab_projects('import-project', tmp_repos_path, repo_name, 'https://github.com/randx/six.git', '--single-branch') }
it "imports repo" do
expect(gl_projects.exec).to be true
end
end
end
describe :fork_project do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment