Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.94 KB | None | 0 0
  1. $ cat ~/bin/sync_namespace
  2. #!/bin/bash
  3.  
  4. # replace performs a string replacement for all files in the repo under the
  5. # current folder and is defined as:
  6. #
  7. #     git grep -l "$1" | xargs sed -i "s/$1/$2/g"
  8.  
  9. UPSTREAM=$(git rev-parse --abbrev-ref HEAD@{upstream})
  10.  
  11. echo "Cleaning up..."
  12. git reset --hard $UPSTREAM
  13.  
  14. cd components/sync
  15.  
  16. # Fix namespace opening and closing.
  17. replace "namespace syncer_v2 {" "namespace syncer {"
  18. replace "namespace sync_driver_v2 {" "namespace syncer {"
  19. replace "namespace sync_driver {" "namespace syncer {"
  20. replace "namespace browser_sync {" "namespace syncer {"
  21. replace "}  \/\/ namespace syncer_v2" "}  \/\/ namespace syncer"
  22. replace "}  \/\/ namespace sync_driver_v2" "}  \/\/ namespace syncer"
  23. replace "}  \/\/ namespace sync_driver" "}  \/\/ namespace syncer"
  24. replace "}  \/\/ namespace browser_sync" "}  \/\/ namespace syncer"
  25.  
  26. # Remove unnecessary namespace identifiers. This is a big hammer that
  27. # I cleaned up after in the manual tweaks.
  28. replace "syncer_v2::" ""
  29. replace "syncer::" ""
  30. replace "sync_driver_v2::" ""
  31. replace "sync_driver::" ""
  32. replace "browser_sync::" ""
  33.  
  34. # Get rid of using statements that are no longer needed.
  35. erase_line "^using [A-Z]\w*;"
  36.  
  37. cd -
  38.  
  39. # Files where "syncer::" was actually needed.
  40. git checkout components/sync/base/data_type_histogram.h
  41. git checkout components/sync/base/immutable_unittest.cc
  42. git checkout components/sync/base/logging.h
  43. git checkout components/sync/syncable/directory.h
  44. git checkout components/sync/test/fake_server
  45. git checkout components/sync/tools/testserver/run_sync_testserver.cc
  46.  
  47. # Clean up namespace identifies outside //components/sync.
  48. replace "syncer_v2::" "syncer::"
  49. replace "sync_driver_v2::" "syncer::"
  50. replace "sync_driver::" "syncer::"
  51.  
  52. echo "Formatting..."
  53. git cl format
  54.  
  55. echo "Commiting automated changes..."
  56. git commit --all -m "Automated changes." > /dev/null
  57.  
  58. echo "Cherry-picking manual changes..."
  59. git cherry-pick 3c060e2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement