Skip to content

Commit

Permalink
Merge pull request gitlabhq#7823 from cirosantilli/test-fetch-shell
Browse files Browse the repository at this point in the history
Only clone GitLab Shell on tests if necessary.
  • Loading branch information
dzaporozhets committed Sep 24, 2014
2 parents 0b7377d + 065ab3e commit 28b6f09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/tasks/gitlab/shell.rake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ namespace :gitlab do

# Make sure we're on the right tag
Dir.chdir(target_dir) do
sh "git fetch origin && git reset --hard $(git describe #{args.tag} || git describe origin/#{args.tag})"
# First try to checkout without fetching
# to avoid stalling tests if the Internet is down.
reset = "git reset --hard $(git describe #{args.tag} || git describe origin/#{args.tag})"
sh "#{reset} || git fetch origin && #{reset}"

config = {
user: user,
Expand Down
10 changes: 6 additions & 4 deletions spec/support/test_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def init(opts = {})
tmp_test_path = Rails.root.join('tmp', 'tests')

if File.directory?(tmp_test_path)
FileUtils.rm_r(tmp_test_path)
Dir.entries(tmp_test_path).each do |entry|
unless ['.', '..', 'gitlab-shell'].include?(entry)
FileUtils.rm_r(File.join(tmp_test_path, entry))
end
end
end

FileUtils.mkdir_p(tmp_test_path)
Expand All @@ -38,9 +42,7 @@ def enable_mailer
end

def setup_gitlab_shell
unless File.directory?(Gitlab.config.gitlab_shell.path)
%x[rake gitlab:shell:install]
end
`rake gitlab:shell:install`
end

def setup_factory_repo
Expand Down

0 comments on commit 28b6f09

Please sign in to comment.