Sha256: 49652519cc5f8f5c9350cbc8586b35a0a9b6b9b016057497c170e4672e79b734

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'capistrano/git'

class Capistrano::Git
  module SubmoduleStrategy
    # do all the things a normal capistrano git session would do
    include Capistrano::Git::DefaultStrategy

    def test
      test! " [ -f #{repo_path}/HEAD ] "
    end

    def check
      unless test!(:git, :'ls-remote', repo_url)
        context.error "Repo `#{repo_url}` does not exists"
        return false
      end

      if context.capture(:git, :'ls-remote', repo_url).split("\n").select{ |i| i.include?("refs/heads/#{fetch(:branch)}") }.empty?
        context.error "Branch `#{fetch(:branch)}` not found in repo `#{repo_url}`"
        return false
      end

      true
    end

    def clone
      git :clone, '--mirror', repo_url, repo_path
    end

    def update
      git :remote, :update
    end

    # put the working tree in a release-branch,
    # make sure the submodules are up-to-date
    # and copy everything to the release path
    def release
      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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-git-submodule-strategy-0.1.7 lib/capistrano/git-submodule-strategy.rb
capistrano-git-submodule-strategy-0.1.6 lib/capistrano/git-submodule-strategy.rb