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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/Gemfile +4 -0
- data/LICENCE.txt +22 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/bin/mygithug +4 -0
- data/levels/add.rb +30 -0
- data/levels/alias_lg.rb +55 -0
- data/levels/alias_st.rb +22 -0
- data/levels/bisect/.githug/COMMIT_EDITMSG +1 -0
- data/levels/bisect/.githug/HEAD +1 -0
- data/levels/bisect/.githug/ORIG_HEAD +1 -0
- data/levels/bisect/.githug/config +7 -0
- data/levels/bisect/.githug/description +1 -0
- data/levels/bisect/.githug/gitk.cache +3 -0
- data/levels/bisect/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/bisect/.githug/hooks/commit-msg.sample +24 -0
- data/levels/bisect/.githug/hooks/post-commit.sample +8 -0
- data/levels/bisect/.githug/hooks/post-receive.sample +15 -0
- data/levels/bisect/.githug/hooks/post-update.sample +8 -0
- data/levels/bisect/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/bisect/.githug/hooks/pre-commit.sample +46 -0
- data/levels/bisect/.githug/hooks/pre-rebase.sample +172 -0
- data/levels/bisect/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/bisect/.githug/hooks/update.sample +128 -0
- data/levels/bisect/.githug/index +0 -0
- data/levels/bisect/.githug/info/exclude +6 -0
- data/levels/bisect/.githug/info/refs +9 -0
- data/levels/bisect/.githug/logs/HEAD +21 -0
- data/levels/bisect/.githug/logs/refs/heads/master +21 -0
- data/levels/bisect/.githug/objects/info/packs +2 -0
- data/levels/bisect/.githug/objects/pack/pack-59fab357f3158a9640633de6a3326ed79a2b4fe6.idx +0 -0
- data/levels/bisect/.githug/objects/pack/pack-59fab357f3158a9640633de6a3326ed79a2b4fe6.pack +0 -0
- data/levels/bisect/.githug/packed-refs +10 -0
- data/levels/bisect/makefile +2 -0
- data/levels/bisect/prog.rb +3 -0
- data/levels/bisect/test.rb +4 -0
- data/levels/bisect.rb +15 -0
- data/levels/blame/.githug/COMMIT_EDITMSG +1 -0
- data/levels/blame/.githug/HEAD +1 -0
- data/levels/blame/.githug/config +5 -0
- data/levels/blame/.githug/description +1 -0
- data/levels/blame/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/blame/.githug/hooks/commit-msg.sample +24 -0
- data/levels/blame/.githug/hooks/post-commit.sample +8 -0
- data/levels/blame/.githug/hooks/post-receive.sample +15 -0
- data/levels/blame/.githug/hooks/post-update.sample +8 -0
- data/levels/blame/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/blame/.githug/hooks/pre-commit.sample +46 -0
- data/levels/blame/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/blame/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/blame/.githug/hooks/update.sample +128 -0
- data/levels/blame/.githug/index +0 -0
- data/levels/blame/.githug/info/exclude +6 -0
- data/levels/blame/.githug/logs/HEAD +5 -0
- data/levels/blame/.githug/logs/refs/heads/master +5 -0
- data/levels/blame/.githug/objects/00/d6bf5341b263ccaf32e7973be55126eb30a343 +0 -0
- data/levels/blame/.githug/objects/05/07c26fed4d111a8344763be9af68af90f0ecf2 +0 -0
- data/levels/blame/.githug/objects/09/4094808dc6dc336c93c8602190a9e5f7bd6a11 +2 -0
- data/levels/blame/.githug/objects/21/15d78864000292628872941b14521f90187eed +0 -0
- data/levels/blame/.githug/objects/31/11dda1f5b08d50ac44b99acabfa54f1e6e72b0 +2 -0
- data/levels/blame/.githug/objects/50/8db115ba34a0e4e8667653aebe0265bb4f7e80 +0 -0
- data/levels/blame/.githug/objects/5e/8863df752e3b7f2150df7c78f12bef6f1ff00e +0 -0
- data/levels/blame/.githug/objects/67/788a4b90180c7588d7bd0ad8032957b0f429ba +0 -0
- data/levels/blame/.githug/objects/70/d00535a3a25b0ac1736dd3d306d6271e5427ed +0 -0
- data/levels/blame/.githug/objects/97/bdd0cccf9f4b8730f78cb53a81a74f205dbcc2 +1 -0
- data/levels/blame/.githug/objects/ab/08819ba3ffaeba17d4f870dc3a458a904519f4 +0 -0
- data/levels/blame/.githug/objects/be/96fe46de646f6a5c728f90cc884aef96fa1d6f +0 -0
- data/levels/blame/.githug/objects/cd/9c6b9ab1a6f56cccc69b6aa661f1d67ba5fb46 +0 -0
- data/levels/blame/.githug/objects/dd/df1d8ebd60eec169c15a5b23cb49a58d2ed5a0 +4 -0
- data/levels/blame/.githug/objects/ff/d39c2dbfd94bdbca06d48686e0cbda642f3de7 +1 -0
- data/levels/blame/.githug/refs/heads/master +1 -0
- data/levels/blame/config.rb +16 -0
- data/levels/blame.rb +15 -0
- data/levels/branch.rb +18 -0
- data/levels/branch_at.rb +25 -0
- data/levels/checkout.rb +18 -0
- data/levels/checkout_file.rb +25 -0
- data/levels/checkout_tag.rb +39 -0
- data/levels/checkout_tag_over_branch.rb +46 -0
- data/levels/cherry-pick/.githug/COMMIT_EDITMSG +1 -0
- data/levels/cherry-pick/.githug/HEAD +1 -0
- data/levels/cherry-pick/.githug/config +6 -0
- data/levels/cherry-pick/.githug/description +1 -0
- data/levels/cherry-pick/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/cherry-pick/.githug/hooks/commit-msg.sample +24 -0
- data/levels/cherry-pick/.githug/hooks/post-update.sample +8 -0
- data/levels/cherry-pick/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/cherry-pick/.githug/hooks/pre-commit.sample +50 -0
- data/levels/cherry-pick/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/cherry-pick/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/cherry-pick/.githug/hooks/update.sample +128 -0
- data/levels/cherry-pick/.githug/index +0 -0
- data/levels/cherry-pick/.githug/info/exclude +6 -0
- data/levels/cherry-pick/.githug/logs/HEAD +14 -0
- data/levels/cherry-pick/.githug/logs/refs/heads/master +4 -0
- data/levels/cherry-pick/.githug/logs/refs/heads/new-feature +6 -0
- data/levels/cherry-pick/.githug/objects/05/aa97588aff673dcf00e0e1b835d6ec6207a7d9 +0 -0
- data/levels/cherry-pick/.githug/objects/14/ad8f1413c40e0e5be6f6cbdec392a783c1d754 +0 -0
- data/levels/cherry-pick/.githug/objects/1b/912962174dd58fbbf1627ec816fa6672c70854 +0 -0
- data/levels/cherry-pick/.githug/objects/22/f99f3abfd02190a760388c8845c190247859fe +0 -0
- data/levels/cherry-pick/.githug/objects/23/2d266a78d5ef7196f1ede14972ccf7ee19e587 +0 -0
- data/levels/cherry-pick/.githug/objects/31/68bdc3ae7e0ab987dda238beab9c0582c7fc07 +0 -0
- data/levels/cherry-pick/.githug/objects/49/4fa3fc1c15986f9a950aba8607da591223614c +0 -0
- data/levels/cherry-pick/.githug/objects/4a/1961bce62840eaef9c4392fe5cc799e38c9b7b +0 -0
- data/levels/cherry-pick/.githug/objects/54/22c2405527c05c23b243b2535a97b6cefa1427 +0 -0
- data/levels/cherry-pick/.githug/objects/54/f3308533fd4400c94c4cd5827cd38036a67a76 +0 -0
- data/levels/cherry-pick/.githug/objects/58/a8c8edcfdd00c6d8cce9aada8f987a1677571f +0 -0
- data/levels/cherry-pick/.githug/objects/6e/dea632d9540e060bca97dda0897df2b7da0ec0 +2 -0
- data/levels/cherry-pick/.githug/objects/85/4e7ac38b3e8df02ea1480ec45aa9e7865f03d7 +0 -0
- data/levels/cherry-pick/.githug/objects/93/3a97260a11a5ee49bb8a4b7b097cb2fb38f85c +0 -0
- data/levels/cherry-pick/.githug/objects/9a/e59e88e6af362c069847e621b971bafff158ac +0 -0
- data/levels/cherry-pick/.githug/objects/a2/14badc644facc4722083aedf91d9339ffdffbf +0 -0
- data/levels/cherry-pick/.githug/objects/b3/0c6a965415df6aef5f2903f9892fa5481152fc +0 -0
- data/levels/cherry-pick/.githug/objects/c6/0c612734f25b9c989d954621491e9ca3c9e061 +0 -0
- data/levels/cherry-pick/.githug/objects/ca/32a6dac7b6f97975edbe19a4296c2ee7682f68 +0 -0
- data/levels/cherry-pick/.githug/objects/cf/d8ce38c22c5fe83cc04e23f94646464f20d990 +0 -0
- data/levels/cherry-pick/.githug/objects/d5/02e68bfe397140e4ac2a819b138545abca604e +0 -0
- data/levels/cherry-pick/.githug/objects/d5/123e58b37fd886dff2b96bfe5ec08a498192aa +0 -0
- data/levels/cherry-pick/.githug/objects/ea/2a47c19b85fc321e2737ddc49db3deeba3a1b5 +0 -0
- data/levels/cherry-pick/.githug/objects/ea/3dbcc5e2d2359698c3606b0ec44af9f76def54 +0 -0
- data/levels/cherry-pick/.githug/refs/heads/master +1 -0
- data/levels/cherry-pick/.githug/refs/heads/new-feature +1 -0
- data/levels/cherry-pick/README.md +2 -0
- data/levels/cherry-pick/hardcore-math.js +3 -0
- data/levels/cherry-pick/nokia.js +1 -0
- data/levels/cherry-pick.rb +19 -0
- data/levels/clone.rb +10 -0
- data/levels/clone_to_folder.rb +10 -0
- data/levels/commit.rb +17 -0
- data/levels/commit_amend.rb +23 -0
- data/levels/commit_in_future.rb +19 -0
- data/levels/config.rb +33 -0
- data/levels/conflict/.githug/COMMIT_EDITMSG +14 -0
- data/levels/conflict/.githug/HEAD +1 -0
- data/levels/conflict/.githug/config +5 -0
- data/levels/conflict/.githug/description +1 -0
- data/levels/conflict/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/conflict/.githug/hooks/commit-msg.sample +24 -0
- data/levels/conflict/.githug/hooks/post-update.sample +8 -0
- data/levels/conflict/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/conflict/.githug/hooks/pre-commit.sample +50 -0
- data/levels/conflict/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/conflict/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/conflict/.githug/hooks/update.sample +128 -0
- data/levels/conflict/.githug/index +0 -0
- data/levels/conflict/.githug/info/exclude +6 -0
- data/levels/conflict/.githug/logs/HEAD +12 -0
- data/levels/conflict/.githug/logs/refs/heads/master +4 -0
- data/levels/conflict/.githug/logs/refs/heads/mybranch +5 -0
- data/levels/conflict/.githug/objects/1d/b9aa5013e47f1482ec90323d926171a99c28af +0 -0
- data/levels/conflict/.githug/objects/25/b3f9c339430b35ae5822b2ef90e763284dc007 +0 -0
- data/levels/conflict/.githug/objects/2d/0d90051e320215f54f357e746c9838490557e7 +1 -0
- data/levels/conflict/.githug/objects/30/6868e3258be1f35ae43db71e3a6d7edf42ffe7 +0 -0
- data/levels/conflict/.githug/objects/30/cc28e66966109bb5bfbe96d6c817c367d2050a +0 -0
- data/levels/conflict/.githug/objects/38/21e4362c5a76db1112b46b9210670cd5bab482 +0 -0
- data/levels/conflict/.githug/objects/3c/b65bef44ae724ddf9e89640e7e2754dea1a47f +0 -0
- data/levels/conflict/.githug/objects/3d/7aec017559be2b61cab850dafdcb2b6212f1c3 +1 -0
- data/levels/conflict/.githug/objects/40/e20a455ac2731ad25c297b03aa543d7eedf6ab +0 -0
- data/levels/conflict/.githug/objects/44/30fd3f45c832e685350417600a9862c94d20f1 +0 -0
- data/levels/conflict/.githug/objects/46/677964e679f3e727356d0860c643a12a87902b +0 -0
- data/levels/conflict/.githug/objects/50/a127cb066eb903a6fa59d71802c10cb442fb3b +0 -0
- data/levels/conflict/.githug/objects/55/ad5af2a93afa778971e3d04faf20f6c368b6ba +0 -0
- data/levels/conflict/.githug/objects/6b/0c0b32bdca3af9beb831744cb755d6fdc7c7c0 +2 -0
- data/levels/conflict/.githug/objects/75/179304f4fab00613f08a9412b6cb0965bfa564 +2 -0
- data/levels/conflict/.githug/objects/7c/36daf29660ae4a2f09345427ef76f1d38f902f +0 -0
- data/levels/conflict/.githug/objects/88/e0473c9da347c6311f5f8eca8d256bf25402b6 +2 -0
- data/levels/conflict/.githug/objects/bd/c7bec8acae9b3eabf0a15b223a48211b7a89a1 +2 -0
- data/levels/conflict/.githug/objects/c7/97f979cf24ba148bf10d5e26f5d7402dd5f2e1 +0 -0
- data/levels/conflict/.githug/objects/da/ae380200ed6eeaafd926177018e8ff3009b988 +0 -0
- data/levels/conflict/.githug/refs/heads/master +1 -0
- data/levels/conflict/.githug/refs/heads/mybranch +1 -0
- data/levels/conflict/poem.txt +5 -0
- data/levels/conflict.rb +23 -0
- data/levels/congratulation.rb +10 -0
- data/levels/contribute.rb +25 -0
- data/levels/delete_branch/.githug/COMMIT_EDITMSG +1 -0
- data/levels/delete_branch/.githug/HEAD +1 -0
- data/levels/delete_branch/.githug/config +7 -0
- data/levels/delete_branch/.githug/description +1 -0
- data/levels/delete_branch/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/delete_branch/.githug/hooks/commit-msg.sample +24 -0
- data/levels/delete_branch/.githug/hooks/post-update.sample +8 -0
- data/levels/delete_branch/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/delete_branch/.githug/hooks/pre-commit.sample +49 -0
- data/levels/delete_branch/.githug/hooks/pre-push.sample +53 -0
- data/levels/delete_branch/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/delete_branch/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/delete_branch/.githug/hooks/update.sample +128 -0
- data/levels/delete_branch/.githug/index +0 -0
- data/levels/delete_branch/.githug/info/exclude +6 -0
- data/levels/delete_branch/.githug/logs/HEAD +4 -0
- data/levels/delete_branch/.githug/logs/refs/heads/delete_me +1 -0
- data/levels/delete_branch/.githug/logs/refs/heads/master +1 -0
- data/levels/delete_branch/.githug/objects/b6/0afe294eb3c200d646995c9e0234470157c1b0 +2 -0
- data/levels/delete_branch/.githug/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/levels/delete_branch/.githug/objects/e8/0ad49ace82167de62e498622d70377d913c79e +0 -0
- data/levels/delete_branch/.githug/refs/heads/delete_me +1 -0
- data/levels/delete_branch/.githug/refs/heads/master +1 -0
- data/levels/delete_branch/readme +0 -0
- data/levels/delete_branch.rb +15 -0
- data/levels/diff/.githug/COMMIT_EDITMSG +1 -0
- data/levels/diff/.githug/HEAD +1 -0
- data/levels/diff/.githug/config +5 -0
- data/levels/diff/.githug/description +1 -0
- data/levels/diff/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/diff/.githug/hooks/commit-msg.sample +24 -0
- data/levels/diff/.githug/hooks/post-commit.sample +8 -0
- data/levels/diff/.githug/hooks/post-receive.sample +15 -0
- data/levels/diff/.githug/hooks/post-update.sample +8 -0
- data/levels/diff/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/diff/.githug/hooks/pre-commit.sample +46 -0
- data/levels/diff/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/diff/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/diff/.githug/hooks/update.sample +128 -0
- data/levels/diff/.githug/index +0 -0
- data/levels/diff/.githug/info/exclude +6 -0
- data/levels/diff/.githug/logs/HEAD +1 -0
- data/levels/diff/.githug/logs/refs/heads/master +1 -0
- data/levels/diff/.githug/objects/1b/6582364621c92707b587409cedbc4f77fc0cee +0 -0
- data/levels/diff/.githug/objects/4f/703ca9bd25781b6758eeb3c42ed5348610ba6d +2 -0
- data/levels/diff/.githug/objects/dc/aa55e97af34402e84d5336da37abcccc23cba6 +3 -0
- data/levels/diff/.githug/refs/heads/master +1 -0
- data/levels/diff/app.rb +42 -0
- data/levels/diff.rb +16 -0
- data/levels/fetch.rb +71 -0
- data/levels/find_old_branch/.githug/COMMIT_EDITMSG +1 -0
- data/levels/find_old_branch/.githug/HEAD +1 -0
- data/levels/find_old_branch/.githug/ORIG_HEAD +1 -0
- data/levels/find_old_branch/.githug/config +6 -0
- data/levels/find_old_branch/.githug/description +1 -0
- data/levels/find_old_branch/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/find_old_branch/.githug/hooks/commit-msg.sample +24 -0
- data/levels/find_old_branch/.githug/hooks/post-commit.sample +8 -0
- data/levels/find_old_branch/.githug/hooks/post-receive.sample +15 -0
- data/levels/find_old_branch/.githug/hooks/post-update.sample +8 -0
- data/levels/find_old_branch/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/find_old_branch/.githug/hooks/pre-commit.sample +50 -0
- data/levels/find_old_branch/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/find_old_branch/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/find_old_branch/.githug/hooks/update.sample +128 -0
- data/levels/find_old_branch/.githug/index +0 -0
- data/levels/find_old_branch/.githug/info/exclude +7 -0
- data/levels/find_old_branch/.githug/logs/HEAD +7 -0
- data/levels/find_old_branch/.githug/logs/refs/heads/blowup_sun_for_ransom +1 -0
- data/levels/find_old_branch/.githug/logs/refs/heads/cure_common_cold +2 -0
- data/levels/find_old_branch/.githug/logs/refs/heads/kill_the_batman +4 -0
- data/levels/find_old_branch/.githug/logs/refs/heads/solve_world_hunger +2 -0
- data/levels/find_old_branch/.githug/objects/05/e9c01bd3c9264761dd0cde477400a2c3104642 +0 -0
- data/levels/find_old_branch/.githug/objects/1f/0a136ddd98f61934d15eb00444df32d8e8254b +0 -0
- data/levels/find_old_branch/.githug/objects/32/4336a8401afc8ca384eaafe6615c84d552dd2c +0 -0
- data/levels/find_old_branch/.githug/objects/50/72aab6bd73accec89ad3aa077f43aab8a5e507 +0 -0
- data/levels/find_old_branch/.githug/objects/5d/130caf89f1a4bba6a1fffe72c484f3ab659e08 +0 -0
- data/levels/find_old_branch/.githug/objects/68/76e5b41fb693190df76b1baef6ef98623b4f1a +0 -0
- data/levels/find_old_branch/.githug/objects/6a/7702145d1eb91c9f79583eabb984027b12e60c +0 -0
- data/levels/find_old_branch/.githug/objects/89/4a16d6f1a48224e9006b4a6f0fe3846da19bec +0 -0
- data/levels/find_old_branch/.githug/objects/b8/c67b45e5fe9e4b39ac7ade725673f7c90bdfc3 +0 -0
- data/levels/find_old_branch/.githug/objects/bf/76434bc7e7346c6fef5a98aee0f7cfc0788f34 +0 -0
- data/levels/find_old_branch/.githug/refs/heads/blowup_sun_for_ransom +1 -0
- data/levels/find_old_branch/.githug/refs/heads/cure_common_cold +1 -0
- data/levels/find_old_branch/.githug/refs/heads/kill_the_batman +1 -0
- data/levels/find_old_branch/.githug/refs/heads/solve_world_hunger +1 -0
- data/levels/find_old_branch/TODO +1 -0
- data/levels/find_old_branch/myfile.txt +1 -0
- data/levels/find_old_branch.rb +15 -0
- data/levels/grep/.githug/COMMIT_EDITMSG +1 -0
- data/levels/grep/.githug/HEAD +1 -0
- data/levels/grep/.githug/config +6 -0
- data/levels/grep/.githug/description +1 -0
- data/levels/grep/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/grep/.githug/hooks/commit-msg.sample +24 -0
- data/levels/grep/.githug/hooks/post-commit.sample +8 -0
- data/levels/grep/.githug/hooks/post-receive.sample +15 -0
- data/levels/grep/.githug/hooks/post-update.sample +8 -0
- data/levels/grep/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/grep/.githug/hooks/pre-commit.sample +46 -0
- data/levels/grep/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/grep/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/grep/.githug/hooks/update.sample +128 -0
- data/levels/grep/.githug/index +0 -0
- data/levels/grep/.githug/info/exclude +6 -0
- data/levels/grep/.githug/logs/HEAD +1 -0
- data/levels/grep/.githug/logs/refs/heads/master +1 -0
- data/levels/grep/.githug/objects/12/c702f8b25b6b528cf904670b854dba3eba0f45 +3 -0
- data/levels/grep/.githug/objects/6f/45753f4a16b69f5b2215f2dbe8245f073353cc +1 -0
- data/levels/grep/.githug/objects/a4/1fe0c342be5c9930328cbb4315acebbd9c94b2 +0 -0
- data/levels/grep/.githug/objects/d3/f53e82aa015d1eea3b06c3b62dfbacee83bbe1 +0 -0
- data/levels/grep/.githug/refs/heads/master +1 -0
- data/levels/grep/app.rb +45 -0
- data/levels/grep/config.rb +17 -0
- data/levels/grep.rb +14 -0
- data/levels/ignore.rb +42 -0
- data/levels/include.rb +21 -0
- data/levels/init.rb +10 -0
- data/levels/log.rb +22 -0
- data/levels/merge/.githug/COMMIT_EDITMSG +1 -0
- data/levels/merge/.githug/HEAD +1 -0
- data/levels/merge/.githug/config +6 -0
- data/levels/merge/.githug/description +1 -0
- data/levels/merge/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/merge/.githug/hooks/commit-msg.sample +24 -0
- data/levels/merge/.githug/hooks/post-commit.sample +8 -0
- data/levels/merge/.githug/hooks/post-receive.sample +15 -0
- data/levels/merge/.githug/hooks/post-update.sample +8 -0
- data/levels/merge/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/merge/.githug/hooks/pre-commit.sample +46 -0
- data/levels/merge/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/merge/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/merge/.githug/hooks/update.sample +128 -0
- data/levels/merge/.githug/index +0 -0
- data/levels/merge/.githug/info/exclude +6 -0
- data/levels/merge/.githug/logs/HEAD +4 -0
- data/levels/merge/.githug/logs/refs/heads/feature +2 -0
- data/levels/merge/.githug/logs/refs/heads/master +1 -0
- data/levels/merge/.githug/objects/ad/24149d789e59d4b5f9ce41cda90110ca0f98b7 +0 -0
- data/levels/merge/.githug/objects/ae/fde3a01f6e10d72fd4899ce14c8b2654d3eb45 +0 -0
- data/levels/merge/.githug/objects/cc/8ea5a233df119d025eb240b9470e1ca76a151c +0 -0
- data/levels/merge/.githug/objects/e1/2277fe88657a072f1c4eb7d9320e4e6a74ba95 +0 -0
- data/levels/merge/.githug/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/levels/merge/.githug/refs/heads/feature +1 -0
- data/levels/merge/.githug/refs/heads/master +1 -0
- data/levels/merge/file1 +0 -0
- data/levels/merge.rb +16 -0
- data/levels/merge_squash.rb +49 -0
- data/levels/number_of_files_committed.rb +51 -0
- data/levels/pull.rb +16 -0
- data/levels/pull_rebase.rb +49 -0
- data/levels/push.rb +67 -0
- data/levels/push_branch.rb +88 -0
- data/levels/push_tags.rb +63 -0
- data/levels/rebase/.githug/COMMIT_EDITMSG +1 -0
- data/levels/rebase/.githug/HEAD +1 -0
- data/levels/rebase/.githug/ORIG_HEAD +1 -0
- data/levels/rebase/.githug/config +7 -0
- data/levels/rebase/.githug/index +0 -0
- data/levels/rebase/.githug/logs/HEAD +13 -0
- data/levels/rebase/.githug/logs/refs/heads/feature +4 -0
- data/levels/rebase/.githug/logs/refs/heads/master +2 -0
- data/levels/rebase/.githug/objects/0c/d212c5b28da2e65ed4900712dd36c8adce48ad +0 -0
- data/levels/rebase/.githug/objects/44/19b972c0cd1b346ac90332aa7c5cc949589f78 +0 -0
- data/levels/rebase/.githug/objects/54/3b9bebdc6bd5c4b22136034a95dd097a57d3dd +0 -0
- data/levels/rebase/.githug/objects/81/78c76d627cade75005b40711b92f4177bc6cfc +0 -0
- data/levels/rebase/.githug/objects/98/205e9faf10cf33d2ef7c0f66e402540c62613a +2 -0
- data/levels/rebase/.githug/objects/a7/8bcab6232e9382a86436cdfcb2ed0391b1f0ac +4 -0
- data/levels/rebase/.githug/objects/b7/7313d7be366609dd2e77aa96d7fd73f4e27853 +0 -0
- data/levels/rebase/.githug/objects/b9/2d5d55d379cfb90b750e6472fc983f32ad9a71 +0 -0
- data/levels/rebase/.githug/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/levels/rebase/.githug/objects/ed/0fdcf366b21b8984fb37ea34106978a2e5c5ba +0 -0
- data/levels/rebase/.githug/refs/heads/feature +1 -0
- data/levels/rebase/.githug/refs/heads/master +1 -0
- data/levels/rebase/README +1 -0
- data/levels/rebase.rb +16 -0
- data/levels/rebase_conflict.rb +55 -0
- data/levels/rebase_onto.rb +45 -0
- data/levels/remote.rb +16 -0
- data/levels/remote_add.rb +16 -0
- data/levels/remote_url.rb +17 -0
- data/levels/rename.rb +18 -0
- data/levels/rename_commit.rb +25 -0
- data/levels/reorder.rb +30 -0
- data/levels/repack.rb +19 -0
- data/levels/reset.rb +22 -0
- data/levels/reset_soft.rb +22 -0
- data/levels/restore.rb +28 -0
- data/levels/restructure.rb +40 -0
- data/levels/revert.rb +30 -0
- data/levels/rm.rb +20 -0
- data/levels/rm_cached.rb +18 -0
- data/levels/squash.rb +29 -0
- data/levels/stage_lines.rb +29 -0
- data/levels/stash/.githug/COMMIT_EDITMSG +1 -0
- data/levels/stash/.githug/HEAD +1 -0
- data/levels/stash/.githug/config +7 -0
- data/levels/stash/.githug/description +1 -0
- data/levels/stash/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/stash/.githug/hooks/commit-msg.sample +24 -0
- data/levels/stash/.githug/hooks/post-update.sample +8 -0
- data/levels/stash/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/stash/.githug/hooks/pre-commit.sample +50 -0
- data/levels/stash/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/stash/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/stash/.githug/hooks/update.sample +128 -0
- data/levels/stash/.githug/index +0 -0
- data/levels/stash/.githug/info/exclude +6 -0
- data/levels/stash/.githug/logs/HEAD +1 -0
- data/levels/stash/.githug/logs/refs/heads/master +1 -0
- data/levels/stash/.githug/objects/02/060592b31c9e12ffe1b282addf9537c5ef8e1f +0 -0
- data/levels/stash/.githug/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/levels/stash/.githug/objects/7f/82d7e4fba66980af16da540e18d8955518cdc2 +0 -0
- data/levels/stash/.githug/objects/85/e560abcd7e3255dcd91982476e432f4d3d1b51 +0 -0
- data/levels/stash/.githug/refs/heads/master +1 -0
- data/levels/stash/lyrics.txt +13 -0
- data/levels/stash.rb +17 -0
- data/levels/status.rb +26 -0
- data/levels/submodule.rb +20 -0
- data/levels/tag.rb +18 -0
- data/levels/unstash/.githug/COMMIT_EDITMSG +1 -0
- data/levels/unstash/.githug/HEAD +1 -0
- data/levels/unstash/.githug/config +7 -0
- data/levels/unstash/.githug/description +1 -0
- data/levels/unstash/.githug/hooks/applypatch-msg.sample +15 -0
- data/levels/unstash/.githug/hooks/commit-msg.sample +24 -0
- data/levels/unstash/.githug/hooks/post-update.sample +8 -0
- data/levels/unstash/.githug/hooks/pre-applypatch.sample +14 -0
- data/levels/unstash/.githug/hooks/pre-commit.sample +50 -0
- data/levels/unstash/.githug/hooks/pre-rebase.sample +169 -0
- data/levels/unstash/.githug/hooks/prepare-commit-msg.sample +36 -0
- data/levels/unstash/.githug/hooks/update.sample +128 -0
- data/levels/unstash/.githug/index +0 -0
- data/levels/unstash/.githug/info/exclude +6 -0
- data/levels/unstash/.githug/logs/HEAD +1 -0
- data/levels/unstash/.githug/logs/refs/heads/master +1 -0
- data/levels/unstash/.githug/objects/02/060592b31c9e12ffe1b282addf9537c5ef8e1f +0 -0
- data/levels/unstash/.githug/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/levels/unstash/.githug/objects/7f/82d7e4fba66980af16da540e18d8955518cdc2 +0 -0
- data/levels/unstash/.githug/objects/85/e560abcd7e3255dcd91982476e432f4d3d1b51 +0 -0
- data/levels/unstash/.githug/refs/heads/master +1 -0
- data/levels/unstash/lyrics.txt +13 -0
- data/levels/unstash.rb +22 -0
- data/lib/githug/cli.rb +121 -0
- data/lib/githug/extensions/grit/ruby1.9.rb +21 -0
- data/lib/githug/game.rb +57 -0
- data/lib/githug/level.rb +135 -0
- data/lib/githug/profile.rb +80 -0
- data/lib/githug/repository.rb +48 -0
- data/lib/githug/ui.rb +59 -0
- data/lib/githug/version.rb +3 -0
- data/lib/githug.rb +16 -0
- data/mygithug.gemspec +27 -0
- data/spec/githug/cli_spec.rb +133 -0
- data/spec/githug/game_spec.rb +96 -0
- data/spec/githug/level_spec.rb +159 -0
- data/spec/githug/profile_spec.rb +89 -0
- data/spec/githug/repository_spec.rb +97 -0
- data/spec/githug/ui_spec.rb +112 -0
- data/spec/githug_spec.rb +316 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/files/test_level.rb +16 -0
- metadata +549 -0
data/lib/githug/cli.rb
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
require 'githug'
|
|
3
|
+
module Githug
|
|
4
|
+
class CLI < Thor
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
default_task :play
|
|
8
|
+
|
|
9
|
+
desc :play, "Initialize the game"
|
|
10
|
+
|
|
11
|
+
def play
|
|
12
|
+
UI.word_box("Githug")
|
|
13
|
+
make_directory!
|
|
14
|
+
Game.new.play_level
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc :test, "Test a level from a file path"
|
|
18
|
+
method_option :errors, :type => :boolean, :default => false
|
|
19
|
+
|
|
20
|
+
def test(path)
|
|
21
|
+
UI.word_box("Githug")
|
|
22
|
+
make_directory!
|
|
23
|
+
level = Level.load_from_file(path)
|
|
24
|
+
Game.new.test_level(level, options[:errors])
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc :hint, "Get a hint for the current level"
|
|
28
|
+
|
|
29
|
+
def hint
|
|
30
|
+
if level = load_level
|
|
31
|
+
level.show_hint
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc :reset, "Reset the current level"
|
|
36
|
+
long_desc <<-LONGDESC
|
|
37
|
+
`githug reset` will reset the current level. You can optionally specify a
|
|
38
|
+
LEVEL parameter which will reset the game to a specific level. For
|
|
39
|
+
example:
|
|
40
|
+
|
|
41
|
+
> $ githug reset merge_squash # or $ githug reset 47
|
|
42
|
+
|
|
43
|
+
Will reset githug to level '#47: merge_squash'
|
|
44
|
+
LONGDESC
|
|
45
|
+
def reset(path = nil)
|
|
46
|
+
level = load_level(path)
|
|
47
|
+
UI.word_box("Githug")
|
|
48
|
+
if level
|
|
49
|
+
UI.puts("resetting level")
|
|
50
|
+
level.setup_level
|
|
51
|
+
level.full_description
|
|
52
|
+
else
|
|
53
|
+
UI.error("Level does not exist")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
desc :levels, "List all of the levels"
|
|
58
|
+
|
|
59
|
+
def levels
|
|
60
|
+
list_with_numbers = Level.list.each_with_index.map do |name, index|
|
|
61
|
+
"##{index + 1}: #{name}"
|
|
62
|
+
end
|
|
63
|
+
UI.puts(list_with_numbers)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
no_tasks do
|
|
67
|
+
|
|
68
|
+
def load_level(path = nil)
|
|
69
|
+
return load_level_from_profile unless path
|
|
70
|
+
return load_level_from_number(path.to_i) if path.to_i.to_s == path
|
|
71
|
+
return load_level_from_name(path) if Level.list.include?(path)
|
|
72
|
+
Level.load_from_file(path)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def load_level_from_number(number)
|
|
76
|
+
level_name = number >= 1 ? Level.list[number - 1] : nil
|
|
77
|
+
return load_level_from_name(level_name)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def load_level_from_name(name)
|
|
81
|
+
profile = Profile.load
|
|
82
|
+
profile.set_level(name)
|
|
83
|
+
Level.load(name)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def load_level_from_profile
|
|
87
|
+
profile = Profile.load
|
|
88
|
+
Level.load(profile.level)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def make_directory!
|
|
93
|
+
return if File.basename(Dir.pwd) == "git_hug"
|
|
94
|
+
check_githug_directory!
|
|
95
|
+
prompt_githug_directory!
|
|
96
|
+
make_githug_directory!
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def check_githug_directory!
|
|
100
|
+
if File.exists?("./git_hug")
|
|
101
|
+
UI.puts "Please change into the git_hug directory"
|
|
102
|
+
exit
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def prompt_githug_directory!
|
|
107
|
+
unless UI.ask("No githug directory found, do you wish to create one?")
|
|
108
|
+
UI.puts("Exiting")
|
|
109
|
+
exit
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def make_githug_directory!
|
|
114
|
+
Dir.mkdir("./git_hug")
|
|
115
|
+
Dir.chdir("git_hug")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class String
|
|
2
|
+
if self.method_defined?(:ord)
|
|
3
|
+
def getord(offset); self[offset].ord; end
|
|
4
|
+
else
|
|
5
|
+
alias :getord :[]
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
unless self.method_defined?(:b)
|
|
9
|
+
if self.method_defined?(:force_encoding)
|
|
10
|
+
def b; self.dup.force_encoding(Encoding::ASCII_8BIT); end
|
|
11
|
+
else
|
|
12
|
+
def b; self.dup; end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if Object.const_defined?(:PACK_IDX_SIGNATURE)
|
|
18
|
+
Object.send(:remove_const, :PACK_IDX_SIGNATURE)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
PACK_IDX_SIGNATURE = "\377tOc".b
|
data/lib/githug/game.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Githug
|
|
2
|
+
class Game
|
|
3
|
+
|
|
4
|
+
attr_accessor :profile
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@profile = Profile.load
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def play_level
|
|
11
|
+
solve = true
|
|
12
|
+
if profile.level.nil?
|
|
13
|
+
UI.puts("Welcome to Githug!")
|
|
14
|
+
solve = false
|
|
15
|
+
level_bump
|
|
16
|
+
else
|
|
17
|
+
level = Level.load(profile.level)
|
|
18
|
+
if solve && level
|
|
19
|
+
if level.solve
|
|
20
|
+
UI.success "Congratulations, you have solved the level!"
|
|
21
|
+
level_bump
|
|
22
|
+
else
|
|
23
|
+
UI.error "Sorry, this solution is not quite right!"
|
|
24
|
+
profile.current_attempts += 1
|
|
25
|
+
profile.save
|
|
26
|
+
|
|
27
|
+
if (profile.current_attempts > 2 && profile.current_attempts % 3 == 0)
|
|
28
|
+
UI.error "Don't forget you can type `githug hint` for a hint and `githug reset` to reset the current level."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
UI.puts level.full_description
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_level(level, errors = nil)
|
|
38
|
+
UI.puts level.full_description
|
|
39
|
+
method = :solve
|
|
40
|
+
method = :test if errors
|
|
41
|
+
if level.send(method)
|
|
42
|
+
UI.success "Valid solution"
|
|
43
|
+
else
|
|
44
|
+
UI.error "Invalid solution"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def level_bump
|
|
49
|
+
profile.level_bump
|
|
50
|
+
if level = Level.load(profile.level)
|
|
51
|
+
UI.puts(level.full_description)
|
|
52
|
+
level.setup_level
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/githug/level.rb
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
module Githug
|
|
2
|
+
class Level
|
|
3
|
+
include UI
|
|
4
|
+
|
|
5
|
+
# LEVELS = [nil, "init", "config", "alias", "alias2", "add", "commit", "clone",
|
|
6
|
+
# "clone_to_folder", "ignore", "include", "status",
|
|
7
|
+
# "number_of_files_committed", "rm", "rm_cached", "stash", "rename",
|
|
8
|
+
# "restructure", "log", "tag", "push_tags", "commit_amend",
|
|
9
|
+
# "commit_in_future", "reset", "reset_soft", "checkout_file", "remote",
|
|
10
|
+
# "remote_url", "pull", "remote_add", "push", "diff", "blame", "branch",
|
|
11
|
+
# "checkout", "checkout_tag", "checkout_tag_over_branch", "branch_at",
|
|
12
|
+
# "delete_branch", "push_branch", "merge", "fetch", "rebase", "rebase_onto", "repack", "cherry-pick",
|
|
13
|
+
# "grep", "rename_commit", "squash", "merge_squash", "reorder", "bisect",
|
|
14
|
+
# "stage_lines", "find_old_branch", "revert", "restore", "conflict",
|
|
15
|
+
# "submodule","contribute"]
|
|
16
|
+
|
|
17
|
+
LEVELS = [nil, "clone", "alias_st", "alias_lg", "config", "log",
|
|
18
|
+
"add", "commit", "ignore", "stash", "unstash",
|
|
19
|
+
"pull", "pull_rebase", "conflict", "rebase_conflict", "push_branch",
|
|
20
|
+
"fetch", "revert", "merge", "cherry-pick",
|
|
21
|
+
"congratulation"
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
attr_accessor :level_no, :level_path, :level_name
|
|
25
|
+
|
|
26
|
+
class << self
|
|
27
|
+
|
|
28
|
+
def load(level_name)
|
|
29
|
+
path = "#{File.dirname(__FILE__)}/../../levels/#{level_name}.rb"
|
|
30
|
+
setup(path)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def load_from_file(path)
|
|
34
|
+
setup(path)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def list
|
|
38
|
+
return LEVELS - [nil]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def setup(path)
|
|
42
|
+
level_path = path.chomp(File.extname(path))
|
|
43
|
+
level = self.new
|
|
44
|
+
|
|
45
|
+
return false unless File.exists?(path)
|
|
46
|
+
|
|
47
|
+
level.instance_eval(File.read(path))
|
|
48
|
+
level.level_name = File.basename(path, File.extname(path))
|
|
49
|
+
level.level_no = LEVELS.index(level.level_name) || 1
|
|
50
|
+
level.level_path = level_path
|
|
51
|
+
level
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def init_from_level
|
|
57
|
+
FileUtils.cp_r("#{level_path}/.", ".")
|
|
58
|
+
FileUtils.mv(".githug", ".git")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def difficulty(num)
|
|
62
|
+
@difficulty = num
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def description(description)
|
|
66
|
+
@description = description
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def solution(&block)
|
|
70
|
+
singleton = class << self; self end
|
|
71
|
+
singleton.send :define_method, :_solution, &block
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def setup(&block)
|
|
75
|
+
@setup = block
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def hint(&hint)
|
|
79
|
+
@hint = hint
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def hints(hints)
|
|
83
|
+
@hints = hints
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def full_description
|
|
87
|
+
UI.puts
|
|
88
|
+
UI.puts "Name: #{level_name}"
|
|
89
|
+
UI.puts "Level: #{level_no}"
|
|
90
|
+
UI.puts "Difficulty: #{"*"*@difficulty}"
|
|
91
|
+
UI.puts
|
|
92
|
+
UI.puts @description
|
|
93
|
+
UI.puts
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def setup_level
|
|
97
|
+
repo.reset
|
|
98
|
+
@setup.call if @setup
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def repo(location = "")
|
|
102
|
+
@repo ||= Repository.new(location)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def solve
|
|
106
|
+
_solution
|
|
107
|
+
rescue
|
|
108
|
+
false
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test
|
|
112
|
+
_solution
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def show_hint
|
|
116
|
+
UI.word_box("Githug")
|
|
117
|
+
profile = Profile.load
|
|
118
|
+
current_hint_index = profile.current_hint_index
|
|
119
|
+
if @hints
|
|
120
|
+
puts @hints[current_hint_index]
|
|
121
|
+
if current_hint_index < @hints.size - 1
|
|
122
|
+
profile.current_hint_index += 1
|
|
123
|
+
profile.save
|
|
124
|
+
else
|
|
125
|
+
profile.current_hint_index = 0
|
|
126
|
+
profile.save
|
|
127
|
+
end
|
|
128
|
+
elsif @hint
|
|
129
|
+
@hint.call
|
|
130
|
+
else
|
|
131
|
+
UI.puts("No hints available for this level.")
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
module Githug
|
|
3
|
+
class Profile
|
|
4
|
+
PROFILE_FILE = ".profile.yml"
|
|
5
|
+
|
|
6
|
+
attr_accessor :settings
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def load
|
|
10
|
+
self.new(settings)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def settings
|
|
16
|
+
return defaults unless File.exists?(PROFILE_FILE)
|
|
17
|
+
defaults.merge(YAML::load(File.open(PROFILE_FILE)))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def defaults
|
|
21
|
+
{
|
|
22
|
+
:level => nil,
|
|
23
|
+
:current_attempts => 0,
|
|
24
|
+
:current_hint_index => 0,
|
|
25
|
+
:current_levels => [],
|
|
26
|
+
:completed_levels => []
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def method_missing(method, *args, &block)
|
|
34
|
+
if method.to_s.end_with?("=")
|
|
35
|
+
method = method.to_s.chop.to_sym
|
|
36
|
+
return settings[method] = args[0] if settings.include?(method)
|
|
37
|
+
end
|
|
38
|
+
return(settings[method]) if settings.include?(method)
|
|
39
|
+
super
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def initialize(settings)
|
|
43
|
+
@settings = settings
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def save
|
|
47
|
+
File.open(PROFILE_FILE, 'w') do |out|
|
|
48
|
+
YAML.dump(settings, out)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def set_level(name)
|
|
53
|
+
settings[:level] = name
|
|
54
|
+
reset!
|
|
55
|
+
save
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def level_bump
|
|
59
|
+
settings[:completed_levels] << level
|
|
60
|
+
settings[:current_levels] = levels
|
|
61
|
+
set_level(next_level)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def levels
|
|
67
|
+
Level::LEVELS
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def next_level
|
|
71
|
+
(levels - settings[:completed_levels]).first || levels.last
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def reset!
|
|
75
|
+
settings[:current_attempts] = 0
|
|
76
|
+
settings[:current_hint_index] = 0
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Githug
|
|
2
|
+
class Repository
|
|
3
|
+
|
|
4
|
+
attr_accessor :grit
|
|
5
|
+
|
|
6
|
+
def initialize(location = ".")
|
|
7
|
+
@grit = Grit::Repo.new(location)
|
|
8
|
+
rescue Grit::InvalidGitRepositoryError
|
|
9
|
+
@grit = nil
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def reset
|
|
13
|
+
dont_delete = ["..", ".", ".profile.yml"]
|
|
14
|
+
if File.basename(Dir.pwd) == "git_hug"
|
|
15
|
+
Dir.entries(Dir.pwd).each do |file|
|
|
16
|
+
FileUtils.rm_rf(file) unless dont_delete.include?(file)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
create_gitignore
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_gitignore
|
|
23
|
+
Dir.chdir("git_hug") if File.exists?("./git_hug")
|
|
24
|
+
File.open(".gitignore", "w") do |file|
|
|
25
|
+
file.puts(".profile.yml")
|
|
26
|
+
file.puts(".gitignore")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def valid?
|
|
31
|
+
!@grit.nil?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Initialize a Git repo. If the repo already exists, do nothing.
|
|
35
|
+
def init(location = ".")
|
|
36
|
+
@grit = Grit::Repo.init(location)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def method_missing(method, *args, &block)
|
|
40
|
+
if @grit && @grit.respond_to?(method)
|
|
41
|
+
return @grit.send(method, *args, &block)
|
|
42
|
+
end
|
|
43
|
+
super
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/githug/ui.rb
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Githug
|
|
2
|
+
module UI
|
|
3
|
+
|
|
4
|
+
class << self
|
|
5
|
+
|
|
6
|
+
attr_accessor :out_stream, :in_stream
|
|
7
|
+
|
|
8
|
+
@out_stream = STDOUT
|
|
9
|
+
@in_stream = STDIN
|
|
10
|
+
|
|
11
|
+
def puts(string = "")
|
|
12
|
+
out_stream.puts(string)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def print(string)
|
|
16
|
+
out_stream.print(string)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def gets
|
|
20
|
+
in_stream.gets
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def word_box(string,width=80,char='*')
|
|
24
|
+
puts char*width
|
|
25
|
+
puts "#{char}#{string.center(width-2)}#{char}"
|
|
26
|
+
puts char*width
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def request(msg)
|
|
30
|
+
print("#{msg} ")
|
|
31
|
+
gets.chomp
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def ask(msg)
|
|
35
|
+
request("#{msg} [yn] ") == 'y'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def colorize(text, color_code)
|
|
39
|
+
return puts text if ENV['OS'] && ENV['OS'].downcase.include?("windows")
|
|
40
|
+
puts "#{color_code}#{text}\033[0m"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def error(text)
|
|
44
|
+
colorize(text, "\033[31m")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def success(text)
|
|
48
|
+
colorize(text, "\033[32m")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def method_missing(method, *args, &block)
|
|
54
|
+
return UI.send(method, *args) if UI.methods(false).include?(method.to_s) || UI.methods(false).include?(method)
|
|
55
|
+
super
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
data/lib/githug.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'grit'
|
|
2
|
+
|
|
3
|
+
require "githug/extensions/grit/ruby1.9"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require "githug/version"
|
|
7
|
+
|
|
8
|
+
require 'githug/ui'
|
|
9
|
+
require 'githug/game'
|
|
10
|
+
require 'githug/profile'
|
|
11
|
+
require 'githug/level'
|
|
12
|
+
require 'githug/repository'
|
|
13
|
+
|
|
14
|
+
Githug::UI.in_stream = STDIN
|
|
15
|
+
Githug::UI.out_stream = STDOUT
|
|
16
|
+
STDIN.sync = true
|
data/mygithug.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "githug/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "mygithug"
|
|
7
|
+
s.version = Githug::VERSION
|
|
8
|
+
s.authors = ["Gary Rennie & Mei Xuesong"]
|
|
9
|
+
s.email = ["meixuesong@gmail.com"]
|
|
10
|
+
s.homepage = "https://github.com/meixuesong/githug"
|
|
11
|
+
s.summary = %q{An interactive way to learn git in your workplace.}
|
|
12
|
+
s.description = %q{An interactive way to learn git.}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "mygithug"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
# specify any dependencies here; for example:
|
|
22
|
+
s.add_development_dependency "rspec", "~>2.8.0"
|
|
23
|
+
|
|
24
|
+
s.add_dependency "grit", "~>2.3.0"
|
|
25
|
+
s.add_dependency "thor", "~>0.14.6"
|
|
26
|
+
s.add_dependency "rake", "<11"
|
|
27
|
+
end
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'githug/cli'
|
|
3
|
+
|
|
4
|
+
describe Githug::CLI do
|
|
5
|
+
|
|
6
|
+
before(:each) do
|
|
7
|
+
game = mock.as_null_object
|
|
8
|
+
Githug::Game.stub(:new).and_return(game)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "prints the logo" do
|
|
12
|
+
Githug::UI.should_receive(:word_box).with("Githug")
|
|
13
|
+
subject.stub(:make_directory!)
|
|
14
|
+
subject.play
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "creates a directory if one does not exist" do
|
|
18
|
+
Githug::UI.stub(:ask).and_return(true)
|
|
19
|
+
Dir.should_receive(:mkdir).with("./git_hug")
|
|
20
|
+
Dir.should_receive(:chdir).with("git_hug")
|
|
21
|
+
subject.make_directory!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "does not create a directory if you are in the game directory" do
|
|
25
|
+
Dir.stub(:pwd).and_return("/home/git_hug")
|
|
26
|
+
Githug::UI.should_not_receive(:ask)
|
|
27
|
+
subject.make_directory!
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "exits if the user selects no" do
|
|
31
|
+
Githug::UI.stub(:ask).and_return(false)
|
|
32
|
+
lambda {subject.prompt_githug_directory!}.should raise_error(SystemExit)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "prompts to change into the directory if it exists" do
|
|
36
|
+
File.stub(:exists?).and_return(true)
|
|
37
|
+
Githug::UI.should_receive(:puts).with("Please change into the git_hug directory")
|
|
38
|
+
lambda {subject.check_githug_directory!}.should raise_error(SystemExit)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "#test" do
|
|
42
|
+
it "performs a test run of the level" do
|
|
43
|
+
level = mock
|
|
44
|
+
game = mock
|
|
45
|
+
subject.stub(:make_directory!)
|
|
46
|
+
Githug::Level.should_receive(:load_from_file).with("/foo/bar/test/level.rb").and_return(level)
|
|
47
|
+
Githug::Game.stub(:new).and_return(game)
|
|
48
|
+
game.should_receive(:test_level).with(level, anything)
|
|
49
|
+
subject.test("/foo/bar/test/level.rb")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe "level methods" do
|
|
54
|
+
|
|
55
|
+
let(:level) { mock }
|
|
56
|
+
let(:profile) { mock }
|
|
57
|
+
|
|
58
|
+
before(:each) do
|
|
59
|
+
profile.stub(:level).and_return(1)
|
|
60
|
+
Githug::Profile.stub(:load).and_return(profile)
|
|
61
|
+
Githug::Level.stub(:load).and_return(level)
|
|
62
|
+
Githug::Level.stub(:load_from_file).with("/foo/bar/level.rb").and_return(level)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "calls the hint method on the level" do
|
|
66
|
+
level.should_receive(:show_hint)
|
|
67
|
+
subject.hint
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "#reset" do
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
it "resets the current level" do
|
|
74
|
+
level.should_receive(:setup_level)
|
|
75
|
+
level.should_receive(:full_description)
|
|
76
|
+
Githug::UI.should_receive(:word_box).with("Githug")
|
|
77
|
+
Githug::UI.should_receive(:puts).with("resetting level")
|
|
78
|
+
subject.reset
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "does not reset if the level cannot be loaded" do
|
|
82
|
+
Githug::Level.stub(:load).and_return(false)
|
|
83
|
+
level.should_not_receive(:setup_level)
|
|
84
|
+
level.should_not_receive(:full_description)
|
|
85
|
+
Githug::UI.should_receive(:error).with("Level does not exist")
|
|
86
|
+
subject.reset
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "resets the level with a level name" do
|
|
90
|
+
level.should_receive(:setup_level)
|
|
91
|
+
level.should_receive(:full_description)
|
|
92
|
+
profile = mock
|
|
93
|
+
Githug::Profile.stub(:load).and_return(profile)
|
|
94
|
+
profile.should_receive(:set_level).with("add")
|
|
95
|
+
Githug::Level.should_receive(:load).with("add").and_return(level)
|
|
96
|
+
Githug::UI.should_receive(:word_box).with("Githug")
|
|
97
|
+
Githug::UI.should_receive(:puts).with("resetting level")
|
|
98
|
+
subject.reset("add")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "resets the level with a level number" do
|
|
102
|
+
level.should_receive(:setup_level)
|
|
103
|
+
level.should_receive(:full_description)
|
|
104
|
+
profile = mock
|
|
105
|
+
Githug::Profile.stub(:load).and_return(profile)
|
|
106
|
+
profile.should_receive(:set_level).with("rename_commit")
|
|
107
|
+
Githug::Level.should_receive(:load).with("rename_commit").and_return(level)
|
|
108
|
+
Githug::UI.should_receive(:word_box).with("Githug")
|
|
109
|
+
Githug::UI.should_receive(:puts).with("resetting level")
|
|
110
|
+
subject.reset("45")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "resets the level with a path" do
|
|
114
|
+
level.should_receive(:setup_level)
|
|
115
|
+
level.should_receive(:full_description)
|
|
116
|
+
Githug::UI.should_receive(:word_box).with("Githug")
|
|
117
|
+
Githug::UI.should_receive(:puts).with("resetting level")
|
|
118
|
+
subject.reset("/foo/bar/level.rb")
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe "#levels" do
|
|
125
|
+
|
|
126
|
+
it "prints the levels and their numbers" do
|
|
127
|
+
Githug::Level.stub(:list).and_return(["commit", "add"])
|
|
128
|
+
Githug::UI.should_receive(:puts).with(["#1: commit", "#2: add"])
|
|
129
|
+
subject.levels
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|