mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #1856 from capistrano/fix-hg-repo-tree
Fix hg repo_tree implementation
This commit is contained in:
commit
1f96cad2c2
3 changed files with 15 additions and 2 deletions
|
@ -19,6 +19,7 @@ https://github.com/capistrano/capistrano/compare/v3.7.2...HEAD
|
|||
* [#1846](https://github.com/capistrano/capistrano/pull/1846): add_host will add a new host in a case where it used to incorrectly update an existing one (potentially breaking) [(@dbenamy)](https://github.com/dbenamy)
|
||||
* [capistrano-harrow#4](https://github.com/harrowio/capistrano-harrow/issues/4): Drop dependency on `capistrano-harrow` gem. Gem can still be installed separately [(@leehambley)](https://github.com/leehambley)
|
||||
* Run `svn switch` to work with svn branches if repo_url is changed
|
||||
* [#1856](https://github.com/capistrano/capistrano/pull/1856): Fix hg repo_tree implementation - [@mattbrictson](https://github.com/mattbrictson)
|
||||
* Your contribution here!
|
||||
|
||||
## `3.7.2` (2017-01-27)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require "capistrano/scm/plugin"
|
||||
require "securerandom"
|
||||
|
||||
class Capistrano::SCM::Hg < Capistrano::SCM::Plugin
|
||||
def register_hooks
|
||||
|
@ -36,7 +37,13 @@ class Capistrano::SCM::Hg < Capistrano::SCM::Plugin
|
|||
if (tree = fetch(:repo_tree))
|
||||
tree = tree.slice %r#^/?(.*?)/?$#, 1
|
||||
components = tree.split("/").size
|
||||
hg "archive --type tgz -p . -I", tree, "--rev", fetch(:branch), "| tar -x --strip-components #{components} -f - -C", release_path
|
||||
temp_tar = "#{fetch(:tmp_dir)}/#{SecureRandom.hex(10)}.tar"
|
||||
|
||||
hg "archive -p . -I", tree, "--rev", fetch(:branch), temp_tar
|
||||
|
||||
backend.execute :mkdir, "-p", release_path
|
||||
backend.execute :tar, "-x --strip-components #{components} -f", temp_tar, "-C", release_path
|
||||
backend.execute :rm, temp_tar
|
||||
else
|
||||
hg "archive", release_path, "--rev", fetch(:branch)
|
||||
end
|
||||
|
|
|
@ -85,8 +85,13 @@ module Capistrano
|
|||
env.set(:repo_tree, "tree")
|
||||
env.set(:branch, :branch)
|
||||
env.set(:release_path, "path")
|
||||
env.set(:tmp_dir, "/tmp")
|
||||
|
||||
backend.expects(:execute).with(:hg, "archive --type tgz -p . -I", "tree", "--rev", :branch, "| tar -x --strip-components 1 -f - -C", "path")
|
||||
SecureRandom.stubs(:hex).with(10).returns("random")
|
||||
backend.expects(:execute).with(:hg, "archive -p . -I", "tree", "--rev", :branch, "/tmp/random.tar")
|
||||
backend.expects(:execute).with(:mkdir, "-p", "path")
|
||||
backend.expects(:execute).with(:tar, "-x --strip-components 1 -f", "/tmp/random.tar", "-C", "path")
|
||||
backend.expects(:execute).with(:rm, "/tmp/random.tar")
|
||||
|
||||
subject.archive_to_release_path
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue