Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-18 00:19:36 +0400
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-18 00:19:36 +0400
commitbc59fd046f9f786c8bbc5512a9177359b384b329 (patch)
tree4fee9b7fdc1c7952b9adbcd37e477c290b008b95 /lib
parent48a5012b211ab2d7938b30e89e878b9212594bf3 (diff)
Add a warning prompt to the setup task
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/gitlab/setup.rake24
-rw-r--r--lib/tasks/gitlab/task_helpers.rake27
2 files changed, 46 insertions, 5 deletions
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake
index 572a22aa1f6..ce6d0eb363d 100644
--- a/lib/tasks/gitlab/setup.rake
+++ b/lib/tasks/gitlab/setup.rake
@@ -1,10 +1,24 @@
namespace :gitlab do
namespace :app do
desc "GITLAB | Setup production application"
- task :setup => [
- 'db:setup',
- 'db:seed_fu',
- 'gitlab:enable_automerge'
- ]
+ task :setup => :environment do
+ setup
+ end
+
+ def setup
+ warn_user_is_not_gitlab
+
+ puts "This will create the necessary database tables and seed the database."
+ puts "You will lose any previous data stored in the database."
+ ask_to_continue
+ puts ""
+
+ Rake::Task["db:setup"].invoke
+ Rake::Task["db:seed_fu"].invoke
+ Rake::Task["gitlab:enable_automerge"].invoke
+ rescue Gitlab::TaskAbortedByUserError
+ puts "Quitting...".red
+ exit 1
+ end
end
end
diff --git a/lib/tasks/gitlab/task_helpers.rake b/lib/tasks/gitlab/task_helpers.rake
index 12fd5181ecb..d494125f76c 100644
--- a/lib/tasks/gitlab/task_helpers.rake
+++ b/lib/tasks/gitlab/task_helpers.rake
@@ -1,5 +1,18 @@
+module Gitlab
+ class TaskAbortedByUserError < StandardError; end
+end
+
namespace :gitlab do
+ # Ask if the user wants to continue
+ #
+ # Returns "yes" the user chose to continue
+ # Raises Gitlab::TaskAbortedByUserError if the user chose *not* to continue
+ def ask_to_continue
+ answer = prompt("Do you want to continue (yes/no)? ".blue, %w{yes no})
+ raise Gitlab::TaskAbortedByUserError unless answer == "yes"
+ end
+
# Check which OS is running
#
# It will primarily use lsb_relase to determine the OS.
@@ -22,6 +35,20 @@ namespace :gitlab do
os_name.try(:squish!)
end
+ # Prompt the user to input something
+ #
+ # message - the message to display before input
+ # choices - array of strings of acceptible answers or nil for any answer
+ #
+ # Returns the user's answer
+ def prompt(message, choices = nil)
+ begin
+ print(message)
+ answer = STDIN.gets.chomp
+ end while choices.present? && !choices.include?(answer)
+ answer
+ end
+
# Runs the given command and matches the output agains the given pattern
#
# Returns nil if nothing matched