Skip to content

Instantly share code, notes, and snippets.

@tomconroy
Forked from bhaberer/submodule_strategy.rb
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save tomconroy/09010bab4e76477ef306 to your computer and use it in GitHub Desktop.

Select an option

Save tomconroy/09010bab4e76477ef306 to your computer and use it in GitHub Desktop.

Revisions

  1. tomconroy revised this gist May 19, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions submodule_strategy.rb
    Original file line number Diff line number Diff line change
    @@ -39,4 +39,8 @@ def release
    git :submodule, :update, '--init'
    context.execute "rsync -ar --exclude=.git\* #{repo_path}/ #{release_path}"
    end

    def fetch_revision
    context.capture(:git, "rev-parse --short HEAD")
    end
    end
  2. @bhaberer bhaberer revised this gist Feb 5, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions submodule_strategy.rb
    Original file line number Diff line number Diff line change
    @@ -34,9 +34,9 @@ def update
    # and copy everything to the release path
    def release
    release_branch = fetch(:release_branch, File.basename(release_path))
    git :checkout, '-B', release_branch, fetch(:remote_branch, "origin/#{fetch(:branch)}")
    git :checkout, '-B', release_branch,
    fetch(:remote_branch, "origin/#{fetch(:branch)}")
    git :submodule, :update, '--init'
    context.execute "rsync -ar --exclude=.git\* #{repo_path}/ #{release_path}"
    end

    end
  3. @bhaberer bhaberer revised this gist Feb 5, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion submodule_strategy.rb
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,9 @@
    # set :git_strategy, SubmoduleStrategy

    module SubmoduleStrategy

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

    # check for a .git directory
    def test
    test! " [ -d #{repo_path}/.git ] "
  4. @bhaberer bhaberer revised this gist Feb 5, 2014. 1 changed file with 8 additions and 4 deletions.
    12 changes: 8 additions & 4 deletions submodule_strategy.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,10 @@

    # this include won't work for some reason:
    # include Capistrano::Git::DefaultStrategy
    # Usage:
    # 1. Drop this file into lib/capistrano/submodule_strategy.rb
    # 2. Add the following to your Capfile:
    # require 'capistrano/git'
    # require './lib/capistrano/submodule_strategy'
    # 3. Add the following to your config/deploy.rb
    # set :git_strategy, SubmoduleStrategy

    module SubmoduleStrategy

    @@ -28,7 +32,7 @@ def update
    # and copy everything to the release path
    def release
    release_branch = fetch(:release_branch, File.basename(release_path))
    git :checkout, '-b', release_branch, fetch(:remote_branch, "origin/#{fetch(:branch)}")
    git :checkout, '-B', release_branch, fetch(:remote_branch, "origin/#{fetch(:branch)}")
    git :submodule, :update, '--init'
    context.execute "rsync -ar --exclude=.git\* #{repo_path}/ #{release_path}"
    end
  5. @stevenscg stevenscg revised this gist Dec 30, 2013. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions submodule_strategy.rb
    Original file line number Diff line number Diff line change
    @@ -23,9 +23,12 @@ def update
    git :remote, :update
    end

    # rsync the working tree to the release path
    # 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 :checkout, fetch(:branch)
    release_branch = fetch(:release_branch, File.basename(release_path))
    git :checkout, '-b', release_branch, fetch(:remote_branch, "origin/#{fetch(:branch)}")
    git :submodule, :update, '--init'
    context.execute "rsync -ar --exclude=.git\* #{repo_path}/ #{release_path}"
    end
  6. @stevenscg stevenscg created this gist Dec 30, 2013.
    33 changes: 33 additions & 0 deletions submodule_strategy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@

    # this include won't work for some reason:
    # include Capistrano::Git::DefaultStrategy

    module SubmoduleStrategy

    # check for a .git directory
    def test
    test! " [ -d #{repo_path}/.git ] "
    end

    # same as in Capistrano::Git::DefaultStrategy
    def check
    test! :git, :'ls-remote', repo_url
    end

    def clone
    git :clone, '-b', fetch(:branch), '--recursive', repo_url, repo_path
    end

    # same as in Capistrano::Git::DefaultStrategy
    def update
    git :remote, :update
    end

    # rsync the working tree to the release path
    def release
    git :checkout, fetch(:branch)
    git :submodule, :update, '--init'
    context.execute "rsync -ar --exclude=.git\* #{repo_path}/ #{release_path}"
    end

    end