1
0
Fork 0
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:
Patrick Waters 2015-08-10 18:47:31 -05:00
parent 6b9bc88f3a
commit 6c8a23b443
3 changed files with 13 additions and 9 deletions

View file

@ -4,6 +4,8 @@ Reverse Chronological Order:
## master
* Added support for git shallow clone
https://github.com/capistrano/capistrano/compare/v3.4.0...HEAD
* 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
then for individual servers to modify them, keeping things DRY
* Enhancements (@Kriechi)
* Added validate method to DSL to allow validation of certain values
- validate values before assignment inside of `set(:key, value)`

View file

@ -22,16 +22,17 @@ class Capistrano::Git < Capistrano::SCM
end
def clone
if fetch(:git_shallow_clone)
git :clone, '--mirror', '--depth 1', repo_url, repo_path
if depth = fetch(:git_shallow_clone)
git :clone, '--mirror', '--depth', depth, '--no-single-branch', repo_url, repo_path
else
git :clone, '--mirror', repo_url, repo_path
end
end
def update
if fetch(:git_shallow_clone)
git :fetch, '--depth 1', '--update-shallow', "origin #{fetch(:branch)}"
# Note: Requires git version 1.9 or greater
if depth = fetch(:git_shallow_clone)
git :fetch, '--depth', depth, 'origin', fetch(:branch)
else
git :remote, :update
end

View file

@ -48,10 +48,11 @@ module Capistrano
end
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_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
end
@ -66,9 +67,9 @@ module Capistrano
end
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(:execute).with(:git, :fetch, '--depth 1', '--update-shallow', "origin branch")
context.expects(:execute).with(:git, :fetch, "--depth", '1', "origin", :branch)
subject.update
end