lib/git_local/repository.rb in git_local-0.0.6 vs lib/git_local/repository.rb in git_local-0.0.7
- old
+ new
@@ -13,11 +13,11 @@
@branch = branch
@local_directory = local_directory
end
def get
- Dir.exist?(path) && new_commit_on_remote? ? pull : clone_and_checkout
+ Dir.exist?(path) && new_commit_on_remote? ? reset_to_latest_from_origin : clone_and_checkout
end
def file_object(file_path)
GitLocal::Object.new(File.join(path, file_path))
end
@@ -92,11 +92,11 @@
def org_repo_branch
@org_repo_branch ||= "#{org}/#{repo}/#{branch}"
end
- def pull
- Process.wait(IO.popen("(cd #{path} && git pull)").pid)
+ def reset_to_latest_from_origin
+ Process.wait(IO.popen("(cd #{path} && git fetch && git reset origin/#{branch} --hard)").pid)
end
def repo_path
@repo_path ||= "#{local_directory}/#{org_repo}"
end