def sync(revision, destination)
git = command
remote = origin
execute = []
execute << "cd #{destination}"
if remote != 'origin'
execute << "#{git} config remote.#{remote}.url #{variable(:repository)}"
execute << "#{git} config remote.#{remote}.fetch +refs/heads/*:refs/remotes/#{remote}/*"
end
execute << "#{git} fetch #{verbose} #{remote} && #{git} reset #{verbose} --hard #{revision}"
if variable(:git_enable_submodules)
execute << "#{git} submodule #{verbose} init"
execute << "for mod in `#{git} submodule status | awk '{ print $2 }'`; do #{git} config -f .git/config submodule.${mod}.url `#{git} config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done"
execute << "#{git} submodule #{verbose} sync"
execute << "#{git} submodule #{verbose} update"
end
execute << "#{git} clean #{verbose} -d -x -f"
execute.join(" && ")
end