From 353c5782b47211f9a7e2439189b23dde8678960a Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 3 Apr 2018 22:47:46 +0800 Subject: Checkout to a new branch --- qa/qa/factory/repository/push.rb | 7 ++++++- qa/qa/git/repository.rb | 4 ++++ qa/qa/specs/features/project/deploy_key_clone_spec.rb | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'qa') diff --git a/qa/qa/factory/repository/push.rb b/qa/qa/factory/repository/push.rb index 6e8905cde78..bd4dee4c7be 100644 --- a/qa/qa/factory/repository/push.rb +++ b/qa/qa/factory/repository/push.rb @@ -30,7 +30,12 @@ module QA repository.clone repository.configure_identity('GitLab QA', 'root@gitlab.com') - repository.checkout(@branch_name) unless @new_branch + if @new_branch + repository.checkout_new_branch(@branch_name) + else + repository.checkout(@branch_name) + end + repository.add_file(@file_name, @file_content) repository.commit(@commit_message) repository.push_changes(@branch_name) diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index b3150e8f3fa..4ffe25304a1 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -40,6 +40,10 @@ module QA `git checkout "#{branch_name}"` end + def checkout_new_branch(branch_name) + `git checkout -b "#{branch_name}"` + end + def shallow_clone clone('--depth 1') end diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index ba1c0375549..f193c77288d 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -74,6 +74,7 @@ module QA resource.commit_message = 'Add .gitlab-ci.yml' resource.file_content = gitlab_ci resource.branch_name = deploy_key_name + resource.new_branch = true end sha1sum = Digest::SHA1.hexdigest(gitlab_ci) -- cgit v1.2.3