Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple mina git:clone fails on step "Using git branch 'master'" #200

Closed
brandondrew opened this issue Jun 16, 2014 · 9 comments
Closed

Simple mina git:clone fails on step "Using git branch 'master'" #200

brandondrew opened this issue Jun 16, 2014 · 9 comments

Comments

@brandondrew
Copy link
Contributor

local $ mina -v git:clone

-----> Cloning the Git repository
$ git clone "https://brandondrew@github.com/SpartanNash/ad-reports-insite.git" "/var/www/vhosts/test.insite.spartannash-dev.com/scm" --bare
Cloning into bare repository '/var/www/vhosts/test.insite.spartannash-dev.com/scm'...
Password for 'https://brandondrew@github.com':
remote: Reusing existing pack: 761, done.
Receiving objects: 100% (761/761), 1.98 MiB | 604.00 KiB/s, done.
remote: Total 761 (delta 0), reused 0 (delta 0)
Resolving deltas: 100% (299/299), done.
Checking connectivity... done.
-----> Using git branch 'master'
$ git clone "/var/www/vhosts/test.insite.spartannash-dev.com/scm" . --recursive --branch "master"
fatal: destination path '.' already exists and is not an empty directory.
Connection to spartand3 closed.

 !     Command failed.
       Failed with status 32768
local $

The same results are obtained by running the same commands on the server, so it looks like Mina is not sending the correct commands in the first place. For instance, when it runs git clone "/var/www/vhosts/test.insite.spartannash-dev.com/scm" . --recursive --branch "master", . is the main :deploy_to directory. That doesn't sound right—shouldn't it be specifying a different directory? (Certainly Git thinks it shouldn't be cloning into that location!)

My deploy.rb file contains

require 'mina/git'

set :domain, 'spartand3' # host, NOT domain!
set :deploy_to, '/var/www/vhosts/test.insite.spartannash-dev.com'
set :repository, 'https://brandondrew@github.com/SpartanNash/ad-reports-insite.git'
set :branch, 'master'
set :user, 'bzisad0'

task :environment do
  queue! %[echo "-----> This is a test from the :environment task."]
  queue  %[echo "-----> You can safely ignore it."]
end

task :setup => :environment do
  queue! %[echo "-----> This is a test from the :setup task."]
  queue  %[echo "-----> You can safely ignore it."]
end

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'

    to :launch do
      queue! %[echo "-----> This is a test from the :launch task."]
      queue  %[echo "-----> You can safely ignore it."]
    end
  end
end
@brandondrew
Copy link
Contributor Author

The problem seems to be at line 48 of https://github.com/mina-deploy/mina/blob/master/lib%2Fmina%2Fgit.rb :

clone = if commit?
  %[
    echo "-----> Using git commit '#{commit}'" &&
    #{echo_cmd %[git clone "#{repository!}" . --recursive]} &&
    #{echo_cmd %[git checkout -b current_release "#{commit}" --force]} &&
  ]
else
  %{
    if [ ! -d "#{deploy_to}/scm/objects" ]; then
      echo "-----> Cloning the Git repository"
      #{echo_cmd %[git clone "#{repository!}" "#{deploy_to}/scm" --bare]}
    else
      echo "-----> Fetching new git commits"
      #{echo_cmd %[(cd "#{deploy_to}/scm" && git fetch "#{repository!}" "#{branch}:#{branch}" --force)]}
    fi &&
    echo "-----> Using git branch '#{branch}'" &&
    ####### Line 48 is next #######
    #{echo_cmd %[git clone "#{deploy_to}/scm" . --recursive --branch "#{branch}"]} &&
  }
end

@brandondrew
Copy link
Contributor Author

I assume it needs to cd to another directory, such as releases/<timestamp>

@brandondrew
Copy link
Contributor Author

hello?

@bf4
Copy link

bf4 commented Aug 11, 2014

duplicate of #190

@paulrobertlloyd
Copy link

I’m seeing the same issue. Any news?

@rstacruz
Copy link
Member

Hm, I'm a little puzzled here. deploy do..end should've taken care of cd'ing into the proper directory. Try doing a mina -S deploy run (--simulate). It should tell you:

echo "-----> Creating a temporary build path"
touch deploy.lock &&
mkdir -p "$build_path" &&
cd "$build_path" && 
(
  ... your git clone commands here
)

Just tested out the latest release and this seems to still work properly. Can you do queue %[ls] and queue %[pwd] just to inspect what should be in .?

@paulrobertlloyd
Copy link

Thanks for helping us out @rstacruz!

These are what I believe are the relevant lines get when I do mina -S deploy:

# Bootstrap script (in deployer)
(
echo "-----> Creating a temporary build path"
touch "deploy.lock" &&
mkdir -p "$build_path" &&
cd "$build_path" &&
(
  (

    if [ ! -d "webapps/paulrobertlloyd_v3/scm/objects" ]; then
      echo "-----> Cloning the Git repository"
      git clone "git://github.com/paulrobertlloyd/paulrobertlloyd.com.git" "webapps/paulrobertlloyd_v3/scm" --bare
    else
      echo "-----> Fetching new git commits"
      (cd "webapps/paulrobertlloyd_v3/scm" && git fetch "git://github.com/paulrobertlloyd/paulrobertlloyd.com.git" "master:master" --force)
    fi &&
    echo "-----> Using git branch 'master'" &&
    git clone "webapps/paulrobertlloyd_v3/scm" . --recursive --branch "master" &&

          echo "-----> Using this git commit" &&
          echo &&
          git --no-pager log --format="%aN (%h):%n> %s" -n 1 &&
          rm -rf .git &&
          echo

  ) && (

    echo "-----> Symlinking shared paths"
    mkdir -p "./config" &&
    mkdir -p "." &&
    rm -rf "./config/database.yml" &&
    ln -s "webapps/paulrobertlloyd_v3/shared/config/database.yml" "./config/database.yml" &&
    rm -rf "./log" &&
    ln -s "webapps/paulrobertlloyd_v3/shared/log" "./log"

  )
)
) &&

That fi && looks suspicious; should that not be if &&?

Also, adding queue %[ls] and queue %[pwd] just outputs ls and pwd. What should I place here to get the result of these commands output?

@brandondrew
Copy link
Contributor Author

the fi ends the shell script's if block, like end would in Ruby, so I
wouldn't consider it suspicious.

On Sun, Aug 17, 2014 at 8:18 PM, Paul Robert Lloyd <notifications@github.com

wrote:

if [ ! -d "webapps/paulrobertlloyd_v3/scm/objects" ]; then echo "----->
Cloning the Git repository" git clone "git://
github.com/paulrobertlloyd/paulrobertlloyd.com.git"
"webapps/paulrobertlloyd_v3/scm" --bare else echo "-----> Fetching new
git commits" (cd "webapps/paulrobertlloyd_v3/scm" && git fetch "git://
github.com/paulrobertlloyd/paulrobertlloyd.com.git" "master:master"
--force) fi

Brandon Zylstra
brandon.zylstra@gmail.com

@d4be4st
Copy link
Member

d4be4st commented Jul 5, 2015

Seems to be fixed in future versions

@d4be4st d4be4st closed this as completed Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants