mygithug 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +18 -0
  5. data/Gemfile +4 -0
  6. data/LICENCE.txt +22 -0
  7. data/README.md +55 -0
  8. data/Rakefile +6 -0
  9. data/bin/mygithug +4 -0
  10. data/levels/add.rb +30 -0
  11. data/levels/alias_lg.rb +55 -0
  12. data/levels/alias_st.rb +22 -0
  13. data/levels/bisect/.githug/COMMIT_EDITMSG +1 -0
  14. data/levels/bisect/.githug/HEAD +1 -0
  15. data/levels/bisect/.githug/ORIG_HEAD +1 -0
  16. data/levels/bisect/.githug/config +7 -0
  17. data/levels/bisect/.githug/description +1 -0
  18. data/levels/bisect/.githug/gitk.cache +3 -0
  19. data/levels/bisect/.githug/hooks/applypatch-msg.sample +15 -0
  20. data/levels/bisect/.githug/hooks/commit-msg.sample +24 -0
  21. data/levels/bisect/.githug/hooks/post-commit.sample +8 -0
  22. data/levels/bisect/.githug/hooks/post-receive.sample +15 -0
  23. data/levels/bisect/.githug/hooks/post-update.sample +8 -0
  24. data/levels/bisect/.githug/hooks/pre-applypatch.sample +14 -0
  25. data/levels/bisect/.githug/hooks/pre-commit.sample +46 -0
  26. data/levels/bisect/.githug/hooks/pre-rebase.sample +172 -0
  27. data/levels/bisect/.githug/hooks/prepare-commit-msg.sample +36 -0
  28. data/levels/bisect/.githug/hooks/update.sample +128 -0
  29. data/levels/bisect/.githug/index +0 -0
  30. data/levels/bisect/.githug/info/exclude +6 -0
  31. data/levels/bisect/.githug/info/refs +9 -0
  32. data/levels/bisect/.githug/logs/HEAD +21 -0
  33. data/levels/bisect/.githug/logs/refs/heads/master +21 -0
  34. data/levels/bisect/.githug/objects/info/packs +2 -0
  35. data/levels/bisect/.githug/objects/pack/pack-59fab357f3158a9640633de6a3326ed79a2b4fe6.idx +0 -0
  36. data/levels/bisect/.githug/objects/pack/pack-59fab357f3158a9640633de6a3326ed79a2b4fe6.pack +0 -0
  37. data/levels/bisect/.githug/packed-refs +10 -0
  38. data/levels/bisect/makefile +2 -0
  39. data/levels/bisect/prog.rb +3 -0
  40. data/levels/bisect/test.rb +4 -0
  41. data/levels/bisect.rb +15 -0
  42. data/levels/blame/.githug/COMMIT_EDITMSG +1 -0
  43. data/levels/blame/.githug/HEAD +1 -0
  44. data/levels/blame/.githug/config +5 -0
  45. data/levels/blame/.githug/description +1 -0
  46. data/levels/blame/.githug/hooks/applypatch-msg.sample +15 -0
  47. data/levels/blame/.githug/hooks/commit-msg.sample +24 -0
  48. data/levels/blame/.githug/hooks/post-commit.sample +8 -0
  49. data/levels/blame/.githug/hooks/post-receive.sample +15 -0
  50. data/levels/blame/.githug/hooks/post-update.sample +8 -0
  51. data/levels/blame/.githug/hooks/pre-applypatch.sample +14 -0
  52. data/levels/blame/.githug/hooks/pre-commit.sample +46 -0
  53. data/levels/blame/.githug/hooks/pre-rebase.sample +169 -0
  54. data/levels/blame/.githug/hooks/prepare-commit-msg.sample +36 -0
  55. data/levels/blame/.githug/hooks/update.sample +128 -0
  56. data/levels/blame/.githug/index +0 -0
  57. data/levels/blame/.githug/info/exclude +6 -0
  58. data/levels/blame/.githug/logs/HEAD +5 -0
  59. data/levels/blame/.githug/logs/refs/heads/master +5 -0
  60. data/levels/blame/.githug/objects/00/d6bf5341b263ccaf32e7973be55126eb30a343 +0 -0
  61. data/levels/blame/.githug/objects/05/07c26fed4d111a8344763be9af68af90f0ecf2 +0 -0
  62. data/levels/blame/.githug/objects/09/4094808dc6dc336c93c8602190a9e5f7bd6a11 +2 -0
  63. data/levels/blame/.githug/objects/21/15d78864000292628872941b14521f90187eed +0 -0
  64. data/levels/blame/.githug/objects/31/11dda1f5b08d50ac44b99acabfa54f1e6e72b0 +2 -0
  65. data/levels/blame/.githug/objects/50/8db115ba34a0e4e8667653aebe0265bb4f7e80 +0 -0
  66. data/levels/blame/.githug/objects/5e/8863df752e3b7f2150df7c78f12bef6f1ff00e +0 -0
  67. data/levels/blame/.githug/objects/67/788a4b90180c7588d7bd0ad8032957b0f429ba +0 -0
  68. data/levels/blame/.githug/objects/70/d00535a3a25b0ac1736dd3d306d6271e5427ed +0 -0
  69. data/levels/blame/.githug/objects/97/bdd0cccf9f4b8730f78cb53a81a74f205dbcc2 +1 -0
  70. data/levels/blame/.githug/objects/ab/08819ba3ffaeba17d4f870dc3a458a904519f4 +0 -0
  71. data/levels/blame/.githug/objects/be/96fe46de646f6a5c728f90cc884aef96fa1d6f +0 -0
  72. data/levels/blame/.githug/objects/cd/9c6b9ab1a6f56cccc69b6aa661f1d67ba5fb46 +0 -0
  73. data/levels/blame/.githug/objects/dd/df1d8ebd60eec169c15a5b23cb49a58d2ed5a0 +4 -0
  74. data/levels/blame/.githug/objects/ff/d39c2dbfd94bdbca06d48686e0cbda642f3de7 +1 -0
  75. data/levels/blame/.githug/refs/heads/master +1 -0
  76. data/levels/blame/config.rb +16 -0
  77. data/levels/blame.rb +15 -0
  78. data/levels/branch.rb +18 -0
  79. data/levels/branch_at.rb +25 -0
  80. data/levels/checkout.rb +18 -0
  81. data/levels/checkout_file.rb +25 -0
  82. data/levels/checkout_tag.rb +39 -0
  83. data/levels/checkout_tag_over_branch.rb +46 -0
  84. data/levels/cherry-pick/.githug/COMMIT_EDITMSG +1 -0
  85. data/levels/cherry-pick/.githug/HEAD +1 -0
  86. data/levels/cherry-pick/.githug/config +6 -0
  87. data/levels/cherry-pick/.githug/description +1 -0
  88. data/levels/cherry-pick/.githug/hooks/applypatch-msg.sample +15 -0
  89. data/levels/cherry-pick/.githug/hooks/commit-msg.sample +24 -0
  90. data/levels/cherry-pick/.githug/hooks/post-update.sample +8 -0
  91. data/levels/cherry-pick/.githug/hooks/pre-applypatch.sample +14 -0
  92. data/levels/cherry-pick/.githug/hooks/pre-commit.sample +50 -0
  93. data/levels/cherry-pick/.githug/hooks/pre-rebase.sample +169 -0
  94. data/levels/cherry-pick/.githug/hooks/prepare-commit-msg.sample +36 -0
  95. data/levels/cherry-pick/.githug/hooks/update.sample +128 -0
  96. data/levels/cherry-pick/.githug/index +0 -0
  97. data/levels/cherry-pick/.githug/info/exclude +6 -0
  98. data/levels/cherry-pick/.githug/logs/HEAD +14 -0
  99. data/levels/cherry-pick/.githug/logs/refs/heads/master +4 -0
  100. data/levels/cherry-pick/.githug/logs/refs/heads/new-feature +6 -0
  101. data/levels/cherry-pick/.githug/objects/05/aa97588aff673dcf00e0e1b835d6ec6207a7d9 +0 -0
  102. data/levels/cherry-pick/.githug/objects/14/ad8f1413c40e0e5be6f6cbdec392a783c1d754 +0 -0
  103. data/levels/cherry-pick/.githug/objects/1b/912962174dd58fbbf1627ec816fa6672c70854 +0 -0
  104. data/levels/cherry-pick/.githug/objects/22/f99f3abfd02190a760388c8845c190247859fe +0 -0
  105. data/levels/cherry-pick/.githug/objects/23/2d266a78d5ef7196f1ede14972ccf7ee19e587 +0 -0
  106. data/levels/cherry-pick/.githug/objects/31/68bdc3ae7e0ab987dda238beab9c0582c7fc07 +0 -0
  107. data/levels/cherry-pick/.githug/objects/49/4fa3fc1c15986f9a950aba8607da591223614c +0 -0
  108. data/levels/cherry-pick/.githug/objects/4a/1961bce62840eaef9c4392fe5cc799e38c9b7b +0 -0
  109. data/levels/cherry-pick/.githug/objects/54/22c2405527c05c23b243b2535a97b6cefa1427 +0 -0
  110. data/levels/cherry-pick/.githug/objects/54/f3308533fd4400c94c4cd5827cd38036a67a76 +0 -0
  111. data/levels/cherry-pick/.githug/objects/58/a8c8edcfdd00c6d8cce9aada8f987a1677571f +0 -0
  112. data/levels/cherry-pick/.githug/objects/6e/dea632d9540e060bca97dda0897df2b7da0ec0 +2 -0
  113. data/levels/cherry-pick/.githug/objects/85/4e7ac38b3e8df02ea1480ec45aa9e7865f03d7 +0 -0
  114. data/levels/cherry-pick/.githug/objects/93/3a97260a11a5ee49bb8a4b7b097cb2fb38f85c +0 -0
  115. data/levels/cherry-pick/.githug/objects/9a/e59e88e6af362c069847e621b971bafff158ac +0 -0
  116. data/levels/cherry-pick/.githug/objects/a2/14badc644facc4722083aedf91d9339ffdffbf +0 -0
  117. data/levels/cherry-pick/.githug/objects/b3/0c6a965415df6aef5f2903f9892fa5481152fc +0 -0
  118. data/levels/cherry-pick/.githug/objects/c6/0c612734f25b9c989d954621491e9ca3c9e061 +0 -0
  119. data/levels/cherry-pick/.githug/objects/ca/32a6dac7b6f97975edbe19a4296c2ee7682f68 +0 -0
  120. data/levels/cherry-pick/.githug/objects/cf/d8ce38c22c5fe83cc04e23f94646464f20d990 +0 -0
  121. data/levels/cherry-pick/.githug/objects/d5/02e68bfe397140e4ac2a819b138545abca604e +0 -0
  122. data/levels/cherry-pick/.githug/objects/d5/123e58b37fd886dff2b96bfe5ec08a498192aa +0 -0
  123. data/levels/cherry-pick/.githug/objects/ea/2a47c19b85fc321e2737ddc49db3deeba3a1b5 +0 -0
  124. data/levels/cherry-pick/.githug/objects/ea/3dbcc5e2d2359698c3606b0ec44af9f76def54 +0 -0
  125. data/levels/cherry-pick/.githug/refs/heads/master +1 -0
  126. data/levels/cherry-pick/.githug/refs/heads/new-feature +1 -0
  127. data/levels/cherry-pick/README.md +2 -0
  128. data/levels/cherry-pick/hardcore-math.js +3 -0
  129. data/levels/cherry-pick/nokia.js +1 -0
  130. data/levels/cherry-pick.rb +19 -0
  131. data/levels/clone.rb +10 -0
  132. data/levels/clone_to_folder.rb +10 -0
  133. data/levels/commit.rb +17 -0
  134. data/levels/commit_amend.rb +23 -0
  135. data/levels/commit_in_future.rb +19 -0
  136. data/levels/config.rb +33 -0
  137. data/levels/conflict/.githug/COMMIT_EDITMSG +14 -0
  138. data/levels/conflict/.githug/HEAD +1 -0
  139. data/levels/conflict/.githug/config +5 -0
  140. data/levels/conflict/.githug/description +1 -0
  141. data/levels/conflict/.githug/hooks/applypatch-msg.sample +15 -0
  142. data/levels/conflict/.githug/hooks/commit-msg.sample +24 -0
  143. data/levels/conflict/.githug/hooks/post-update.sample +8 -0
  144. data/levels/conflict/.githug/hooks/pre-applypatch.sample +14 -0
  145. data/levels/conflict/.githug/hooks/pre-commit.sample +50 -0
  146. data/levels/conflict/.githug/hooks/pre-rebase.sample +169 -0
  147. data/levels/conflict/.githug/hooks/prepare-commit-msg.sample +36 -0
  148. data/levels/conflict/.githug/hooks/update.sample +128 -0
  149. data/levels/conflict/.githug/index +0 -0
  150. data/levels/conflict/.githug/info/exclude +6 -0
  151. data/levels/conflict/.githug/logs/HEAD +12 -0
  152. data/levels/conflict/.githug/logs/refs/heads/master +4 -0
  153. data/levels/conflict/.githug/logs/refs/heads/mybranch +5 -0
  154. data/levels/conflict/.githug/objects/1d/b9aa5013e47f1482ec90323d926171a99c28af +0 -0
  155. data/levels/conflict/.githug/objects/25/b3f9c339430b35ae5822b2ef90e763284dc007 +0 -0
  156. data/levels/conflict/.githug/objects/2d/0d90051e320215f54f357e746c9838490557e7 +1 -0
  157. data/levels/conflict/.githug/objects/30/6868e3258be1f35ae43db71e3a6d7edf42ffe7 +0 -0
  158. data/levels/conflict/.githug/objects/30/cc28e66966109bb5bfbe96d6c817c367d2050a +0 -0
  159. data/levels/conflict/.githug/objects/38/21e4362c5a76db1112b46b9210670cd5bab482 +0 -0
  160. data/levels/conflict/.githug/objects/3c/b65bef44ae724ddf9e89640e7e2754dea1a47f +0 -0
  161. data/levels/conflict/.githug/objects/3d/7aec017559be2b61cab850dafdcb2b6212f1c3 +1 -0
  162. data/levels/conflict/.githug/objects/40/e20a455ac2731ad25c297b03aa543d7eedf6ab +0 -0
  163. data/levels/conflict/.githug/objects/44/30fd3f45c832e685350417600a9862c94d20f1 +0 -0
  164. data/levels/conflict/.githug/objects/46/677964e679f3e727356d0860c643a12a87902b +0 -0
  165. data/levels/conflict/.githug/objects/50/a127cb066eb903a6fa59d71802c10cb442fb3b +0 -0
  166. data/levels/conflict/.githug/objects/55/ad5af2a93afa778971e3d04faf20f6c368b6ba +0 -0
  167. data/levels/conflict/.githug/objects/6b/0c0b32bdca3af9beb831744cb755d6fdc7c7c0 +2 -0
  168. data/levels/conflict/.githug/objects/75/179304f4fab00613f08a9412b6cb0965bfa564 +2 -0
  169. data/levels/conflict/.githug/objects/7c/36daf29660ae4a2f09345427ef76f1d38f902f +0 -0
  170. data/levels/conflict/.githug/objects/88/e0473c9da347c6311f5f8eca8d256bf25402b6 +2 -0
  171. data/levels/conflict/.githug/objects/bd/c7bec8acae9b3eabf0a15b223a48211b7a89a1 +2 -0
  172. data/levels/conflict/.githug/objects/c7/97f979cf24ba148bf10d5e26f5d7402dd5f2e1 +0 -0
  173. data/levels/conflict/.githug/objects/da/ae380200ed6eeaafd926177018e8ff3009b988 +0 -0
  174. data/levels/conflict/.githug/refs/heads/master +1 -0
  175. data/levels/conflict/.githug/refs/heads/mybranch +1 -0
  176. data/levels/conflict/poem.txt +5 -0
  177. data/levels/conflict.rb +23 -0
  178. data/levels/congratulation.rb +10 -0
  179. data/levels/contribute.rb +25 -0
  180. data/levels/delete_branch/.githug/COMMIT_EDITMSG +1 -0
  181. data/levels/delete_branch/.githug/HEAD +1 -0
  182. data/levels/delete_branch/.githug/config +7 -0
  183. data/levels/delete_branch/.githug/description +1 -0
  184. data/levels/delete_branch/.githug/hooks/applypatch-msg.sample +15 -0
  185. data/levels/delete_branch/.githug/hooks/commit-msg.sample +24 -0
  186. data/levels/delete_branch/.githug/hooks/post-update.sample +8 -0
  187. data/levels/delete_branch/.githug/hooks/pre-applypatch.sample +14 -0
  188. data/levels/delete_branch/.githug/hooks/pre-commit.sample +49 -0
  189. data/levels/delete_branch/.githug/hooks/pre-push.sample +53 -0
  190. data/levels/delete_branch/.githug/hooks/pre-rebase.sample +169 -0
  191. data/levels/delete_branch/.githug/hooks/prepare-commit-msg.sample +36 -0
  192. data/levels/delete_branch/.githug/hooks/update.sample +128 -0
  193. data/levels/delete_branch/.githug/index +0 -0
  194. data/levels/delete_branch/.githug/info/exclude +6 -0
  195. data/levels/delete_branch/.githug/logs/HEAD +4 -0
  196. data/levels/delete_branch/.githug/logs/refs/heads/delete_me +1 -0
  197. data/levels/delete_branch/.githug/logs/refs/heads/master +1 -0
  198. data/levels/delete_branch/.githug/objects/b6/0afe294eb3c200d646995c9e0234470157c1b0 +2 -0
  199. data/levels/delete_branch/.githug/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  200. data/levels/delete_branch/.githug/objects/e8/0ad49ace82167de62e498622d70377d913c79e +0 -0
  201. data/levels/delete_branch/.githug/refs/heads/delete_me +1 -0
  202. data/levels/delete_branch/.githug/refs/heads/master +1 -0
  203. data/levels/delete_branch/readme +0 -0
  204. data/levels/delete_branch.rb +15 -0
  205. data/levels/diff/.githug/COMMIT_EDITMSG +1 -0
  206. data/levels/diff/.githug/HEAD +1 -0
  207. data/levels/diff/.githug/config +5 -0
  208. data/levels/diff/.githug/description +1 -0
  209. data/levels/diff/.githug/hooks/applypatch-msg.sample +15 -0
  210. data/levels/diff/.githug/hooks/commit-msg.sample +24 -0
  211. data/levels/diff/.githug/hooks/post-commit.sample +8 -0
  212. data/levels/diff/.githug/hooks/post-receive.sample +15 -0
  213. data/levels/diff/.githug/hooks/post-update.sample +8 -0
  214. data/levels/diff/.githug/hooks/pre-applypatch.sample +14 -0
  215. data/levels/diff/.githug/hooks/pre-commit.sample +46 -0
  216. data/levels/diff/.githug/hooks/pre-rebase.sample +169 -0
  217. data/levels/diff/.githug/hooks/prepare-commit-msg.sample +36 -0
  218. data/levels/diff/.githug/hooks/update.sample +128 -0
  219. data/levels/diff/.githug/index +0 -0
  220. data/levels/diff/.githug/info/exclude +6 -0
  221. data/levels/diff/.githug/logs/HEAD +1 -0
  222. data/levels/diff/.githug/logs/refs/heads/master +1 -0
  223. data/levels/diff/.githug/objects/1b/6582364621c92707b587409cedbc4f77fc0cee +0 -0
  224. data/levels/diff/.githug/objects/4f/703ca9bd25781b6758eeb3c42ed5348610ba6d +2 -0
  225. data/levels/diff/.githug/objects/dc/aa55e97af34402e84d5336da37abcccc23cba6 +3 -0
  226. data/levels/diff/.githug/refs/heads/master +1 -0
  227. data/levels/diff/app.rb +42 -0
  228. data/levels/diff.rb +16 -0
  229. data/levels/fetch.rb +71 -0
  230. data/levels/find_old_branch/.githug/COMMIT_EDITMSG +1 -0
  231. data/levels/find_old_branch/.githug/HEAD +1 -0
  232. data/levels/find_old_branch/.githug/ORIG_HEAD +1 -0
  233. data/levels/find_old_branch/.githug/config +6 -0
  234. data/levels/find_old_branch/.githug/description +1 -0
  235. data/levels/find_old_branch/.githug/hooks/applypatch-msg.sample +15 -0
  236. data/levels/find_old_branch/.githug/hooks/commit-msg.sample +24 -0
  237. data/levels/find_old_branch/.githug/hooks/post-commit.sample +8 -0
  238. data/levels/find_old_branch/.githug/hooks/post-receive.sample +15 -0
  239. data/levels/find_old_branch/.githug/hooks/post-update.sample +8 -0
  240. data/levels/find_old_branch/.githug/hooks/pre-applypatch.sample +14 -0
  241. data/levels/find_old_branch/.githug/hooks/pre-commit.sample +50 -0
  242. data/levels/find_old_branch/.githug/hooks/pre-rebase.sample +169 -0
  243. data/levels/find_old_branch/.githug/hooks/prepare-commit-msg.sample +36 -0
  244. data/levels/find_old_branch/.githug/hooks/update.sample +128 -0
  245. data/levels/find_old_branch/.githug/index +0 -0
  246. data/levels/find_old_branch/.githug/info/exclude +7 -0
  247. data/levels/find_old_branch/.githug/logs/HEAD +7 -0
  248. data/levels/find_old_branch/.githug/logs/refs/heads/blowup_sun_for_ransom +1 -0
  249. data/levels/find_old_branch/.githug/logs/refs/heads/cure_common_cold +2 -0
  250. data/levels/find_old_branch/.githug/logs/refs/heads/kill_the_batman +4 -0
  251. data/levels/find_old_branch/.githug/logs/refs/heads/solve_world_hunger +2 -0
  252. data/levels/find_old_branch/.githug/objects/05/e9c01bd3c9264761dd0cde477400a2c3104642 +0 -0
  253. data/levels/find_old_branch/.githug/objects/1f/0a136ddd98f61934d15eb00444df32d8e8254b +0 -0
  254. data/levels/find_old_branch/.githug/objects/32/4336a8401afc8ca384eaafe6615c84d552dd2c +0 -0
  255. data/levels/find_old_branch/.githug/objects/50/72aab6bd73accec89ad3aa077f43aab8a5e507 +0 -0
  256. data/levels/find_old_branch/.githug/objects/5d/130caf89f1a4bba6a1fffe72c484f3ab659e08 +0 -0
  257. data/levels/find_old_branch/.githug/objects/68/76e5b41fb693190df76b1baef6ef98623b4f1a +0 -0
  258. data/levels/find_old_branch/.githug/objects/6a/7702145d1eb91c9f79583eabb984027b12e60c +0 -0
  259. data/levels/find_old_branch/.githug/objects/89/4a16d6f1a48224e9006b4a6f0fe3846da19bec +0 -0
  260. data/levels/find_old_branch/.githug/objects/b8/c67b45e5fe9e4b39ac7ade725673f7c90bdfc3 +0 -0
  261. data/levels/find_old_branch/.githug/objects/bf/76434bc7e7346c6fef5a98aee0f7cfc0788f34 +0 -0
  262. data/levels/find_old_branch/.githug/refs/heads/blowup_sun_for_ransom +1 -0
  263. data/levels/find_old_branch/.githug/refs/heads/cure_common_cold +1 -0
  264. data/levels/find_old_branch/.githug/refs/heads/kill_the_batman +1 -0
  265. data/levels/find_old_branch/.githug/refs/heads/solve_world_hunger +1 -0
  266. data/levels/find_old_branch/TODO +1 -0
  267. data/levels/find_old_branch/myfile.txt +1 -0
  268. data/levels/find_old_branch.rb +15 -0
  269. data/levels/grep/.githug/COMMIT_EDITMSG +1 -0
  270. data/levels/grep/.githug/HEAD +1 -0
  271. data/levels/grep/.githug/config +6 -0
  272. data/levels/grep/.githug/description +1 -0
  273. data/levels/grep/.githug/hooks/applypatch-msg.sample +15 -0
  274. data/levels/grep/.githug/hooks/commit-msg.sample +24 -0
  275. data/levels/grep/.githug/hooks/post-commit.sample +8 -0
  276. data/levels/grep/.githug/hooks/post-receive.sample +15 -0
  277. data/levels/grep/.githug/hooks/post-update.sample +8 -0
  278. data/levels/grep/.githug/hooks/pre-applypatch.sample +14 -0
  279. data/levels/grep/.githug/hooks/pre-commit.sample +46 -0
  280. data/levels/grep/.githug/hooks/pre-rebase.sample +169 -0
  281. data/levels/grep/.githug/hooks/prepare-commit-msg.sample +36 -0
  282. data/levels/grep/.githug/hooks/update.sample +128 -0
  283. data/levels/grep/.githug/index +0 -0
  284. data/levels/grep/.githug/info/exclude +6 -0
  285. data/levels/grep/.githug/logs/HEAD +1 -0
  286. data/levels/grep/.githug/logs/refs/heads/master +1 -0
  287. data/levels/grep/.githug/objects/12/c702f8b25b6b528cf904670b854dba3eba0f45 +3 -0
  288. data/levels/grep/.githug/objects/6f/45753f4a16b69f5b2215f2dbe8245f073353cc +1 -0
  289. data/levels/grep/.githug/objects/a4/1fe0c342be5c9930328cbb4315acebbd9c94b2 +0 -0
  290. data/levels/grep/.githug/objects/d3/f53e82aa015d1eea3b06c3b62dfbacee83bbe1 +0 -0
  291. data/levels/grep/.githug/refs/heads/master +1 -0
  292. data/levels/grep/app.rb +45 -0
  293. data/levels/grep/config.rb +17 -0
  294. data/levels/grep.rb +14 -0
  295. data/levels/ignore.rb +42 -0
  296. data/levels/include.rb +21 -0
  297. data/levels/init.rb +10 -0
  298. data/levels/log.rb +22 -0
  299. data/levels/merge/.githug/COMMIT_EDITMSG +1 -0
  300. data/levels/merge/.githug/HEAD +1 -0
  301. data/levels/merge/.githug/config +6 -0
  302. data/levels/merge/.githug/description +1 -0
  303. data/levels/merge/.githug/hooks/applypatch-msg.sample +15 -0
  304. data/levels/merge/.githug/hooks/commit-msg.sample +24 -0
  305. data/levels/merge/.githug/hooks/post-commit.sample +8 -0
  306. data/levels/merge/.githug/hooks/post-receive.sample +15 -0
  307. data/levels/merge/.githug/hooks/post-update.sample +8 -0
  308. data/levels/merge/.githug/hooks/pre-applypatch.sample +14 -0
  309. data/levels/merge/.githug/hooks/pre-commit.sample +46 -0
  310. data/levels/merge/.githug/hooks/pre-rebase.sample +169 -0
  311. data/levels/merge/.githug/hooks/prepare-commit-msg.sample +36 -0
  312. data/levels/merge/.githug/hooks/update.sample +128 -0
  313. data/levels/merge/.githug/index +0 -0
  314. data/levels/merge/.githug/info/exclude +6 -0
  315. data/levels/merge/.githug/logs/HEAD +4 -0
  316. data/levels/merge/.githug/logs/refs/heads/feature +2 -0
  317. data/levels/merge/.githug/logs/refs/heads/master +1 -0
  318. data/levels/merge/.githug/objects/ad/24149d789e59d4b5f9ce41cda90110ca0f98b7 +0 -0
  319. data/levels/merge/.githug/objects/ae/fde3a01f6e10d72fd4899ce14c8b2654d3eb45 +0 -0
  320. data/levels/merge/.githug/objects/cc/8ea5a233df119d025eb240b9470e1ca76a151c +0 -0
  321. data/levels/merge/.githug/objects/e1/2277fe88657a072f1c4eb7d9320e4e6a74ba95 +0 -0
  322. data/levels/merge/.githug/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  323. data/levels/merge/.githug/refs/heads/feature +1 -0
  324. data/levels/merge/.githug/refs/heads/master +1 -0
  325. data/levels/merge/file1 +0 -0
  326. data/levels/merge.rb +16 -0
  327. data/levels/merge_squash.rb +49 -0
  328. data/levels/number_of_files_committed.rb +51 -0
  329. data/levels/pull.rb +16 -0
  330. data/levels/pull_rebase.rb +49 -0
  331. data/levels/push.rb +67 -0
  332. data/levels/push_branch.rb +88 -0
  333. data/levels/push_tags.rb +63 -0
  334. data/levels/rebase/.githug/COMMIT_EDITMSG +1 -0
  335. data/levels/rebase/.githug/HEAD +1 -0
  336. data/levels/rebase/.githug/ORIG_HEAD +1 -0
  337. data/levels/rebase/.githug/config +7 -0
  338. data/levels/rebase/.githug/index +0 -0
  339. data/levels/rebase/.githug/logs/HEAD +13 -0
  340. data/levels/rebase/.githug/logs/refs/heads/feature +4 -0
  341. data/levels/rebase/.githug/logs/refs/heads/master +2 -0
  342. data/levels/rebase/.githug/objects/0c/d212c5b28da2e65ed4900712dd36c8adce48ad +0 -0
  343. data/levels/rebase/.githug/objects/44/19b972c0cd1b346ac90332aa7c5cc949589f78 +0 -0
  344. data/levels/rebase/.githug/objects/54/3b9bebdc6bd5c4b22136034a95dd097a57d3dd +0 -0
  345. data/levels/rebase/.githug/objects/81/78c76d627cade75005b40711b92f4177bc6cfc +0 -0
  346. data/levels/rebase/.githug/objects/98/205e9faf10cf33d2ef7c0f66e402540c62613a +2 -0
  347. data/levels/rebase/.githug/objects/a7/8bcab6232e9382a86436cdfcb2ed0391b1f0ac +4 -0
  348. data/levels/rebase/.githug/objects/b7/7313d7be366609dd2e77aa96d7fd73f4e27853 +0 -0
  349. data/levels/rebase/.githug/objects/b9/2d5d55d379cfb90b750e6472fc983f32ad9a71 +0 -0
  350. data/levels/rebase/.githug/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
  351. data/levels/rebase/.githug/objects/ed/0fdcf366b21b8984fb37ea34106978a2e5c5ba +0 -0
  352. data/levels/rebase/.githug/refs/heads/feature +1 -0
  353. data/levels/rebase/.githug/refs/heads/master +1 -0
  354. data/levels/rebase/README +1 -0
  355. data/levels/rebase.rb +16 -0
  356. data/levels/rebase_conflict.rb +55 -0
  357. data/levels/rebase_onto.rb +45 -0
  358. data/levels/remote.rb +16 -0
  359. data/levels/remote_add.rb +16 -0
  360. data/levels/remote_url.rb +17 -0
  361. data/levels/rename.rb +18 -0
  362. data/levels/rename_commit.rb +25 -0
  363. data/levels/reorder.rb +30 -0
  364. data/levels/repack.rb +19 -0
  365. data/levels/reset.rb +22 -0
  366. data/levels/reset_soft.rb +22 -0
  367. data/levels/restore.rb +28 -0
  368. data/levels/restructure.rb +40 -0
  369. data/levels/revert.rb +30 -0
  370. data/levels/rm.rb +20 -0
  371. data/levels/rm_cached.rb +18 -0
  372. data/levels/squash.rb +29 -0
  373. data/levels/stage_lines.rb +29 -0
  374. data/levels/stash/.githug/COMMIT_EDITMSG +1 -0
  375. data/levels/stash/.githug/HEAD +1 -0
  376. data/levels/stash/.githug/config +7 -0
  377. data/levels/stash/.githug/description +1 -0
  378. data/levels/stash/.githug/hooks/applypatch-msg.sample +15 -0
  379. data/levels/stash/.githug/hooks/commit-msg.sample +24 -0
  380. data/levels/stash/.githug/hooks/post-update.sample +8 -0
  381. data/levels/stash/.githug/hooks/pre-applypatch.sample +14 -0
  382. data/levels/stash/.githug/hooks/pre-commit.sample +50 -0
  383. data/levels/stash/.githug/hooks/pre-rebase.sample +169 -0
  384. data/levels/stash/.githug/hooks/prepare-commit-msg.sample +36 -0
  385. data/levels/stash/.githug/hooks/update.sample +128 -0
  386. data/levels/stash/.githug/index +0 -0
  387. data/levels/stash/.githug/info/exclude +6 -0
  388. data/levels/stash/.githug/logs/HEAD +1 -0
  389. data/levels/stash/.githug/logs/refs/heads/master +1 -0
  390. data/levels/stash/.githug/objects/02/060592b31c9e12ffe1b282addf9537c5ef8e1f +0 -0
  391. data/levels/stash/.githug/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  392. data/levels/stash/.githug/objects/7f/82d7e4fba66980af16da540e18d8955518cdc2 +0 -0
  393. data/levels/stash/.githug/objects/85/e560abcd7e3255dcd91982476e432f4d3d1b51 +0 -0
  394. data/levels/stash/.githug/refs/heads/master +1 -0
  395. data/levels/stash/lyrics.txt +13 -0
  396. data/levels/stash.rb +17 -0
  397. data/levels/status.rb +26 -0
  398. data/levels/submodule.rb +20 -0
  399. data/levels/tag.rb +18 -0
  400. data/levels/unstash/.githug/COMMIT_EDITMSG +1 -0
  401. data/levels/unstash/.githug/HEAD +1 -0
  402. data/levels/unstash/.githug/config +7 -0
  403. data/levels/unstash/.githug/description +1 -0
  404. data/levels/unstash/.githug/hooks/applypatch-msg.sample +15 -0
  405. data/levels/unstash/.githug/hooks/commit-msg.sample +24 -0
  406. data/levels/unstash/.githug/hooks/post-update.sample +8 -0
  407. data/levels/unstash/.githug/hooks/pre-applypatch.sample +14 -0
  408. data/levels/unstash/.githug/hooks/pre-commit.sample +50 -0
  409. data/levels/unstash/.githug/hooks/pre-rebase.sample +169 -0
  410. data/levels/unstash/.githug/hooks/prepare-commit-msg.sample +36 -0
  411. data/levels/unstash/.githug/hooks/update.sample +128 -0
  412. data/levels/unstash/.githug/index +0 -0
  413. data/levels/unstash/.githug/info/exclude +6 -0
  414. data/levels/unstash/.githug/logs/HEAD +1 -0
  415. data/levels/unstash/.githug/logs/refs/heads/master +1 -0
  416. data/levels/unstash/.githug/objects/02/060592b31c9e12ffe1b282addf9537c5ef8e1f +0 -0
  417. data/levels/unstash/.githug/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  418. data/levels/unstash/.githug/objects/7f/82d7e4fba66980af16da540e18d8955518cdc2 +0 -0
  419. data/levels/unstash/.githug/objects/85/e560abcd7e3255dcd91982476e432f4d3d1b51 +0 -0
  420. data/levels/unstash/.githug/refs/heads/master +1 -0
  421. data/levels/unstash/lyrics.txt +13 -0
  422. data/levels/unstash.rb +22 -0
  423. data/lib/githug/cli.rb +121 -0
  424. data/lib/githug/extensions/grit/ruby1.9.rb +21 -0
  425. data/lib/githug/game.rb +57 -0
  426. data/lib/githug/level.rb +135 -0
  427. data/lib/githug/profile.rb +80 -0
  428. data/lib/githug/repository.rb +48 -0
  429. data/lib/githug/ui.rb +59 -0
  430. data/lib/githug/version.rb +3 -0
  431. data/lib/githug.rb +16 -0
  432. data/mygithug.gemspec +27 -0
  433. data/spec/githug/cli_spec.rb +133 -0
  434. data/spec/githug/game_spec.rb +96 -0
  435. data/spec/githug/level_spec.rb +159 -0
  436. data/spec/githug/profile_spec.rb +89 -0
  437. data/spec/githug/repository_spec.rb +97 -0
  438. data/spec/githug/ui_spec.rb +112 -0
  439. data/spec/githug_spec.rb +316 -0
  440. data/spec/spec_helper.rb +1 -0
  441. data/spec/support/files/test_level.rb +16 -0
  442. metadata +549 -0
