From 2fa4c07a9c8eca52bc02ab8fc5de2e43ff82d310 Mon Sep 17 00:00:00 2001 From: Jan Berdajs <mrbrdo@gmail.com> Date: Sat, 25 Apr 2015 17:57:02 +0200 Subject: [PATCH] fix sanity checks in script/server, remove migration check because it is too slow and Rails 4 checks it on first request anyway --- script/server | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/script/server b/script/server index 4a0980a4cd..fdf1f23fd4 100755 --- a/script/server +++ b/script/server @@ -61,16 +61,29 @@ then fatal "config/diaspora.yml is missing! Copy over config/diaspora.yml.example to config/diaspora.yml and edit it properly!" fi -# Check if detached head state -if git status | grep 'Changes not staged for commit' > /dev/null ; -then - warning "Your changes are not staged for commit. Kindly stash or commit them" +command -v git > /dev/null 2>&1 +if [ $? -eq 0 ]; then + # Check if git merge is in progress + if [ -f .git/MERGE_MODE ]; then + fatal "A git merge is in progress!" + fi + + # Check if detached head state + git_branch_name="$(git symbolic-ref HEAD 2>/dev/null)" + if [ -z "$git_branch_name" ]; + then + warning "You are in detached HEAD state!" + fi fi -# Check if RVM available -if rvm -v | grep 'No command '"'"'rvm'"'"' found' > /dev/null ; -then - warning "RVM is not installed on the system. Please install it" +# Do RVM checks if RVM is being used +command -v rvm > /dev/null 2>&1 +if [ $? -eq 0 ]; then + rvm_gemset="$(rvm current | cut -d"@" -f2)" + project_gemset="$(cat .ruby-gemset | tr -d " \t\n\r")" + if [ "$rvm_gemset" != "$project_gemset" ]; then + warning "Project gemset is $project_gemset but you are using $rvm_gemset" + fi fi # Check if bundle is complete @@ -79,15 +92,6 @@ then fatal "Your bundle is not up to date, run the command \"bundle install\"" fi -# Check if database is migrated and correct gemset -if rake db:migrate:status | grep 'down' > /dev/null ; -then - warning "Your database is not migrated, run the command \"rake db:migrate\"" -elif rake db:migrate:status | grep 'rake aborted' > /dev/null ; -then - warning "The gemset is not correct" -fi - # Setup environment if [ -z "$RAILS_ENV" ] then @@ -133,8 +137,8 @@ if [ -w "public" -a ! -e "public/source.tar.gz" ] then if command -v git > /dev/null 2>&1 && git rev-parse --is-inside-work-tree > /dev/null 2>&1 then - branch=$(git branch | awk '/^[*]/ {print $2}') - tar czf public/source.tar.gz $(git ls-tree -r $branch | awk '{print $4}') + commit_sha=$(git rev-parse HEAD) + tar czf public/source.tar.gz $(git ls-tree -r $commit_sha | awk '{print $4}') else fatal "Can't generate public/source.tar.gz for you. Please tar up a copy of your Diaspora installation and place it there." -- GitLab