Although the copy.rb script will make the copy into the release directory fast, this time is actually just shifting to the git reset --hard command since it will break all the hard links, even for unchanged files. Breaking hard links equates to copying the file to replace the hard link.
Ideally this would be fixed in git, but as a workaround I found that git reset --mixed #{revision} && git checkout -f . checks out the files without breaking hard links, so actually speeds up deploys when using fast_remote_cache.
Adding the following to config/deploy.rb will speed up deploys by using avoid git reset --hard.
module FastGitSync
def sync(revision, destination)
git = command
remote = origin
branch = head
execute = []
execute << "cd #{destination}"
execute << "#{git} fetch #{verbose} #{remote} +#{branch}:refs/remotes/#{remote}/#{branch}"
# Reset the git index
execute << "#{git} reset #{verbose} --mixed #{revision}"
# Checkout the index into the work tree
execute << "#{git} checkout -f ."
# Remove untracked files
execute << "#{git} clean #{verbose} -d -x -f"
execute.join(" && ")
end
end
set(:source) { Capistrano::Deploy::SCM.new(scm, self).extend(FastGitSync) }
Some conditions from sync where removed for brevity. See the original source for the sync method for details.
Any thoughts on how this change should be integrated into fast_remote_cache?
Although the copy.rb script will make the copy into the release directory fast, this time is actually just shifting to the
git reset --hard
command since it will break all the hard links, even for unchanged files. Breaking hard links equates to copying the file to replace the hard link.Ideally this would be fixed in git, but as a workaround I found that
git reset --mixed #{revision} && git checkout -f .
checks out the files without breaking hard links, so actually speeds up deploys when using fast_remote_cache.Adding the following to config/deploy.rb will speed up deploys by using avoid
git reset --hard
.Some conditions from sync where removed for brevity. See the original source for the sync method for details.
Any thoughts on how this change should be integrated into fast_remote_cache?