Skip to content

Commit

Permalink
Detect and abort when a directory was expected to be a Git working co…
Browse files Browse the repository at this point in the history
…py but it isn't. One cause for this is when a directory is moved somewhere else and the old location is redefined as an svn:externals.
  • Loading branch information
Marc Liyanage committed May 6, 2010
1 parent a04948c commit 699124e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions git-svn-clone-externals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def update_current_dir
shell('git svn fetch')
else
# regular update, rebase to SVN head
check_working_copy_git
check_working_copy_branch
check_working_copy_dirty
check_working_copy_url
Expand All @@ -179,6 +180,11 @@ def update_current_dir
end


def check_working_copy_git
raise "Error: Expected '#{Dir.getwd}' to be a Git working copy, but it isn't. Maybe a directory was replaced with an SVN externals definition. Please remove this directory and run this script again." unless File.exist?('.git')
end


def check_working_copy_branch
shell('git status')[0] =~ /On branch (\S+)/
raise "Error: Unable to determine Git branch in '#{Dir.getwd}' using 'git status'" unless $~
Expand Down

0 comments on commit 699124e

Please sign in to comment.