@@ -0,0 +1,88 @@
1
+ difficulty 2
2
+ description "你已经创建了本地分支 `test_branch`,开发已经完成,你需要将此分支 push 到远程代码库。
3
+ 注意:只能push `test_branch` 分支,不能push其它分支。"
4
+
5
+ setup do
6
+
7
+ # remember the working directory so we can come back to it later
8
+ cwd = Dir.pwd
9
+ # initialize another git repo to be used as a "remote"
10
+ tmpdir = Dir.mktmpdir
11
+
12
+ # local repo
13
+ repo.init
14
+
15
+ FileUtils.touch "file1"
16
+ repo.add "file1"
17
+ repo.commit_all "committed changes on master"
18
+
19
+ # copy the repo to remote
20
+ FileUtils.cp_r ".", tmpdir
21
+
22
+ # add another file. If successful this file won't be pushed to the remote repository
23
+ FileUtils.touch "file2"
24
+ repo.add "file2"
25
+ repo.commit_all "If this commit gets pushed to repo, then you have lost the level :( "
26
+
27
+ #This branch should not be pushed to to the remote repository
28
+ `git checkout -b other_branch --quiet`
29
+ # add another file
30
+ FileUtils.touch "file3"
31
+ repo.add "file3"
32
+ repo.commit_all "If this commit gets pushed to repo, then you have lost the level :( "
33
+
34
+ `git checkout -b test_branch --quiet`
35
+
36
+ #This file should get pushed if the level is successful
37
+ FileUtils.touch "file4"
38
+ repo.add "file4"
39
+ repo.commit_all "committed change on test_branch"
40
+
41
+ # remote repo
42
+ Dir.chdir tmpdir
43
+
44
+ repo.init
45
+
46
+ # make a 'non-bare' repo accept pushes
47
+ `git config receive.denyCurrentBranch ignore`
48
+
49
+ # change back to original repo to set up a remote
50
+ Dir.chdir cwd
51
+ `git remote add origin #{tmpdir}/.git`
52
+ `git fetch --quiet origin`
53
+ `git branch -u origin/master master 2> /dev/null`
54
+
55
+ `git checkout master --quiet` #return to master branch
56
+ end
57
+
58
+ solution do
59
+ repo.init
60
+ result = false
61
+
62
+ #each branch consits of one line, `wc -l counts the number of lines in order to get the number of remote branches`
63
+ #At the moment Grit doesn't support remote branch references but is on the ToDo list. This should be revisited when Grit implements the change
64
+ num_remote_branches = `git branch -r`.split("\n").count
65
+
66
+ # counts the number of commits in the remote master branch'
67
+ remote_master_commits = repo.commits('origin/master').count
68
+ remote_test_branch_commits = repo.commits('origin/test_branch').count #if returns 0 indicates that the remote test_branch doesn't exist
69
+
70
+ #Level will be successful if the remote master branch remains at 1 commit, the remote test_branch exits and the number of remote branches
71
+ if remote_master_commits == 1 and remote_test_branch_commits > 0 and num_remote_branches == 2
72
+ result = true
73
+
74
+ #User pushed up too many branches, level failed
75
+ elsif num_remote_branches > 2
76
+ puts "*** It looks like you pushed up too many branches. You need to make sure only 'test_branch' gets pushed. Please try again! ***"
77
+
78
+ #User pushed up the master banch, level failed
79
+ elsif remote_master_commits > 1
80
+ puts "*** It looks like you pushed up new master branch changes. You need to make sure only 'test_branch' gets pushed. Please try again! ***"
81
+ end
82
+
83
+ result
84
+ end
85
+
86
+ hint do
87
+ puts "研究一下 `git push` 命令吧,可以使用 `git push --help`"
88
+ end
@@ -0,0 +1,63 @@
1
+ difficulty 2
2
+ description "There are tags in the repository that aren't pushed into remote repository. Push them now."
3
+
4
+ setup do
5
+ # remember the working directory so we can come back to it later
6
+ cwd = Dir.pwd
7
+ # initialize another git repo to be used as a "remote"
8
+ tmpdir = Dir.mktmpdir
9
+
10
+ # local repo
11
+ repo.init
12
+
13
+ FileUtils.touch "file1"
14
+ repo.add "file1"
15
+ repo.commit_all "First commit"
16
+ repo.git.tag({'f' => true}, "tag_to_be_pushed")
17
+
18
+ FileUtils.touch "file2"
19
+ repo.add "file2"
20
+ repo.commit_all "Second commit"
21
+
22
+ # copy the repo to remote
23
+ FileUtils.cp_r ".", tmpdir
24
+
25
+ # remote repo
26
+ Dir.chdir tmpdir
27
+ repo.init
28
+ # make a 'non-bare' repo accept pushes
29
+ `git config receive.denyCurrentBranch ignore`
30
+
31
+ # change back to original repo to set up a remote
32
+ Dir.chdir cwd
33
+ `git remote add origin #{tmpdir}/.git`
34
+ `git fetch origin`
35
+
36
+ # delete tags from remote
37
+ Dir.chdir tmpdir
38
+ repo.git.tag({'d' => true}, "tag_to_be_pushed")
39
+
40
+ # change back to local repo
41
+ Dir.chdir cwd
42
+ end
43
+
44
+ solution do
45
+ solved = false
46
+
47
+ # a bit hacky solution to get tags from remote
48
+ remote_tags=
49
+ repo.git.raw_git_call("git ls-remote --tags .", repo.git.git_file_index).
50
+ first.
51
+ split("\n")
52
+
53
+ # see if we have the correct tag in the remote
54
+ remote_tags.each do |t|
55
+ solved=true if t.include?("refs/tags/tag_to_be_pushed")
56
+ end
57
+
58
+ solved
59
+ end
60
+
61
+ hint do
62
+ puts "Take a look at `--tags` flag of `git push`"
63
+ end
@@ -0,0 +1 @@
1
+ add content
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
@@ -0,0 +1 @@
1
+ 4419b972c0cd1b346ac90332aa7c5cc949589f78
@@ -0,0 +1,7 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = false
5
+ logallrefupdates = true
6
+ ignorecase = true
7
+ precomposeunicode = true
Binary file
@@ -0,0 +1,13 @@
1
+ 0000000000000000000000000000000000000000 a78bcab6232e9382a86436cdfcb2ed0391b1f0ac ipmsteven <steven.lyl147@gmail.com> 1418373185 -0800 commit (initial): init commit
2
+ a78bcab6232e9382a86436cdfcb2ed0391b1f0ac a78bcab6232e9382a86436cdfcb2ed0391b1f0ac ipmsteven <steven.lyl147@gmail.com> 1418373194 -0800 checkout: moving from master to feature
3
+ a78bcab6232e9382a86436cdfcb2ed0391b1f0ac ed0fdcf366b21b8984fb37ea34106978a2e5c5ba ipmsteven <steven.lyl147@gmail.com> 1418373239 -0800 commit: add feature
4
+ ed0fdcf366b21b8984fb37ea34106978a2e5c5ba a78bcab6232e9382a86436cdfcb2ed0391b1f0ac ipmsteven <steven.lyl147@gmail.com> 1418373246 -0800 checkout: moving from feature to master
5
+ a78bcab6232e9382a86436cdfcb2ed0391b1f0ac 98205e9faf10cf33d2ef7c0f66e402540c62613a ipmsteven <steven.lyl147@gmail.com> 1418373270 -0800 commit: add content
6
+ 98205e9faf10cf33d2ef7c0f66e402540c62613a ed0fdcf366b21b8984fb37ea34106978a2e5c5ba ipmsteven <steven.lyl147@gmail.com> 1418373282 -0800 checkout: moving from master to feature
7
+ ed0fdcf366b21b8984fb37ea34106978a2e5c5ba 98205e9faf10cf33d2ef7c0f66e402540c62613a ipmsteven <steven.lyl147@gmail.com> 1418373314 -0800 rebase: checkout master
8
+ 98205e9faf10cf33d2ef7c0f66e402540c62613a 4419b972c0cd1b346ac90332aa7c5cc949589f78 ipmsteven <steven.lyl147@gmail.com> 1418373314 -0800 rebase: add feature
9
+ 4419b972c0cd1b346ac90332aa7c5cc949589f78 4419b972c0cd1b346ac90332aa7c5cc949589f78 ipmsteven <steven.lyl147@gmail.com> 1418373314 -0800 rebase finished: returning to refs/heads/feature
10
+ 4419b972c0cd1b346ac90332aa7c5cc949589f78 98205e9faf10cf33d2ef7c0f66e402540c62613a ipmsteven <steven.lyl147@gmail.com> 1418373423 -0800 checkout: moving from feature to master
11
+ 98205e9faf10cf33d2ef7c0f66e402540c62613a 4419b972c0cd1b346ac90332aa7c5cc949589f78 ipmsteven <steven.lyl147@gmail.com> 1418373435 -0800 checkout: moving from master to feature
12
+ 4419b972c0cd1b346ac90332aa7c5cc949589f78 ed0fdcf366b21b8984fb37ea34106978a2e5c5ba ipmsteven <steven.lyl147@gmail.com> 1418373492 -0800 reset: moving to ed0fdcf
13
+ ed0fdcf366b21b8984fb37ea34106978a2e5c5ba 98205e9faf10cf33d2ef7c0f66e402540c62613a ipmsteven <steven.lyl147@gmail.com> 1418373509 -0800 checkout: moving from feature to master
@@ -0,0 +1,4 @@
1
+ 0000000000000000000000000000000000000000 a78bcab6232e9382a86436cdfcb2ed0391b1f0ac ipmsteven <steven.lyl147@gmail.com> 1418373194 -0800 branch: Created from HEAD
2
+ a78bcab6232e9382a86436cdfcb2ed0391b1f0ac ed0fdcf366b21b8984fb37ea34106978a2e5c5ba ipmsteven <steven.lyl147@gmail.com> 1418373239 -0800 commit: add feature
3
+ ed0fdcf366b21b8984fb37ea34106978a2e5c5ba 4419b972c0cd1b346ac90332aa7c5cc949589f78 ipmsteven <steven.lyl147@gmail.com> 1418373314 -0800 rebase finished: refs/heads/feature onto 98205e9faf10cf33d2ef7c0f66e402540c62613a
4
+ 4419b972c0cd1b346ac90332aa7c5cc949589f78 ed0fdcf366b21b8984fb37ea34106978a2e5c5ba ipmsteven <steven.lyl147@gmail.com> 1418373492 -0800 reset: moving to ed0fdcf
@@ -0,0 +1,2 @@
1
+ 0000000000000000000000000000000000000000 a78bcab6232e9382a86436cdfcb2ed0391b1f0ac ipmsteven <steven.lyl147@gmail.com> 1418373185 -0800 commit (initial): init commit
2
+ a78bcab6232e9382a86436cdfcb2ed0391b1f0ac 98205e9faf10cf33d2ef7c0f66e402540c62613a ipmsteven <steven.lyl147@gmail.com> 1418373270 -0800 commit: add content
@@ -0,0 +1,2 @@
1
+ x��Q
2
+ !@��^�P����2:c-��Y��[�}=x�����4�s��Έ`�1 �Lbv�H�ce���a<�Zi�eh˜ ���I��(�p-� H6�j�(z�G����琷,���i������h�O�����F@ph��Dc�n��!折u��؇�}�IY
@@ -0,0 +1,4 @@
1
+ x��Q
2
+ !E�vo
3
+ mE}R��1Y��f}]�p�V�S��� FS�1GNkd�tT
4
+ i���7���`,����;�g{���\�\귢��{ �.��+�FG��8K'��픎�'.�6/#���;�
@@ -0,0 +1 @@
1
+ ed0fdcf366b21b8984fb37ea34106978a2e5c5ba
@@ -0,0 +1 @@
1
+ 98205e9faf10cf33d2ef7c0f66e402540c62613a
@@ -0,0 +1 @@
1
+ readme
data/levels/rebase.rb ADDED
@@ -0,0 +1,16 @@
1
+ difficulty 2
2
+
3
+ description "We are using a git rebase workflow and the feature branch is ready to go into master. Let's rebase the feature branch onto our master branch."
4
+
5
+ setup do
6
+ init_from_level
7
+ end
8
+
9
+ solution do
10
+ return repo.commits('feature').last.id_abbrev != "ed0fdcf" &&
11
+ repo.commits("feature").map(&:message) == ['add feature','add content','init commit']
12
+ end
13
+
14
+ hint do
15
+ puts "You want to research the `git rebase` command"
16
+ end
@@ -0,0 +1,55 @@
1
+ difficulty 2
2
+ description "你需获取远程的最新代码,请让版本树尽量整洁(只有⼀个树⼲).过程中如果有冲突,请解决掉它!"
3
+
4
+ setup do
5
+ # remember the working directory so we can come back to it later
6
+ cwd = Dir.pwd
7
+ repo.init
8
+
9
+ # initialize another git repo to be used as a "remote"
10
+ # remote repo
11
+ tmpdir = Dir.mktmpdir
12
+ Dir.chdir tmpdir
13
+ repo.init
14
+ # make a 'non-bare' repo accept pushes
15
+ `git config receive.denyCurrentBranch ignore`
16
+
17
+ # add a different file and commit so remote and local would diverge
18
+ FileUtils.touch "file1"
19
+ repo.add "file1"
20
+ repo.commit_all "first commit"
21
+
22
+ # change back to original repo to set up a remote
23
+ Dir.chdir cwd
24
+ `git remote add origin #{tmpdir}/.git 2> /dev/null`
25
+ `git fetch origin 2> /dev/null`
26
+ `git branch -u origin/master master 2> /dev/null`
27
+
28
+ # 处理本地repo
29
+ `git pull origin master --quiet`
30
+ `echo "My Hello" >> file1 && git add file1 2> /dev/null && git commit -m "Second commit" 2> /dev/null`
31
+
32
+ Dir.chdir tmpdir
33
+ FileUtils.touch "file1"
34
+ `echo "My teammate say Hello" >> file1 && git add file1 2> /dev/null && git commit -m "Third commit" 2> /dev/null`
35
+
36
+ #制造冲突
37
+ Dir.chdir cwd
38
+ FileUtils.touch "file1"
39
+ `echo "Hello" >> file1 && git add file1 2> /dev/null && git commit -m "Forth commit" 2> /dev/null`
40
+ `git branch --set-upstream-to=origin/master master 2> /dev/null`
41
+
42
+
43
+ end
44
+
45
+ solution do
46
+ return false if 1 != repo.commits("master")[0].parents.length
47
+
48
+ txt = File.read("file1")
49
+ return false if txt =~ /[<>=|]/
50
+ true
51
+ end
52
+
53
+ hint do
54
+ puts "Take a look at `git fetch`, `git pull`, and `git rebase` 你的日志应该只有4条记录,并且file1的冲突已经解决"
55
+ end
@@ -0,0 +1,45 @@
1
+ difficulty 2
2
+
3
+ description "You have created your branch from `wrong_branch` and already made some commits, \
4
+ and you realise that you needed to create your branch from `master`. \
5
+ Rebase your commits onto `master` branch so that you don't have `wrong_branch` commits."
6
+
7
+ setup do
8
+ readme_file = "README.md"
9
+ authors_file = "authors.md"
10
+
11
+ repo.init
12
+ FileUtils.touch(authors_file)
13
+ File.open(authors_file, "w") { |f| f << "https://github.com/janis-vitols\n" }
14
+ repo.add(authors_file)
15
+ repo.commit_all("Create authors file")
16
+
17
+ repo.git.native :checkout, { "b" => true }, "wrong_branch"
18
+ File.open(authors_file, "w") { |f| f << "None\n" }
19
+ repo.add(authors_file)
20
+ repo.commit_all("Wrong changes")
21
+
22
+ repo.git.native :checkout, { "b" => true }, "readme-update"
23
+ FileUtils.touch(readme_file)
24
+ File.open(readme_file, "a") { |f| f << "# SuperApp\n" }
25
+ repo.add(readme_file)
26
+ repo.commit_all("Add app name in readme")
27
+ File.open(readme_file, "a") { |f| f << "## About\n" }
28
+ repo.add(readme_file)
29
+ repo.commit_all("Add `About` header in readme")
30
+ File.open(readme_file, "a") { |f| f << "## Install\n" }
31
+ repo.add(readme_file)
32
+ repo.commit_all("Add `Install` header in readme")
33
+ end
34
+
35
+ solution do
36
+ repo.commits("readme-update").each { |commit| return false if commit.message == "Wrong changes" }
37
+ return false unless repo.commits("readme-update").length == 4
38
+ return false unless File.readlines("authors.md").include?("https://github.com/janis-vitols\n")
39
+
40
+ true
41
+ end
42
+
43
+ hint do
44
+ puts "You want to research the `git rebase` commands `--onto` argument"
45
+ end
data/levels/remote.rb ADDED
@@ -0,0 +1,16 @@
1
+ difficulty 2
2
+
3
+ description "This project has a remote repository. Identify it."
4
+
5
+ setup do
6
+ repo.init
7
+ repo.remote_add("my_remote_repo", "https://github.com/Gazler/githug")
8
+ end
9
+
10
+ solution do
11
+ "my_remote_repo" == request("What is the name of the remote repository?")
12
+ end
13
+
14
+ hint do
15
+ puts "You are looking for a remote. You can run `git` for a list of commands."
16
+ end
@@ -0,0 +1,16 @@
1
+ difficulty 2
2
+
3
+ description "Add a remote repository called `origin` with the url https://github.com/githug/githug"
4
+
5
+ setup do
6
+ repo.init
7
+ end
8
+
9
+ solution do
10
+ result = `git remote -v`
11
+ result.include?("https://github.com/githug/githug")
12
+ end
13
+
14
+ hint do
15
+ puts "You can run `git remote --help` for the man pages."
16
+ end
@@ -0,0 +1,17 @@
1
+ difficulty 2
2
+
3
+ description "The remote repositories have a url associated to them. Please enter the url of remote_location."
4
+
5
+ setup do
6
+ repo.init
7
+ repo.remote_add("my_remote_repo", "https://github.com/Gazler/githug")
8
+ repo.remote_add("remote_location", "https://github.com/githug/not_a_repo")
9
+ end
10
+
11
+ solution do
12
+ !!(request("What is the url of the remote repository?") =~ /https:\/\/github.com\/githug\/not_a_repo\/?/)
13
+ end
14
+
15
+ hint do
16
+ puts "You can run `git remote --help` for the man pages."
17
+ end
data/levels/rename.rb ADDED
@@ -0,0 +1,18 @@
1
+ difficulty 3
2
+
3
+ description "We have a file called `oldfile.txt`. We want to rename it to `newfile.txt` and stage this change."
4
+
5
+ setup do
6
+ repo.init
7
+ FileUtils.touch("oldfile.txt")
8
+ repo.add("oldfile.txt")
9
+ repo.commit_all("Commited oldfile.txt")
10
+ end
11
+
12
+ solution do
13
+ repo.status["oldfile.txt"].type == "D" && repo.status["newfile.txt"].type == "A" && repo.status["oldfile.txt"].stage.nil?
14
+ end
15
+
16
+ hint do
17
+ puts "Take a look at `git mv`."
18
+ end
@@ -0,0 +1,25 @@
1
+ difficulty 3
2
+ description "Correct the typo in the message of your first (non-root) commit."
3
+
4
+ setup do
5
+ repo.init
6
+ FileUtils.touch "README"
7
+ repo.add "README"
8
+ repo.commit_all "Initial commit"
9
+
10
+ FileUtils.touch "file1"
11
+ repo.add "file1"
12
+ repo.commit_all "First coommit"
13
+
14
+ FileUtils.touch "file2"
15
+ repo.add "file2"
16
+ repo.commit_all "Second commit"
17
+ end
18
+
19
+ solution do
20
+ repo.commits[1].message == "First commit"
21
+ end
22
+
23
+ hint do
24
+ puts "Take a look the `-i` flag of the rebase command."
25
+ end
data/levels/reorder.rb ADDED
@@ -0,0 +1,30 @@
1
+ difficulty 4
2
+ description "You have committed several times but in the wrong order. Please reorder your commits."
3
+
4
+ setup do
5
+ repo.init
6
+
7
+ FileUtils.touch "README"
8
+ repo.add "README"
9
+ repo.commit_all "Initial Setup"
10
+
11
+ FileUtils.touch "file1"
12
+ repo.add "file1"
13
+ repo.commit_all "First commit"
14
+
15
+ FileUtils.touch "file3"
16
+ repo.add "file3"
17
+ repo.commit_all "Third commit"
18
+
19
+ FileUtils.touch "file2"
20
+ repo.add "file2"
21
+ repo.commit_all "Second commit"
22
+ end
23
+
24
+ solution do
25
+ `git log --format="%s"`.split.join("").match /Third.*Second.*First.*Initial/
26
+ end
27
+
28
+ hint do
29
+ puts "Take a look the `-i` flag of the rebase command."
30
+ end
data/levels/repack.rb ADDED
@@ -0,0 +1,19 @@
1
+ difficulty 2
2
+ description "Optimise how your repository is packaged ensuring that redundant packs are removed."
3
+
4
+ setup do
5
+ repo.init
6
+ FileUtils.touch("foo")
7
+ repo.add("foo")
8
+ repo.commit_all("Added foo")
9
+ end
10
+
11
+ solution do
12
+ result = `git count-objects -v`
13
+ required = ["count: 0", "prune-packable: 0"];
14
+ required.all? { |r| result.include?(r) }
15
+ end
16
+
17
+ hint do
18
+ puts "You want to research the `git repack` command."
19
+ end
data/levels/reset.rb ADDED
@@ -0,0 +1,22 @@
1
+ difficulty 2
2
+ description "There are two files to be committed. The goal was to add each file as a separate commit, however both were added by accident. Unstage the file `to_commit_second.rb` using the reset command (don't commit anything)."
3
+
4
+ setup do
5
+ repo.init
6
+ FileUtils.touch("README")
7
+ repo.add("README")
8
+ repo.commit_all("Initial commit")
9
+ FileUtils.touch("to_commit_first.rb")
10
+ FileUtils.touch("to_commit_second.rb")
11
+ repo.add(".")
12
+ end
13
+
14
+ solution do
15
+ return false unless (repo.status.files["to_commit_second.rb"].nil? || repo.status.files["to_commit_second.rb"].stage.nil?) && File.exists?("to_commit_second.rb")
16
+ return false if (repo.status.files["to_commit_first.rb"].nil? || repo.status.files["to_commit_first.rb"].stage.nil?)
17
+ true
18
+ end
19
+
20
+ hint do
21
+ puts "You can get some useful information for git status, it will tell you the command you need to run."
22
+ end
@@ -0,0 +1,22 @@
1
+ difficulty 2
2
+ description "You committed too soon. Now you want to undo the last commit, while keeping the index."
3
+
4
+ setup do
5
+ repo.init
6
+ FileUtils.touch("README")
7
+ repo.add("README")
8
+ repo.commit_all("Initial commit")
9
+ FileUtils.touch("newfile.rb")
10
+ repo.add("newfile.rb")
11
+ repo.commit_all("Premature commit")
12
+ end
13
+
14
+ solution do
15
+ return false unless File.exists?("newfile.rb") && repo.status.files.keys.include?("newfile.rb")
16
+ return false if repo.status.files["newfile.rb"].untracked || repo.commit_count > 1
17
+ true
18
+ end
19
+
20
+ hint do
21
+ puts "What are some options you can use with `git reset`?"
22
+ end
data/levels/restore.rb ADDED
@@ -0,0 +1,28 @@
1
+ difficulty 4
2
+ description "You decided to delete your latest commit by running `git reset --hard HEAD^`. (Not a smart thing to do.) You then change your mind, and want that commit back. Restore the deleted commit."
3
+
4
+ setup do
5
+ repo.init
6
+ FileUtils.touch 'file1'
7
+ repo.add 'file1'
8
+ repo.commit_all 'Initial commit'
9
+
10
+ FileUtils.touch 'file2'
11
+ repo.add 'file2'
12
+ repo.commit_all 'First commit'
13
+
14
+ FileUtils.touch 'file3'
15
+ repo.add 'file3'
16
+ repo.commit_all 'Restore this commit'
17
+
18
+ repo.git.native :reset, { "hard" => true }, 'HEAD^'
19
+ end
20
+
21
+ solution do
22
+ return false unless File.exists?('file3')
23
+ true
24
+ end
25
+
26
+ hint do
27
+ puts "The commit is still floating around somewhere. Have you checked out `git reflog`?"
28
+ end
@@ -0,0 +1,40 @@
1
+ difficulty 3
2
+
3
+ description "You added some files to your repository, but now realize that your project needs to be restructured. Make a new folder named `src` and using Git move all of the .html files into this folder."
4
+
5
+ setup do
6
+ repo.init
7
+
8
+ FileUtils.touch("about.html")
9
+ FileUtils.touch("contact.html")
10
+ FileUtils.touch("index.html")
11
+
12
+ repo.add("about.html")
13
+ repo.add("contact.html")
14
+ repo.add("index.html")
15
+
16
+ repo.commit_all("adding web content.")
17
+ end
18
+
19
+ solution do
20
+ index =
21
+ repo.status["index.html"].type == "D" &&
22
+ repo.status["index.html"].stage.nil? &&
23
+ repo.status["src/index.html"].type == "A"
24
+
25
+ about =
26
+ repo.status["about.html"].type == "D" &&
27
+ repo.status["about.html"].stage.nil? &&
28
+ repo.status["src/about.html"].type == "A"
29
+
30
+ contact =
31
+ repo.status["contact.html"].type == "D" &&
32
+ repo.status["contact.html"].stage.nil? &&
33
+ repo.status["src/contact.html"].type == "A"
34
+
35
+ index && about && contact
36
+ end
37
+
38
+ hint do
39
+ puts "You'll have to use mkdir, and `git mv`."
40
+ end
data/levels/revert.rb ADDED
@@ -0,0 +1,30 @@
1
+ difficulty 4
2
+ description "你已经在本地做了几次提交,而且所有提交都Push到了远程代码库。现在你发现有一次提交(Bad commit)包含了Bug, 你需要把它回滚掉。"
3
+
4
+ setup do
5
+ repo.init
6
+
7
+ FileUtils.touch "file1"
8
+ repo.add "file1"
9
+ repo.commit_all "First commit"
10
+
11
+ FileUtils.touch "file3"
12
+ repo.add "file3"
13
+ repo.commit_all "Bad commit"
14
+
15
+ FileUtils.touch "file2"
16
+ repo.add "file2"
17
+ repo.commit_all "Second commit"
18
+ end
19
+
20
+ solution do
21
+ valid = false
22
+ commit_messages = repo.commits.map(&:message)
23
+ valid = true if repo.commits.length > 3 &&
24
+ commit_messages.any? { |e| e =~ /(Revert )?"Bad commit"/ }
25
+ valid
26
+ end
27
+
28
+ hint do
29
+ puts "Try the revert command."
30
+ end