ekho / capistrano-git-submodule-strategy

Git submodule support for Capistrano 3
MIT License
47 stars 20 forks source link

double-checking on git:release not working quite right. #3

Closed brushbox closed 9 years ago

brushbox commented 10 years ago

I don't know why the cap tasks run twice, do you?

Anyway, I hit that issue and I found that your fix wasn't working for me.

If I understand what you are trying to do you only want to do the git clone if:

I made a quick hack in the gem and found that the following change worked:

# git-submodule-strategy.rb
...
    def release
      if context.test(:test, '-e', release_path) && context.test("find #{release_path} -maxdepth 0 -empty | read")
        git :clone, '--depth=1', '--recursive', '-b', fetch(:branch), "file://#{repo_path}", release_path
        context.execute("find #{release_path} -name '.git*' | xargs -I {} rm -rfv {}")
      end
    end
...
brushbox commented 10 years ago

I've made a PR for this change: https://github.com/i-ekho/capistrano-git-submodule-strategy/pull/4

ekho commented 10 years ago

I don't know why the cap tasks run twice, do you?

it's because operation executes on all servers. Records

role :app, example.com
role :web, example.com

defines two servers

ekho commented 10 years ago

If I understand what you are trying to do you only want to do the git clone if:

  • the directory exists AND
  • the directory is empty

In my environment release_path may no exist prior to run task.

I think condition should check what release_path does not exists OR it's empty

brushbox commented 10 years ago

I don't know why the cap tasks run twice, do you?

it's because operation executes on all servers. Records

role :app, example.com role :web, example.com

defines two servers

That was my guess...until I removed all roles except for :app and I still had cap tasks executing twice.

brushbox commented 10 years ago

In my environment release_path may no exist prior to run task.

I think condition should check what release_path does not exists OR it's empty

That makes sense. I'll check that change in my env and update on the outcome.