Advertisement
Guest User

Untitled

a guest
Mar 18th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. require 'fileutils'
  2.  
  3. # Problem: ActionScript class files named without following capitalized convention
  4. # cannot be simply renamed to the correct convention and commit to version control.
  5. # This is caused by case-insensitive file systems not recognizing the casing changes.
  6. # Solution: Create a temp copy of the original, incorrectly cased file. Remove the original from version control.
  7. # Rename the temp to the correct name and add to version control. Commit.
  8.  
  9.  
  10. # Rename and copy temporarily
  11. Dir['*.as'].each do |as_file|
  12. # if the filename is not uppercased
  13. if as_file[0..0] != (cap = as_file[0..0].upcase)
  14. # make tmp copy of the file with correct capitalization
  15. # ie. foo.as gets copied to Foo.as.tmp
  16. FileUtils.cp(as_file, "#{cap}#{as_file[1..as_file.size]}.tmp")
  17. # remove the original file from SVN
  18. `svn rm #{as_file}`
  19. end
  20. end
  21.  
  22. # Rename temp files to corrected name and add to SVN
  23. Dir['*.as.tmp'].each do |tmp_file|
  24. final = tmp_file.sub(/\.tmp$/, '')
  25. FileUtils.mv tmp_file, final
  26. `svn add #{final}`
  27. end
  28.  
  29. # Double check and commit.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement