Permalink
Browse files

Better git checkout command sequence.

  • Loading branch information...
1 parent cf35d86 commit 050432297913190cdee1df9002430e068bff6b46 @pwnall committed Feb 4, 2012
Showing with 6 additions and 10 deletions.
  1. +2 −0 CHANGELOG
  2. +4 −10 lib/rails_pwnerer/app/vcs/git.rb
View
@@ -1,3 +1,5 @@
+v0.6.103. Better git checkout command sequence.
+
v0.6.102. Workaround for buggy apt-cache search output.
v0.6.101. Install MRI 1.9.2+ instead of 1.8.7+ when available.
@@ -6,6 +6,7 @@ class RailsPwnerer::App::Git
# remove any files not in Git in the application dir
def cleanup_app_dir(app_name, instance_name, target_dir, app_name_is_dir = false)
Dir.chdir(app_name_is_dir ? app_name : RailsPwnerer::Config[app_name, instance_name][:app_path]) do
+ next unless File.exist?(target_dir)
Kernel.system "git clean -d -f -x -- #{target_dir}"
Kernel.system "git checkout -- #{target_dir}"
end
@@ -28,6 +29,7 @@ def cleanup_app_caches(app_name, instance_name, app_name_is_dir = false)
def revert_config_changes(app_name, instance_name)
Dir.chdir RailsPwnerer::Config[app_name, instance_name][:app_path] do
['config', 'Gemfile', 'Gemfile.lock'].each do |dir|
+ next unless File.exist?(target_dir)
Kernel.system "git clean -d -f -x -- #{dir}"
Kernel.system "git checkout -- #{dir}"
end
@@ -79,18 +81,10 @@ def checkout(remote_path, app_name, instance_name)
FileUtils.rm_rf app_path
print "Doing Git clone, please enter your password if prompted...\n"
- system "git clone #{git_repository} #{app_path}"
+ system "git clone -b #{git_branch} -- #{git_repository} #{app_path}"
FileUtils.mkpath app_path unless File.exists? app_path
- Dir.chdir app_path do
- system "git checkout -q origin/#{git_branch}"
- # NOTE: it is only safe to delete master now, we're on a remote branch
- system "git branch -d master"
- system "git checkout -q -b #{git_branch}"
- system "git config branch.#{git_branch}.remote origin"
- system "git config branch.#{git_branch}.merge #{git_branch}"
- end
# check that we really checked out a Rails app
return check_rails_root(app_path) ? :ok : false
end
-end
+end

0 comments on commit 0504322

Please sign in to comment.