Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.73 KB | None | 0 0
  1. Note that in the this gist assumes that the following git aliases are in place:
  2.  
  3. ```
  4. show-graph = log --graph --abbrev-commit --pretty=oneline
  5. co = checkout
  6. br = branch
  7. cm = commit
  8. st = status
  9. rb = rebase
  10. cp = cherry-pick
  11. lol = log --oneline
  12. ```
  13.  
  14. Clone the original repo
  15.  
  16. ```
  17. [ericloots@Eric-Loots-MBP] $ git clone git@github.com:typesafe-training/advanced-akka-java.git
  18. Cloning into 'advanced-akka-java'...
  19. X11 forwarding request failed on channel 0
  20. remote: Counting objects: 322, done.
  21. remote: Compressing objects: 100% (2/2), done.
  22. remote: Total 322 (delta 10), reused 10 (delta 10), pack-reused 310
  23. Receiving objects: 100% (322/322), 61.78 KiB | 0 bytes/s, done.
  24. Resolving deltas: 100% (101/101), done.
  25.  
  26. [ericloots@Eric-Loots-MBP] $ cd advanced-akka-java/
  27. ```
  28.  
  29. The commit history looks as follows (note that there's a `Base template` commit that is of no use to us):
  30.  
  31. ```
  32. [ericloots@Eric-Loots-MBP] $ git lol
  33. ea24155 Data replication
  34. 7a555c2 Persistent actors
  35. da6d3b3 Cluster sharding
  36. ac2b3b6 Cluster singleton
  37. ef203f3 Cluster aware routers
  38. a421b58 Cluster events
  39. ee340ba Remoting
  40. 8a98458 Complete initial state
  41. a2391cc Initial state (koan:initial)
  42. 90e6a83 Base template
  43. ```
  44.  
  45. Squash commits `Initial state (koan:initial)` and `Base template` together:
  46.  
  47. ```
  48. [ericloots@Eric-Loots-MBP] $ git rebase -i --root
  49. [detached HEAD 2438ab4] Initial state (koan:initial)
  50. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  51. Date: Wed Jun 24 11:25:04 2015 +0200
  52. 32 files changed, 2327 insertions(+)
  53. create mode 100644 .gitignore
  54. create mode 100644 LICENSE
  55. create mode 100644 README.md
  56. create mode 100644 build.sbt
  57. create mode 100644 man.sbt
  58. create mode 100644 project/build.properties
  59.  
  60.  
  61. r 2438ab4 Initial state (koan:initial)
  62.  
  63.  
  64. create mode 100644 project/plugins.sbt
  65. create mode 100644 shell-prompt.sbt
  66. create mode 100644 src/main/java/com/typesafe/training/akkacollect/BaseApp.java
  67. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Game.java
  68. create mode 100644 src/main/java/com/typesafe/training/akkacollect/GameEngine.java
  69. create mode 100644 src/main/java/com/typesafe/training/akkacollect/GameEngineApp.java
  70. create mode 100644 src/main/java/com/typesafe/training/akkacollect/PlayerRegistry.java
  71. create mode 100644 src/main/java/com/typesafe/training/akkacollect/PlayerRegistryApp.java
  72. create mode 100644 src/main/java/com/typesafe/training/akkacollect/RandomPlayer.java
  73. create mode 100644 src/main/java/com/typesafe/training/akkacollect/ScoresRepository.java
  74. create mode 100644 src/main/java/com/typesafe/training/akkacollect/ScoresRepositoryApp.java
  75. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Settings.java
  76. create mode 100644 src/main/java/com/typesafe/training/akkacollect/SharedJournalApp.java
  77. create mode 100644 src/main/java/com/typesafe/training/akkacollect/SimplePlayer.java
  78. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Terminal.java
  79. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Tournament.java
  80. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Utils.java
  81. create mode 100644 src/main/resources/application.conf
  82. create mode 100644 src/main/resources/logback.xml
  83. create mode 100644 src/test/java/com/typesafe/training/akkacollect/GameTest.java
  84. create mode 100644 src/test/java/com/typesafe/training/akkacollect/TournamentTest.java
  85. create mode 100644 src/test/java/com/typesafe/training/akkacollect/UtilsTest.java
  86. create mode 100644 src/test/resources/README.md
  87. create mode 100644 src/test/resources/logback-test.xml
  88. create mode 100755 tags
  89. create mode 100755 verify
  90. Successfully rebased and updated refs/heads/master.
  91. /lbt/AAJ/advanced-akka-java
  92. [ericloots@Eric-Loots-MBP] $ git lol
  93. 1f19cf6 Data replication
  94. 3cad7ca Persistent actors
  95. c2bb835 Cluster sharding
  96. d5091f5 Cluster singleton
  97. 136b7d3 Cluster aware routers
  98. 0ecb79f Cluster events
  99. 05fe4ec Remoting
  100. 01f0d30 Complete initial state
  101. 2438ab4 Initial state (koan:initial)
  102. ```
  103. Change the commit messages for the resulting 8 commits to hold the respective exercise names (using the `studentify` naming conventions)
  104.  
  105. ```
  106. [ericloots@Eric-Loots-MBP] $ git rebase -i --root
  107. [detached HEAD 6c60eea] exercise_000_initial_state
  108.  
  109.  
  110. exercise_002_remoting
  111. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  112. Date: Wed Jun 24 11:25:04 2015 +0200
  113. 32 files changed, 2327 insertions(+)
  114. create mode 100644 .gitignore
  115. create mode 100644 LICENSE
  116.  
  117.  
  118. create mode 100644 README.md
  119. create mode 100644 build.sbt
  120. create mode 100644 man.sbt
  121. create mode 100644 project/build.properties
  122. create mode 100644 project/plugins.sbt
  123.  
  124.  
  125. exercise_004_cluster_aware_routers
  126. create mode 100644 shell-prompt.sbt
  127. create mode 100644 src/main/java/com/typesafe/training/akkacollect/BaseApp.java
  128. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Game.java
  129. create mode 100644 src/main/java/com/typesafe/training/akkacollect/GameEngine.java
  130. create mode 100644 src/main/java/com/typesafe/training/akkacollect/GameEngineApp.java
  131.  
  132.  
  133. exercise_005_cluster_singleton
  134. create mode 100644 src/main/java/com/typesafe/training/akkacollect/PlayerRegistry.java
  135. create mode 100644 src/main/java/com/typesafe/training/akkacollect/PlayerRegistryApp.java
  136. create mode 100644 src/main/java/com/typesafe/training/akkacollect/RandomPlayer.java
  137. create mode 100644 src/main/java/com/typesafe/training/akkacollect/ScoresRepository.java
  138. create mode 100644 src/main/java/com/typesafe/training/akkacollect/ScoresRepositoryApp.java
  139. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Settings.java
  140.  
  141.  
  142. exercise_006_cluster_sharding
  143. create mode 100644 src/main/java/com/typesafe/training/akkacollect/SharedJournalApp.java
  144. create mode 100644 src/main/java/com/typesafe/training/akkacollect/SimplePlayer.java
  145. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Terminal.java
  146. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Tournament.java
  147. create mode 100644 src/main/java/com/typesafe/training/akkacollect/Utils.java
  148. create mode 100644 src/main/resources/application.conf
  149.  
  150.  
  151. exercise_007_persistent_actors
  152. create mode 100644 src/main/resources/logback.xml
  153. create mode 100644 src/test/java/com/typesafe/training/akkacollect/GameTest.java
  154. create mode 100644 src/test/java/com/typesafe/training/akkacollect/TournamentTest.java
  155. create mode 100644 src/test/java/com/typesafe/training/akkacollect/UtilsTest.java
  156. create mode 100644 src/test/resources/README.md
  157.  
  158.  
  159. exercise_008_data_replication
  160. create mode 100644 src/test/resources/logback-test.xml
  161. create mode 100755 tags
  162. create mode 100755 verify
  163. [detached HEAD ede6f69] exercise_001_complete_initial_state
  164. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  165. Date: Wed Jun 24 13:10:24 2015 +0200
  166. 6 files changed, 82 insertions(+), 40 deletions(-)
  167. rewrite src/test/resources/README.md (91%)
  168. [detached HEAD 2a3e6ad] exercise_002_remoting
  169. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  170. Date: Wed Jun 24 14:18:05 2015 +0200
  171. 10 files changed, 106 insertions(+), 95 deletions(-)
  172. rewrite src/test/resources/README.md (92%)
  173. [detached HEAD 5160dd8] exercise_003_cluster_events
  174. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  175. Date: Wed Jun 24 14:32:16 2015 +0200
  176. 5 files changed, 144 insertions(+), 72 deletions(-)
  177. rewrite src/test/resources/README.md (73%)
  178. [detached HEAD 541e85b] exercise_004_cluster_aware_routers
  179. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  180. Date: Wed Jun 24 15:23:39 2015 +0200
  181. 5 files changed, 82 insertions(+), 56 deletions(-)
  182. rewrite src/test/resources/README.md (94%)
  183. [detached HEAD d364d0d] exercise_005_cluster_singleton
  184. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  185. Date: Wed Jun 24 15:41:04 2015 +0200
  186. 4 files changed, 138 insertions(+), 186 deletions(-)
  187. rewrite src/main/java/com/typesafe/training/akkacollect/GameEngine.java (69%)
  188. rewrite src/test/resources/README.md (65%)
  189. [detached HEAD 3cbe069] exercise_006_cluster_sharding
  190. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  191. Date: Wed Jun 24 16:10:36 2015 +0200
  192. 9 files changed, 404 insertions(+), 52 deletions(-)
  193. create mode 100644 src/main/java/com/typesafe/training/akkacollect/PlayerSharding.java
  194. rewrite src/test/resources/README.md (66%)
  195. [detached HEAD e4d0d22] exercise_007_persistent_actors
  196. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  197. Date: Wed Jun 24 16:39:47 2015 +0200
  198. 3 files changed, 146 insertions(+), 220 deletions(-)
  199. rewrite src/test/resources/README.md (88%)
  200. [detached HEAD 051dc07] exercise_008_data_replication
  201. Author: Nilanjan Raychaudhuri <nraychaudhuri@gmail.com>
  202. Date: Wed Jun 24 16:49:46 2015 +0200
  203. 3 files changed, 80 insertions(+), 56 deletions(-)
  204. rewrite src/test/resources/README.md (68%)
  205. Successfully rebased and updated refs/heads/master.
  206. ```
  207.  
  208. The result now looks as follows for the AAJ course:
  209.  
  210. ```
  211. [ericloots@Eric-Loots-MBP] $ git lol
  212. 051dc07 exercise_008_data_replication
  213. e4d0d22 exercise_007_persistent_actors
  214. 3cbe069 exercise_006_cluster_sharding
  215. d364d0d exercise_005_cluster_singleton
  216. 541e85b exercise_004_cluster_aware_routers
  217. 5160dd8 exercise_003_cluster_events
  218. 2a3e6ad exercise_002_remoting
  219. ede6f69 exercise_001_complete_initial_state
  220. 6c60eea exercise_000_initial_state
  221. ```
  222.  
  223. It would now be cool if this repo would meet the conditions for the `delinearize` command for converting a delinearized repo to the _normal_ course master repo layout. Unfortunately, this isn't the case, as `delinearize` assumes that the project is (sbt) multi-project. Let's try to convert the repo to something that looks like what's needed...
  224.  
  225. Let's start by adding a common folder to each commit (holding at least one file, `.gitignore` in this case. We'll utilize git filter-branch to do the actual work.
  226.  
  227. First we create a shell script that will create a `common` directory with an empty `.gitignore` file in it:
  228.  
  229. ```
  230. [ericloots@Eric-Loots-MBP] $ ls -l /tmp/mkCommon
  231. -rwxr-xr-x 1 ericloots wheel 49 Jan 24 11:01 /tmp/mkCommon
  232. [ericloots@Eric-Loots-MBP] $ cat /tmp/mkCommon
  233. #!/bin/ksh
  234.  
  235. mkdir common
  236. touch common/.gitignore
  237. ```
  238.  
  239. Now we can run `filter-branch` and quickly do a small verification:
  240.  
  241. ```
  242. [ericloots@Eric-Loots-MBP] $ git filter-branch --tree-filter /tmp/mkCommon -f
  243. Rewrite 051dc07a5302354f5a19dd59b5357d44fcf8e998 (9/9) (1 seconds passed, remaining 0 predicted)
  244. Ref 'refs/heads/master' was rewritten
  245.  
  246. [ericloots@Eric-Loots-MBP] $ ls
  247. LICENSE build.sbt man.sbt shell-prompt.sbt tags
  248. README.md common project src verify
  249. /lbt/AAJ/advanced-akka-java
  250. [ericloots@Eric-Loots-MBP] $ git lol
  251. 6854272 exercise_008_data_replication
  252. e193f6f exercise_007_persistent_actors
  253. 7bac4ec exercise_006_cluster_sharding
  254. fdeff34 exercise_005_cluster_singleton
  255. a53ae20 exercise_004_cluster_aware_routers
  256. 446cf41 exercise_003_cluster_events
  257. f31d616 exercise_002_remoting
  258. a1aa3af exercise_001_complete_initial_state
  259. 0b900bc exercise_000_initial_state
  260.  
  261. [ericloots@Eric-Loots-MBP] $ git co 0b900bc
  262. Note: checking out '0b900bc'.
  263.  
  264. You are in 'detached HEAD' state. You can look around, make experimental
  265. changes and commit them, and you can discard any commits you make in this
  266. state without impacting any branches by performing another checkout.
  267.  
  268. If you want to create a new branch to retain commits you create, you may
  269. do so (now or later) by using -b with the checkout command again. Example:
  270.  
  271. git checkout -b <new-branch-name>
  272.  
  273. HEAD is now at 0b900bc... exercise_000_initial_state
  274.  
  275. [ericloots@Eric-Loots-MBP] $ ll -a common
  276. total 0
  277. drwxr-xr-x 3 ericloots staff 102 Jan 24 11:01 .
  278. drwxr-xr-x 14 ericloots staff 476 Jan 24 11:01 ..
  279. -rw-r--r-- 1 ericloots staff 0 Jan 24 11:01 .gitignore
  280.  
  281. [ericloots@Eric-Loots-MBP] $ git co master
  282. Previous HEAD position was 0b900bc... exercise_000_initial_state
  283. Switched to branch 'master'
  284. Your branch and 'origin/master' have diverged,
  285. and have 9 and 10 different commits each, respectively.
  286. (use "git pull" to merge the remote branch into yours)
  287. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement