mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Cleaning up git shallow clone and adding tests
This commit is contained in:
parent
6b9bc88f3a
commit
6c8a23b443
3 changed files with 13 additions and 9 deletions
|
@ -4,6 +4,8 @@ Reverse Chronological Order:
|
||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* Added support for git shallow clone
|
||||||
|
|
||||||
https://github.com/capistrano/capistrano/compare/v3.4.0...HEAD
|
https://github.com/capistrano/capistrano/compare/v3.4.0...HEAD
|
||||||
|
|
||||||
* Remove 'vendor/bundle' from default :linked_dirs (@ojab)
|
* Remove 'vendor/bundle' from default :linked_dirs (@ojab)
|
||||||
|
@ -137,7 +139,7 @@ https://github.com/capistrano/capistrano/compare/v3.2.1...v3.3.3
|
||||||
|
|
||||||
This allows roles to specify properties common to all servers and
|
This allows roles to specify properties common to all servers and
|
||||||
then for individual servers to modify them, keeping things DRY
|
then for individual servers to modify them, keeping things DRY
|
||||||
|
|
||||||
* Enhancements (@Kriechi)
|
* Enhancements (@Kriechi)
|
||||||
* Added validate method to DSL to allow validation of certain values
|
* Added validate method to DSL to allow validation of certain values
|
||||||
- validate values before assignment inside of `set(:key, value)`
|
- validate values before assignment inside of `set(:key, value)`
|
||||||
|
|
|
@ -22,16 +22,17 @@ class Capistrano::Git < Capistrano::SCM
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone
|
def clone
|
||||||
if fetch(:git_shallow_clone)
|
if depth = fetch(:git_shallow_clone)
|
||||||
git :clone, '--mirror', '--depth 1', repo_url, repo_path
|
git :clone, '--mirror', '--depth', depth, '--no-single-branch', repo_url, repo_path
|
||||||
else
|
else
|
||||||
git :clone, '--mirror', repo_url, repo_path
|
git :clone, '--mirror', repo_url, repo_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if fetch(:git_shallow_clone)
|
# Note: Requires git version 1.9 or greater
|
||||||
git :fetch, '--depth 1', '--update-shallow', "origin #{fetch(:branch)}"
|
if depth = fetch(:git_shallow_clone)
|
||||||
|
git :fetch, '--depth', depth, 'origin', fetch(:branch)
|
||||||
else
|
else
|
||||||
git :remote, :update
|
git :remote, :update
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,10 +48,11 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should run git clone in shallow mode" do
|
it "should run git clone in shallow mode" do
|
||||||
context.expects(:fetch).with(:git_shallow_clone).returns(true)
|
context.expects(:fetch).with(:git_shallow_clone).returns('1')
|
||||||
context.expects(:repo_url).returns(:url)
|
context.expects(:repo_url).returns(:url)
|
||||||
context.expects(:repo_path).returns(:path)
|
context.expects(:repo_path).returns(:path)
|
||||||
context.expects(:execute).with(:git, :clone, '--mirror', '--depth 1', :url, :path)
|
|
||||||
|
context.expects(:execute).with(:git, :clone, '--mirror', "--depth", '1', '--no-single-branch', :url, :path)
|
||||||
|
|
||||||
subject.clone
|
subject.clone
|
||||||
end
|
end
|
||||||
|
@ -66,9 +67,9 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should run git update in shallow mode" do
|
it "should run git update in shallow mode" do
|
||||||
context.expects(:fetch).with(:git_shallow_clone).returns(true)
|
context.expects(:fetch).with(:git_shallow_clone).returns('1')
|
||||||
context.expects(:fetch).with(:branch).returns(:branch)
|
context.expects(:fetch).with(:branch).returns(:branch)
|
||||||
context.expects(:execute).with(:git, :fetch, '--depth 1', '--update-shallow', "origin branch")
|
context.expects(:execute).with(:git, :fetch, "--depth", '1', "origin", :branch)
|
||||||
|
|
||||||
subject.update
|
subject.update
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue