lib/git_p4_sync.rb in git-p4-sync-0.1.2 vs lib/git_p4_sync.rb in git-p4-sync-0.2.0

- old
+ new

@@ -32,11 +32,11 @@ run_cmd "git pull", simulate end end if File.exist?(gitignore = File.join(git_path, ".gitignore")) - @ignore_list = @ignore_list.concat(File.read(gitignore).split(/\n/).map {|i| i.gsub("*",".*") } ) + @ignore_list = @ignore_list.concat(File.read(gitignore).split(/\n/).reject{|i| (i.size == 0) or i.strip.start_with?("#") }.map {|i| i.gsub("*",".*") } ) end diff = diff_dirs(p4_path, git_path) if diff.size > 0 @@ -50,27 +50,32 @@ puts "#{action.to_s.upcase} in Git: #{file}" Dir.chdir(p4_path) do case action when :new - run_cmd "cp -r #{git_path}#{file} #{p4_path}#{file}", simulate - run_cmd "#{p4_add_recursively("#{p4_path}#{file}")}", simulate + run_cmd "cp -r '#{git_path}#{file}' '#{p4_path}#{file}'", simulate + run_cmd "#{p4_add_recursively("'#{p4_path}#{file}'")}", simulate when :deleted - run_cmd "p4 delete #{p4_path}#{file}", simulate + file_path="#{p4_path}#{file}" + Find.find(file_path) do |f| + puts "DELETED in Git (dir contents): #{f}" if file_path != f + run_cmd("p4 delete '#{f}'", simulate) + end + FileUtils.remove_entry_secure(file_path,:force => true) when :modified - run_cmd "p4 edit #{p4_path}#{file}", simulate - run_cmd "cp #{git_path}#{file} #{p4_path}#{file}", simulate + run_cmd "p4 edit '#{p4_path}#{file}'", simulate + run_cmd "cp '#{git_path}#{file}' '#{p4_path}#{file}'", simulate else puts "Unknown change type #{action}. Stopping." exit 1 end end end if submit git_head_commit = "" Dir.chdir(git_path) do - git_head_commit = `git show --pretty=oneline`.split("\n")[0] + git_head_commit = `git show -v -s --pretty=oneline`.split("\n")[0] end Dir.chdir(p4_path) do puts "Submitting changes to Perforce" run_cmd "p4 submit -d '#{git_head_commit.gsub("'", "''")}'", simulate