From 39eda89d75ba7b1e76e415b16923812725f97c9f Mon Sep 17 00:00:00 2001 From: Hans Roman Date: Thu, 8 Jan 2015 19:46:03 -0500 Subject: [PATCH 001/115] Fix typo that prevented ".hidden" to be commited --- levels/squash.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/squash.rb b/levels/squash.rb index 4ed31432..03e0cefb 100644 --- a/levels/squash.rb +++ b/levels/squash.rb @@ -4,7 +4,7 @@ setup do repo.init FileUtils.touch(".hidden") - repo.add("hidden") + repo.add(".hidden") repo.commit_all("Initial Commit") FileUtils.touch("README") repo.add("README") From 7e1dcd72c05cbc49ec5ba2552a129008512c35d3 Mon Sep 17 00:00:00 2001 From: Jack Maney Date: Wed, 14 Jan 2015 11:57:50 -0600 Subject: [PATCH 002/115] Added a basic submodule level --- levels/submodule.rb | 20 ++++++++++++++++++++ lib/githug/level.rb | 3 ++- lib/githug/version.rb | 2 +- spec/githug_spec.rb | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 levels/submodule.rb diff --git a/levels/submodule.rb b/levels/submodule.rb new file mode 100644 index 00000000..6432a38b --- /dev/null +++ b/levels/submodule.rb @@ -0,0 +1,20 @@ +difficulty 2 +description "You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into a the folder `./githug-include-me`. Do this without cloning the repo or copying the files from the repo into this repo." + +setup do + repo.init +end + +solution do + return false if not File.directory?("./githug-include-me") + return false if not File.exist?("./githug-include-me/README.md") + return false if not File.exist?("./githug-include-me/.git") + return false if File.directory?("./githug-include-me/.git") + return false if not File.exist?(".gitmodules") + + return true +end + +hint do + puts "Take a look at `git submodule`." +end diff --git a/lib/githug/level.rb b/lib/githug/level.rb index 45b98225..d0b46fe3 100644 --- a/lib/githug/level.rb +++ b/lib/githug/level.rb @@ -11,7 +11,8 @@ class Level "checkout", "checkout_tag", "checkout_tag_over_branch", "branch_at", "delete_branch", "push_branch", "merge", "fetch", "rebase", "repack", "cherry-pick", "grep", "rename_commit", "squash", "merge_squash", "reorder", "bisect", - "stage_lines", "find_old_branch", "revert", "restore", "conflict", "contribute"] + "stage_lines", "find_old_branch", "revert", "restore", "conflict", + "submodule","contribute"] attr_accessor :level_no, :level_path, :level_name diff --git a/lib/githug/version.rb b/lib/githug/version.rb index 3d54e2b8..7c861b68 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.4.3" + VERSION = "0.4.4" end diff --git a/spec/githug_spec.rb b/spec/githug_spec.rb index 071e8665..ad5a4435 100644 --- a/spec/githug_spec.rb +++ b/spec/githug_spec.rb @@ -298,6 +298,11 @@ def skip_level skip_level end + it "solves the submodule level" do + `git submodule add https://github.com/jackmaney/githug-include-me` + `githug`.should be_solved + end + it "solves the contribute level" do skip_level end From 3d844f5a7a194851ed7db817635989f4e59c5d75 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Tue, 10 Feb 2015 18:30:16 +0000 Subject: [PATCH 003/115] fix(fetch): ensure fetch level works on Windows Previously the fetch level was using the `wc` tool to check the number of commits in ".git/FETCH_HEAD". Since `wc` is not available on Windows, a pure ruby alternative is used. --- levels/fetch.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/levels/fetch.rb b/levels/fetch.rb index af4a24f2..76e999e2 100644 --- a/levels/fetch.rb +++ b/levels/fetch.rb @@ -52,13 +52,13 @@ # after a git fetch command, each branch will be stored in in the .git/FETCH_HEAD file. Each branch is on its own line # This command will count the number of lines, which will give the number of branches if File.file?('.git/FETCH_HEAD') #checks for file existance - num_remote = `wc -l < .git/FETCH_HEAD` + num_remote = File.read(".git/FETCH_HEAD").split("\n").count else - num_remote = '0' + num_remote = 0 end # there should be 1 local branch and 2 remote branches for a success condition - if local_branches == 1 and num_remote.to_i == 2 + if local_branches == 1 and num_remote == 2 result = true else result = false From 97fc24829d6ce9bb20347e85314bcca5617ca9cc Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Tue, 10 Feb 2015 18:31:59 +0000 Subject: [PATCH 004/115] fix(push_branch): ensure push_branch level works on Windows Previously the push_branch level was using the `wc` tool to check the number of branches in the repository. Since `wc` is not available on Windows, a pure ruby alternative is used. --- levels/push_branch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/push_branch.rb b/levels/push_branch.rb index a9de94cc..7f0a0a91 100644 --- a/levels/push_branch.rb +++ b/levels/push_branch.rb @@ -60,7 +60,7 @@ #each branch consits of one line, `wc -l counts the number of lines in order to get the number of remote branches` #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 - num_remote_branches = `git branch -r | wc -l`.to_i + num_remote_branches = `git branch -r`.split("\n").count # counts the number of commits in the remote master branch' remote_master_commits = repo.commits('origin/master').count From cdc24b9e14e0992064c3f5c19ad3caf468c475d0 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Fri, 13 Feb 2015 10:52:46 +0000 Subject: [PATCH 005/115] fix(reorder): ensure file3 is closed in merge_squash level Previously the merge_squash level was using "file3" to validate the results. On Windows, a file needs to be explicitly closed or it cannot be accessed by another process. When reseting for the reorder level, this was causing a permissions issue. --- levels/merge_squash.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/merge_squash.rb b/levels/merge_squash.rb index fb50f8d9..d0eb8b04 100644 --- a/levels/merge_squash.rb +++ b/levels/merge_squash.rb @@ -39,6 +39,7 @@ result = false unless file.readline =~ /some feature/ result = false unless file.readline =~ /getting awesomer/ result = false unless file.readline =~ /and awesomer!/ + file.close result end From 48bc5d357e7f39693fe2a3c50244ef03bc2457cd Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Sat, 19 Dec 2015 11:57:32 -0700 Subject: [PATCH 006/115] flesh out game instructions in README The instructions for how to use Githug assumed a lot of knowledge that many beginners do not have (Ruby, filesystem idioms, permissions). This makes the Ruby prerequisite explicit (not everyone who wants to learn git is learning Ruby). Since people who are learning git without ruby might already have Ruby installed at the system-level, this adds a note about running `gem install` with `sudo`. It also separates out "how to play" from the installation instructions, and removed the `test` command from the list of commands, since that is contributor-related and not relevant for people who are just using the tool to learn how to use git. The `test` command is documented below in the contribution section. --- README.md | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8562ae73..90f8b822 100644 --- a/README.md +++ b/README.md @@ -3,28 +3,58 @@ Git Your Game On [![Build Status](https://travis-ci.org/Gazler/githug.png?branch ## About Githug is designed to give you a practical way of learning git. It has a series of levels, each requiring you to use git commands to arrive at a correct answer. -## Installation +## Playing Githug + +Githug should work on Linux, OS X and Windows. + +### Prerequisites + +Githug requires Ruby 1.8.7 or higher. + +You can check which version of Ruby is installed with the following command: + +``` +ruby --version +``` + +If ruby is not installed, follow the installation instructions on [ruby-lang.org](https://www.ruby-lang.org/en/documentation/installation/). + +### Installation + To install Githug, run gem install githug -After the gem is installed, run `githug`. You will be prompted to create a directory. Githug should work on Linux, OS X and Windows. +If you get a complaint about permissions, you can rerun the command with `sudo`: + + sudo gem install githug + +### Starting the Game + +After the gem is installed change directory to the location where you want the game-related assets to be stored. +Then run `githug`: + + githug -## Commands +You will be prompted to create a directory. -Githug has 5 commands: + No githug directory found, do you wish to create one? [yn] + +Type `y` (yes) to continue, `n` (no) to cancel and quit Githug. + +### Commands + +Githug has 4 game commands: * play - The default command, checks your solution for the current level * hint - Gives you a hint (if available) for the current level * reset - Reset the current level or reset the level to a given name or path * levels - List all the levels - * test - Test levels in development (please see the "Testing Levels" section below) ## Change Log The change log is available on the wiki. [Change log](https://github.com/Gazler/githug/wiki/Change-Log) - ## Contributing To suggest a level or create a level that has been suggested, check out [the wiki](https://github.com/Gazler/githug/wiki). From b21ce095f8297474b5a2866ef2613c07f8400059 Mon Sep 17 00:00:00 2001 From: Anthony Gargiulo Date: Sun, 4 Oct 2015 19:59:07 -0400 Subject: [PATCH 007/115] fix for the revert level 51 --- levels/revert.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/levels/revert.rb b/levels/revert.rb index 84652094..8ad2a0a6 100644 --- a/levels/revert.rb +++ b/levels/revert.rb @@ -20,11 +20,9 @@ solution do valid = false + commit_messages = repo.commits.map(&:message) valid = true if repo.commits.length > 3 && - repo.commits[3].message == "First commit" && - repo.commits[2].message == "Second commit" && - repo.commits[1].message == "Bad commit" && - repo.commits[0].message.split("\n").first == "Revert \"Bad commit\"" + commit_messages.any? { |e| e =~ /(Revert )?"Bad commit"/ } valid end From 923114c6883c84a71f04f796318351cf6fe27a48 Mon Sep 17 00:00:00 2001 From: legendtkl Date: Fri, 1 Jan 2016 20:48:19 +0800 Subject: [PATCH 008/115] give the detailed information about squash (squash which commits to which) --- levels/squash.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/levels/squash.rb b/levels/squash.rb index 03e0cefb..64559e35 100644 --- a/levels/squash.rb +++ b/levels/squash.rb @@ -11,13 +11,13 @@ repo.commit_all("Adding README") File.open("README", 'w') { |f| f.write("hey there") } repo.add("README") - repo.commit_all("Updating README") + repo.commit_all("Updating README (squash this commit into Adding README)") File.open("README", 'a') { |f| f.write("\nAdding some more text") } repo.add("README") - repo.commit_all("Updating README") + repo.commit_all("Updating README (squash this commit into Adding README)") File.open("README", 'a') { |f| f.write("\neven more text") } repo.add("README") - repo.commit_all("Updating README") + repo.commit_all("Updating README (squash this commit into Adding README)") end solution do From 84d101e5f92a5b326233546f703ffa0a437d807b Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Fri, 1 Jan 2016 15:56:06 +0000 Subject: [PATCH 009/115] fix(levels/remote_url): allow a trailing slash on repo url both `https://github.com/githug/not_a_repo` and `https://github.com/githug/not_a_repo/` are now valid. This closes #187 --- levels/remote_url.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/remote_url.rb b/levels/remote_url.rb index 7321def6..dc15367b 100644 --- a/levels/remote_url.rb +++ b/levels/remote_url.rb @@ -9,7 +9,7 @@ end solution do - "https://github.com/githug/not_a_repo" == request("What is the url of the remote repository?") + !!(request("What is the url of the remote repository?") =~ /https:\/\/github.com\/githug\/not_a_repo\/?/) end hint do From 495805853865c378b1880f276f0ce460743101c6 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Fri, 1 Jan 2016 15:57:31 +0000 Subject: [PATCH 010/115] chore(version): bump to 0.4.5 --- lib/githug/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/githug/version.rb b/lib/githug/version.rb index 7c861b68..4c5f8cf4 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.4.4" + VERSION = "0.4.5" end From 49ffc886143dd2b9a19c59293ddca374166d4b03 Mon Sep 17 00:00:00 2001 From: Hooopo Date: Sun, 3 Jan 2016 22:14:04 +0800 Subject: [PATCH 011/115] add homepage --- githug.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githug.gemspec b/githug.gemspec index 917d861b..1f17ca92 100644 --- a/githug.gemspec +++ b/githug.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |s| s.version = Githug::VERSION s.authors = ["Gary Rennie"] s.email = ["webmaster@gazler.com"] - s.homepage = "" + s.homepage = "https://github.com/Gazler/githug" s.summary = %q{An interactive way to learn git.} s.description = %q{An interactive way to learn git.} From fea1b1b918fe85f91bc9419430cafef262304e93 Mon Sep 17 00:00:00 2001 From: Oscar de Groot Date: Thu, 7 Jan 2016 15:04:28 +0100 Subject: [PATCH 012/115] Fix typo: it's GitHub, not Github. --- levels/contribute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/contribute.rb b/levels/contribute.rb index 149cbcc4..ba9ebfc0 100644 --- a/levels/contribute.rb +++ b/levels/contribute.rb @@ -1,5 +1,5 @@ difficulty 3 -description "This is the final level, the goal is to contribute to this repository by making a pull request on Github. Please note that this level is designed to encourage you to add a valid contribution to Githug, not testing your ability to create a pull request. Contributions that are likely to be accepted are levels, bug fixes and improved documentation." +description "This is the final level, the goal is to contribute to this repository by making a pull request on GitHub. Please note that this level is designed to encourage you to add a valid contribution to Githug, not testing your ability to create a pull request. Contributions that are likely to be accepted are levels, bug fixes and improved documentation." solution do location = "/tmp/githug" From 798f838f3c3d24b202c26f3fc981a3a85996e7fd Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Fri, 8 Jan 2016 17:51:17 +0000 Subject: [PATCH 013/115] fix(checkout_tag): only show commit message in solution The solution now uses a format flag to only show the commit message. This fixes an issue if the users name contains UTF-8 characters. --- levels/checkout_tag.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/checkout_tag.rb b/levels/checkout_tag.rb index 82e3284e..8e571b11 100644 --- a/levels/checkout_tag.rb +++ b/levels/checkout_tag.rb @@ -30,7 +30,7 @@ solution do return false unless repo.commits.length == 5 - return false unless `git show HEAD` =~ /Some more changes/ + return false unless `git show HEAD --format=%s` =~ /Some more changes/ true end From 0c09f4cb8e65275af0f66f0ab83346bd04be4835 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Fri, 8 Jan 2016 17:57:00 +0000 Subject: [PATCH 014/115] chore(version): bump to 0.4.6 --- lib/githug/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/githug/version.rb b/lib/githug/version.rb index 4c5f8cf4..b593dfd0 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.4.5" + VERSION = "0.4.6" end From 44289d291c2cc8102229e0fccd83c592fbaa9d98 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Mon, 11 Jan 2016 18:05:41 +0000 Subject: [PATCH 015/115] fix(checkout_tag_over_branch): only show commit message in solution The solution now uses a format flag to only show the commit message. This fixes an issue if the users name contains UTF-8 characters. --- levels/checkout_tag_over_branch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/checkout_tag_over_branch.rb b/levels/checkout_tag_over_branch.rb index e10e5163..3a6c89a5 100644 --- a/levels/checkout_tag_over_branch.rb +++ b/levels/checkout_tag_over_branch.rb @@ -37,7 +37,7 @@ solution do return false unless repo.commits.length == 5 - return false unless `git show HEAD` =~ /Some more changes/ + return false unless `git show HEAD --format=%s` =~ /Some more changes/ true end From ec4a8e41c02108e7af7bba6c05fe439a6bd23cfe Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Thu, 14 Jan 2016 22:05:14 +0000 Subject: [PATCH 016/115] chore(version): bump to 0.4.7 --- lib/githug/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/githug/version.rb b/lib/githug/version.rb index b593dfd0..60f43105 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.4.6" + VERSION = "0.4.7" end From 8869b2599e396c6ddb9e1a782e75e54713050346 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Thu, 21 Jan 2016 21:56:26 +0000 Subject: [PATCH 017/115] fix(push): specify the files to copy This prevents the copy recursing if the tmp directory exists in the git_hug workspace. Fixes #201 and #188 --- levels/push.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/levels/push.rb b/levels/push.rb index 28722b12..b9f84279 100644 --- a/levels/push.rb +++ b/levels/push.rb @@ -21,7 +21,9 @@ repo.commit_all "Second commit" # copy the repo to remote - FileUtils.cp_r ".", tmpdir + FileUtils.cp "file1", tmpdir + FileUtils.cp "file2", tmpdir + # add another file FileUtils.touch "file3" repo.add "file3" From 8f79c63c989624dd52223164ac582571f90a66d2 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Thu, 21 Jan 2016 21:57:59 +0000 Subject: [PATCH 018/115] chore(version): bump to 0.4.8 --- lib/githug/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/githug/version.rb b/lib/githug/version.rb index 60f43105..a18c4992 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.4.7" + VERSION = "0.4.8" end From af332cef894d6cb96be84abae89893d64908f346 Mon Sep 17 00:00:00 2001 From: Lane Date: Fri, 5 Aug 2016 00:14:01 +0800 Subject: [PATCH 019/115] Update "githug reset" to allow numbers (#215) --- lib/githug/cli.rb | 8 +++++++- spec/githug/cli_spec.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/githug/cli.rb b/lib/githug/cli.rb index 6bac6157..89431629 100644 --- a/lib/githug/cli.rb +++ b/lib/githug/cli.rb @@ -38,7 +38,7 @@ def hint LEVEL parameter which will reset the game to a specific level. For example: - > $ githug reset merge_squash + > $ githug reset merge_squash # or $ githug reset 45 Will reset githug to level '#45: merge_squash' LONGDESC @@ -67,10 +67,16 @@ def levels def load_level(path = nil) return load_level_from_profile unless path + return load_level_from_number(path.to_i) if path.to_i.to_s == path return load_level_from_name(path) if Level.list.include?(path) Level.load_from_file(path) end + def load_level_from_number(number) + level_name = number >= 1 ? Level.list[number - 1] : nil + return load_level_from_name(level_name) + end + def load_level_from_name(name) profile = Profile.load profile.set_level(name) diff --git a/spec/githug/cli_spec.rb b/spec/githug/cli_spec.rb index d5d28a7b..d3c26829 100644 --- a/spec/githug/cli_spec.rb +++ b/spec/githug/cli_spec.rb @@ -98,6 +98,18 @@ subject.reset("add") end + it "resets the level with a level number" do + level.should_receive(:setup_level) + level.should_receive(:full_description) + profile = mock + Githug::Profile.stub(:load).and_return(profile) + profile.should_receive(:set_level).with("squash") + Githug::Level.should_receive(:load).with("squash").and_return(level) + Githug::UI.should_receive(:word_box).with("Githug") + Githug::UI.should_receive(:puts).with("resetting level") + subject.reset("45") + end + it "resets the level with a path" do level.should_receive(:setup_level) level.should_receive(:full_description) From 8931d2faf358ddb9ca52b9cb3d206cb204a1d027 Mon Sep 17 00:00:00 2001 From: pallxk Date: Sat, 6 Aug 2016 19:18:56 +0800 Subject: [PATCH 020/115] fix(ignore): clarify level requirements (#216) --- levels/ignore.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/ignore.rb b/levels/ignore.rb index 6cef9db7..9689fb7f 100644 --- a/levels/ignore.rb +++ b/levels/ignore.rb @@ -1,5 +1,5 @@ difficulty 2 -description "The text editor 'vim' creates files ending in `.swp` (swap files) for all files that are currently open. We don't want them creeping into the repository. Make this repository ignore `.swp` files." +description "The text editor 'vim' creates files ending in `.swp` (swap files) for all files that are currently open. We don't want them creeping into the repository. Make this repository ignore those swap files which are ending in `.swp`." setup do repo.init From d8a39953bfaeb6c02bd297d3f57bdfae985db7be Mon Sep 17 00:00:00 2001 From: pallxk Date: Wed, 10 Aug 2016 15:30:44 +0800 Subject: [PATCH 021/115] chore(gemspec): specify required rake version (#217) rake v11 drops support for ruby version < 1.9.3 --- githug.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githug.gemspec b/githug.gemspec index 1f17ca92..bc5da6a3 100644 --- a/githug.gemspec +++ b/githug.gemspec @@ -23,6 +23,6 @@ Gem::Specification.new do |s| s.add_dependency "grit", "~>2.3.0" s.add_dependency "thor", "~>0.14.6" - s.add_dependency "rake" + s.add_dependency "rake", "<11" # s.add_runtime_dependency "rest-client" end From 1189d3515caf245d638d62583dfeab3b009b9763 Mon Sep 17 00:00:00 2001 From: Sean Oldham Date: Wed, 17 Aug 2016 15:04:46 -0500 Subject: [PATCH 022/115] Clarify Description Wording Instead of "Do this without cloning the repo..." I've changed it to "Do this without manually cloning the repo..." When using submodule, it does clone the repo. I was initially confused by the phrasing in the description and hope this helps make it more clear. --- levels/submodule.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/submodule.rb b/levels/submodule.rb index 6432a38b..4e316f37 100644 --- a/levels/submodule.rb +++ b/levels/submodule.rb @@ -1,5 +1,5 @@ difficulty 2 -description "You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into a the folder `./githug-include-me`. Do this without cloning the repo or copying the files from the repo into this repo." +description "You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into a the folder `./githug-include-me`. Do this without manually cloning the repo or copying the files from the repo into this repo." setup do repo.init From fd38c65bce7843f6c13fce26b5963a6d6cdaba9c Mon Sep 17 00:00:00 2001 From: Yunfeng Wang Date: Fri, 30 Sep 2016 15:29:07 +0800 Subject: [PATCH 023/115] fix(ProfileSpec): typo in profile test (#220) `acces` to `access` --- spec/githug/profile_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/githug/profile_spec.rb b/spec/githug/profile_spec.rb index 36ad74b5..fd966c89 100644 --- a/spec/githug/profile_spec.rb +++ b/spec/githug/profile_spec.rb @@ -20,7 +20,7 @@ end end - it "allows method acces to getters and setters" do + it "allows method access to getters and setters" do profile = Githug::Profile.load profile.level.should eql(nil) profile.level = 1 From c543aefad5c8bf148a0cafe6b1d780ffcd0f6b81 Mon Sep 17 00:00:00 2001 From: Janis Vitols Date: Sun, 13 Nov 2016 21:05:34 +0200 Subject: [PATCH 024/115] feat(rebase_onto): add level (#221) --- levels/rebase_onto.rb | 45 +++++++++++++++++++++++++++++++++++++++++ lib/githug/level.rb | 2 +- lib/githug/version.rb | 2 +- spec/githug/cli_spec.rb | 4 ++-- spec/githug_spec.rb | 6 ++++++ 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 levels/rebase_onto.rb diff --git a/levels/rebase_onto.rb b/levels/rebase_onto.rb new file mode 100644 index 00000000..e5043ef2 --- /dev/null +++ b/levels/rebase_onto.rb @@ -0,0 +1,45 @@ +difficulty 2 + +description "You have created your branch from `wrong_branch` and already made some commits, \ +and you realise that you needed to create your branch from `master`. \ +Rebase your commits onto `master` branch so that you don't have `wrong_branch` commits." + +setup do + readme_file = "README.md" + authors_file = "authors.md" + + repo.init + FileUtils.touch(authors_file) + File.open(authors_file, "w") { |f| f << "https://github.com/janis-vitols\n" } + repo.add(authors_file) + repo.commit_all("Create authors file") + + repo.git.native :checkout, { "b" => true }, "wrong_branch" + File.open(authors_file, "w") { |f| f << "None\n" } + repo.add(authors_file) + repo.commit_all("Wrong changes") + + repo.git.native :checkout, { "b" => true }, "readme-update" + FileUtils.touch(readme_file) + File.open(readme_file, "a") { |f| f << "# SuperApp\n" } + repo.add(readme_file) + repo.commit_all("Add app name in readme") + File.open(readme_file, "a") { |f| f << "## About\n" } + repo.add(readme_file) + repo.commit_all("Add `About` header in readme") + File.open(readme_file, "a") { |f| f << "## Install\n" } + repo.add(readme_file) + repo.commit_all("Add `Install` header in readme") +end + +solution do + repo.commits("readme-update").each { |commit| return false if commit.message == "Wrong changes" } + return false unless repo.commits("readme-update").length == 4 + return false unless File.readlines("authors.md").include?("https://github.com/janis-vitols\n") + + true +end + +hint do + puts "You want to research the `git rebase` commands `--onto` argument" +end diff --git a/lib/githug/level.rb b/lib/githug/level.rb index d0b46fe3..051d1738 100644 --- a/lib/githug/level.rb +++ b/lib/githug/level.rb @@ -9,7 +9,7 @@ class Level "commit_in_future", "reset", "reset_soft", "checkout_file", "remote", "remote_url", "pull", "remote_add", "push", "diff", "blame", "branch", "checkout", "checkout_tag", "checkout_tag_over_branch", "branch_at", - "delete_branch", "push_branch", "merge", "fetch", "rebase", "repack", "cherry-pick", + "delete_branch", "push_branch", "merge", "fetch", "rebase", "rebase_onto", "repack", "cherry-pick", "grep", "rename_commit", "squash", "merge_squash", "reorder", "bisect", "stage_lines", "find_old_branch", "revert", "restore", "conflict", "submodule","contribute"] diff --git a/lib/githug/version.rb b/lib/githug/version.rb index a18c4992..db82e905 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.4.8" + VERSION = "0.4.9" end diff --git a/spec/githug/cli_spec.rb b/spec/githug/cli_spec.rb index d3c26829..791e2902 100644 --- a/spec/githug/cli_spec.rb +++ b/spec/githug/cli_spec.rb @@ -103,8 +103,8 @@ level.should_receive(:full_description) profile = mock Githug::Profile.stub(:load).and_return(profile) - profile.should_receive(:set_level).with("squash") - Githug::Level.should_receive(:load).with("squash").and_return(level) + profile.should_receive(:set_level).with("rename_commit") + Githug::Level.should_receive(:load).with("rename_commit").and_return(level) Githug::UI.should_receive(:word_box).with("Githug") Githug::UI.should_receive(:puts).with("resetting level") subject.reset("45") diff --git a/spec/githug_spec.rb b/spec/githug_spec.rb index ad5a4435..988892b9 100644 --- a/spec/githug_spec.rb +++ b/spec/githug_spec.rb @@ -237,6 +237,12 @@ def skip_level `githug`.should be_solved end + it "solves the rebase_onto level" do + `git checkout readme-update` + `git rebase --onto master wrong_branch readme-update` + `githug`.should be_solved + end + it "solves the repack level" do `git repack -d` `githug`.should be_solved From 109597c078ff479bfdf545187c5d8acebe00cb37 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Sun, 13 Nov 2016 19:06:28 +0000 Subject: [PATCH 025/115] chore(version): bump to 0.5.0 This is a minor release due to the inclusion of the rebase_onto level. --- lib/githug/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/githug/version.rb b/lib/githug/version.rb index db82e905..94a7696c 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.4.9" + VERSION = "0.5.0" end From 0cc18515bf6606d44ec631262532fb8da4b7fa6e Mon Sep 17 00:00:00 2001 From: kk Date: Sat, 3 Dec 2016 06:52:25 -0600 Subject: [PATCH 026/115] docs(README.md): fix typo stacktrace -> stack trace (#224) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90f8b822..263d58a3 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,6 @@ The easiest way to test a level is: * Solve the level * Run `githug test PATH_TO_YOUR_LEVEL` -Please note that the `githug test` command can be run as `githug test --errors` to get an error stacktrace from your solve method. +Please note that the `githug test` command can be run as `githug test --errors` to get an error stack trace from your solve method. It would be ideal if you add an integration test for your level. These tests live in `spec/githug_spec` and **must** be run in order. If you add a level but do not add a test, please add a simple `skip_level` test case similar to the `contribute` level. From f184f34176651ef5f7ef89a588b6cfa06c8bf008 Mon Sep 17 00:00:00 2001 From: "C.W" Date: Sat, 3 Dec 2016 04:53:49 -0800 Subject: [PATCH 027/115] chore(.gemspec): remove commented out dependency (#222) * Remove commented-out dependency in gemspec --- githug.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/githug.gemspec b/githug.gemspec index bc5da6a3..7e604857 100644 --- a/githug.gemspec +++ b/githug.gemspec @@ -24,5 +24,4 @@ Gem::Specification.new do |s| s.add_dependency "grit", "~>2.3.0" s.add_dependency "thor", "~>0.14.6" s.add_dependency "rake", "<11" - # s.add_runtime_dependency "rest-client" end From 1225f668447d5f3af4f9d3e63728f6dfcb8d3eb6 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Thu, 19 Jan 2017 12:02:59 +0100 Subject: [PATCH 028/115] fix(submodule): fix minor typo (#226) --- levels/submodule.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/submodule.rb b/levels/submodule.rb index 4e316f37..9a7a60ec 100644 --- a/levels/submodule.rb +++ b/levels/submodule.rb @@ -1,5 +1,5 @@ difficulty 2 -description "You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into a the folder `./githug-include-me`. Do this without manually cloning the repo or copying the files from the repo into this repo." +description "You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into the folder `./githug-include-me`. Do this without manually cloning the repo or copying the files from the repo into this repo." setup do repo.init From f91d50539b182969065cfec8ce19b1465f344a46 Mon Sep 17 00:00:00 2001 From: Sobolev Nikita Date: Thu, 6 Apr 2017 11:08:29 +0300 Subject: [PATCH 029/115] docs(README.md): use svg badges (#230) --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 263d58a3..c158adbb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Githug -Git Your Game On [![Build Status](https://travis-ci.org/Gazler/githug.png?branch=master)](https://travis-ci.org/Gazler/githug) [![Code Climate](https://codeclimate.com/github/Gazler/githug.png)](https://codeclimate.com/github/Gazler/githug) +Git Your Game On + +[![Build Status](https://travis-ci.org/Gazler/githug.svg?branch=master)](https://travis-ci.org/Gazler/githug) [![Code Climate](https://codeclimate.com/github/Gazler/githug.svg)](https://codeclimate.com/github/Gazler/githug) + ## About Githug is designed to give you a practical way of learning git. It has a series of levels, each requiring you to use git commands to arrive at a correct answer. From 392c357f237049e870ee2d560b78543d1c5838df Mon Sep 17 00:00:00 2001 From: Michael Kebe Date: Thu, 6 Apr 2017 10:09:27 +0200 Subject: [PATCH 030/115] feat(rm): print the hint on multiple lines (#231) --- levels/rm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/rm.rb b/levels/rm.rb index 7f815d9d..8ee563b5 100644 --- a/levels/rm.rb +++ b/levels/rm.rb @@ -16,5 +16,5 @@ end hint do - puts "You may need to use more than one command to complete this. You have checked your staging area in a previous level. Don't forget to run `git` for a list of commands." + puts ["You may need to use more than one command to complete this.", "You have checked your staging area in a previous level.", "Don't forget to run `git` for a list of commands."] end From c92e35dd4ce82d7a41f8abd5529a76a4d167c957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AF=E5=8F=AF=E7=86=8A?= Date: Thu, 6 Apr 2017 03:13:02 -0500 Subject: [PATCH 031/115] fix(Githug): stdout buffer problem (#227) (#228) --- lib/githug.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/githug.rb b/lib/githug.rb index 14c26d6a..84bc11eb 100644 --- a/lib/githug.rb +++ b/lib/githug.rb @@ -13,3 +13,4 @@ Githug::UI.in_stream = STDIN Githug::UI.out_stream = STDOUT +STDIN.sync = true From d763aa99f5bf02deb6d029194fae0620a71bd1e5 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 25 Jul 2017 18:15:16 +0300 Subject: [PATCH 032/115] First level hint improvement (#233) --- levels/init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/init.rb b/levels/init.rb index d18e04ec..3d17c03d 100644 --- a/levels/init.rb +++ b/levels/init.rb @@ -6,5 +6,5 @@ end hint do - puts "You can type `git` in your shell to get a list of available git commands." + puts "You can type `git --help` or `git` in your shell to get a list of available git commands." end From 2544b01546d00165cd7f7059b965be85e1e15006 Mon Sep 17 00:00:00 2001 From: elstamey Date: Thu, 2 Nov 2017 04:36:24 -0400 Subject: [PATCH 033/115] revised the language of the prompt for push level (#236) --- levels/push.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/push.rb b/levels/push.rb index b9f84279..af92120d 100644 --- a/levels/push.rb +++ b/levels/push.rb @@ -1,6 +1,6 @@ difficulty 3 description "Your local master branch has diverged from " + - "the remote origin/master branch. Rebase your commit onto " + + "the remote origin/master branch. Rebase your branch onto " + "origin/master and push it to remote." setup do From d1de80a3d7b102691b03528a0d8be94d365b1026 Mon Sep 17 00:00:00 2001 From: tkhamis <39271287+tkhamis@users.noreply.github.com> Date: Wed, 11 Jul 2018 21:17:38 +0300 Subject: [PATCH 034/115] Imporoved the hint of the test grep (#240) * Imporoved the hint of the test grep * Improved hint --- levels/number_of_files_committed.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/number_of_files_committed.rb b/levels/number_of_files_committed.rb index 8eda2b93..db2e0a43 100644 --- a/levels/number_of_files_committed.rb +++ b/levels/number_of_files_committed.rb @@ -47,5 +47,5 @@ end hint do - puts "You are looking for a command to identify the status of the repository." + puts "You are looking for a command to identify the status of the repository, (resembles a linux command)." end From f54aa2517e247727809ad3d60710824d4fadb8cf Mon Sep 17 00:00:00 2001 From: Lane Date: Mon, 10 Dec 2018 15:49:21 +0800 Subject: [PATCH 035/115] #45: merge_squash => #47: merge_squash (#246) --- lib/githug/cli.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/githug/cli.rb b/lib/githug/cli.rb index 89431629..31306568 100644 --- a/lib/githug/cli.rb +++ b/lib/githug/cli.rb @@ -38,9 +38,9 @@ def hint LEVEL parameter which will reset the game to a specific level. For example: - > $ githug reset merge_squash # or $ githug reset 45 + > $ githug reset merge_squash # or $ githug reset 47 - Will reset githug to level '#45: merge_squash' + Will reset githug to level '#47: merge_squash' LONGDESC def reset(path = nil) level = load_level(path) From 6b4c41d8080409e154889209b7e41aaf53c6e2a6 Mon Sep 17 00:00:00 2001 From: duianto Date: Mon, 11 Feb 2019 08:58:48 +0100 Subject: [PATCH 036/115] fix(number_of_files_commit): ask for files not changes (#247) --- levels/number_of_files_committed.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/number_of_files_committed.rb b/levels/number_of_files_committed.rb index db2e0a43..1b37ab43 100644 --- a/levels/number_of_files_committed.rb +++ b/levels/number_of_files_committed.rb @@ -31,7 +31,7 @@ end solution do - numberOfFilesThereWillBeCommit = request("How many changes are going to be committed?") + numberOfFilesThereWillBeCommit = request("How many files are going to be committed?") isInteger = !!(numberOfFilesThereWillBeCommit =~ /^[-+]?[0-9]+$/) From 09f95a0e9ec1178217d4b764b2e16f31e4635c3b Mon Sep 17 00:00:00 2001 From: duianto Date: Thu, 14 Feb 2019 09:02:25 +0100 Subject: [PATCH 037/115] chore(fetch): remove trailing whitespace (#250) --- levels/fetch.rb | 8 ++++---- levels/number_of_files_committed.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/levels/fetch.rb b/levels/fetch.rb index 76e999e2..2f3b2083 100644 --- a/levels/fetch.rb +++ b/levels/fetch.rb @@ -23,7 +23,7 @@ FileUtils.touch "master_file" repo.add "master_file" repo.commit_all 'Commits master_file' - + #adds remote repo Dir.chdir cwd `git remote add origin #{tmpdir}/.git` @@ -38,7 +38,7 @@ FileUtils.touch "file1" repo.add "file1" repo.commit_all 'Commits file 1' - + end solution do @@ -50,7 +50,7 @@ local_branches = repo.branches.size # after a git fetch command, each branch will be stored in in the .git/FETCH_HEAD file. Each branch is on its own line - # This command will count the number of lines, which will give the number of branches + # This command will count the number of lines, which will give the number of branches if File.file?('.git/FETCH_HEAD') #checks for file existance num_remote = File.read(".git/FETCH_HEAD").split("\n").count else @@ -62,7 +62,7 @@ result = true else result = false - end + end end hint do diff --git a/levels/number_of_files_committed.rb b/levels/number_of_files_committed.rb index 1b37ab43..1977c29d 100644 --- a/levels/number_of_files_committed.rb +++ b/levels/number_of_files_committed.rb @@ -22,7 +22,7 @@ %w{rubyfile1.rb}.each do |file| FileUtils.touch(file) repo.add(file) - end + end #Untrached files %w{rubyfile6.rb rubyfile7.rb}.each do |file| From f7f17b2e649de843e3a31efd62abf1f82a4d5ffc Mon Sep 17 00:00:00 2001 From: vikrant-pune Date: Fri, 12 Apr 2019 12:20:13 +0530 Subject: [PATCH 038/115] Adding strip for string (#254) * Adding strip on solution for level 30 * Adding strip on solution for level 30 his commit fixes #253 --- levels/blame.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/blame.rb b/levels/blame.rb index cdb4c7f8..2adde08a 100644 --- a/levels/blame.rb +++ b/levels/blame.rb @@ -7,7 +7,7 @@ solution do offender = repo.commit("97bdd0cccf9f4b8730f78cb53a81a74f205dbcc2").author.name - request("Who made the commit with the password?").downcase == offender.downcase + request("Who made the commit with the password?").downcase.strip == offender.downcase end hint do From 28775b4807494418e5d38a793ce94c4760b516ac Mon Sep 17 00:00:00 2001 From: BreakBB <33514570+BreakBB@users.noreply.github.com> Date: Fri, 26 Apr 2019 08:45:28 +0200 Subject: [PATCH 039/115] Fix various typos. Remove double blanks. Rewrite find_old_branch (#257) --- levels/bisect.rb | 2 +- levels/branch_at.rb | 4 ++-- levels/checkout.rb | 2 +- levels/checkout_file.rb | 2 +- levels/cherry-pick.rb | 2 +- levels/commit_amend.rb | 2 +- levels/config.rb | 2 +- levels/contribute.rb | 2 +- levels/diff.rb | 4 ++-- levels/fetch.rb | 9 ++++----- levels/find_old_branch.rb | 2 +- levels/ignore.rb | 2 +- levels/include.rb | 2 +- levels/log.rb | 4 ++-- levels/number_of_files_committed.rb | 12 ++++++------ levels/push_branch.rb | 22 +++++++++++----------- levels/remote.rb | 4 ++-- levels/remote_url.rb | 2 +- levels/reset.rb | 2 +- levels/restore.rb | 4 ++-- levels/restructure.rb | 2 +- levels/revert.rb | 3 +-- levels/rm.rb | 2 +- levels/rm_cached.rb | 4 ++-- levels/squash.rb | 2 +- levels/stage_lines.rb | 2 +- levels/stash.rb | 2 +- levels/status.rb | 2 +- 28 files changed, 52 insertions(+), 54 deletions(-) diff --git a/levels/bisect.rb b/levels/bisect.rb index 8c13434f..49608bb8 100644 --- a/levels/bisect.rb +++ b/levels/bisect.rb @@ -1,5 +1,5 @@ difficulty 3 -description "A bug was introduced somewhere along the way. You know that running `ruby prog.rb 5` should output 15. You can also run `make test`. What are the first 7 chars of the hash of the commit that introduced the bug." +description "A bug was introduced somewhere along the way. You know that running `ruby prog.rb 5` should output 15. You can also run `make test`. What are the first 7 chars of the hash of the commit that introduced the bug." setup do init_from_level diff --git a/levels/branch_at.rb b/levels/branch_at.rb index ae6dc69e..00bdba27 100644 --- a/levels/branch_at.rb +++ b/levels/branch_at.rb @@ -1,5 +1,5 @@ difficulty 3 -description "You forgot to branch at the previous commit and made a commit on top of it. Create branch test_branch at the commit before the last." +description "You forgot to branch at the previous commit and made a commit on top of it. Create the branch test_branch at the commit before the last." setup do repo.init @@ -16,7 +16,7 @@ solution do return false unless repo.branches.map(&:name).include?("test_branch") - repo.commits("test_branch").each { |commit| return false if commit.message == "Updating file1 again" } + repo.commits("test_branch").each { |commit| return false if commit.message == "Updating file1 again" } true end diff --git a/levels/checkout.rb b/levels/checkout.rb index 27ae815b..67301010 100644 --- a/levels/checkout.rb +++ b/levels/checkout.rb @@ -1,5 +1,5 @@ difficulty 2 -description "Create and switch to a new branch called my_branch. You will need to create a branch like you did in the previous level." +description "Create and switch to a new branch called my_branch. You will need to create a branch like you did in the previous level." setup do repo.init diff --git a/levels/checkout_file.rb b/levels/checkout_file.rb index c4ef2f9b..848ef1a4 100644 --- a/levels/checkout_file.rb +++ b/levels/checkout_file.rb @@ -1,6 +1,6 @@ difficulty 3 -description "A file has been modified, but you don't want to keep the modification. Checkout the `config.rb` file from the last commit." +description "A file has been modified, but you don't want to keep the modification. Checkout the `config.rb` file from the last commit." setup do repo.init diff --git a/levels/cherry-pick.rb b/levels/cherry-pick.rb index be19905b..cf382a4b 100644 --- a/levels/cherry-pick.rb +++ b/levels/cherry-pick.rb @@ -3,7 +3,7 @@ setup do init_from_level - `git stash` #fix for README.md being in githug root an the level + `git stash` # fix for README.md being in githug root an the level end solution do diff --git a/levels/commit_amend.rb b/levels/commit_amend.rb index a16ab546..fe4c7757 100644 --- a/levels/commit_amend.rb +++ b/levels/commit_amend.rb @@ -1,5 +1,5 @@ difficulty 2 -description "The `README` file has been committed, but it looks like the file `forgotten_file.rb` was missing from the commit. Add the file and amend your previous commit to include it." +description "The `README` file has been committed, but it looks like the file `forgotten_file.rb` was missing from the commit. Add the file and amend your previous commit to include it." setup do repo.init diff --git a/levels/config.rb b/levels/config.rb index f5c44b2b..489a8060 100644 --- a/levels/config.rb +++ b/levels/config.rb @@ -29,5 +29,5 @@ end hint do - puts "These settings are config settings. You should run `git help config` if you are stuck." + puts "These settings are config settings. You should run `git help config` if you are stuck." end diff --git a/levels/contribute.rb b/levels/contribute.rb index ba9ebfc0..a36572ef 100644 --- a/levels/contribute.rb +++ b/levels/contribute.rb @@ -1,5 +1,5 @@ difficulty 3 -description "This is the final level, the goal is to contribute to this repository by making a pull request on GitHub. Please note that this level is designed to encourage you to add a valid contribution to Githug, not testing your ability to create a pull request. Contributions that are likely to be accepted are levels, bug fixes and improved documentation." +description "This is the final level, the goal is to contribute to this repository by making a pull request on GitHub. Please note that this level is designed to encourage you to add a valid contribution to Githug, not testing your ability to create a pull request. Contributions that are likely to be accepted are levels, bug fixes and improved documentation." solution do location = "/tmp/githug" diff --git a/levels/diff.rb b/levels/diff.rb index cc662fee..0cb7ac26 100644 --- a/levels/diff.rb +++ b/levels/diff.rb @@ -1,5 +1,5 @@ difficulty 2 -description "There have been modifications to the `app.rb` file since your last commit. Find out which line has changed." +description "There have been modifications to the `app.rb` file since your last commit. Find out which line has changed." setup do init_from_level @@ -12,5 +12,5 @@ end hint do - puts "You are looking for the difference since your last commit. Don't forget that running `git` on its own will list the possible commands." + puts "You are looking for the difference since your last commit. Don't forget that running `git` on its own will list the possible commands." end diff --git a/levels/fetch.rb b/levels/fetch.rb index 2f3b2083..2b39013b 100644 --- a/levels/fetch.rb +++ b/levels/fetch.rb @@ -10,7 +10,7 @@ # local repo repo.init - #adds a file to origin/master + # adds a file to origin/master FileUtils.touch "master_file" repo.add "master_file" repo.commit_all 'Commits master_file' @@ -19,12 +19,12 @@ Dir.chdir tmpdir repo.init - #adds a file to origin/master + # adds a file to origin/master FileUtils.touch "master_file" repo.add "master_file" repo.commit_all 'Commits master_file' - #adds remote repo + # adds remote repo Dir.chdir cwd `git remote add origin #{tmpdir}/.git` `git fetch origin --quiet` @@ -45,13 +45,12 @@ repo.init result = true - # counts the number of local branches. Should equal 1 local_branches = repo.branches.size # after a git fetch command, each branch will be stored in in the .git/FETCH_HEAD file. Each branch is on its own line # This command will count the number of lines, which will give the number of branches - if File.file?('.git/FETCH_HEAD') #checks for file existance + if File.file?('.git/FETCH_HEAD') # checks for file existence num_remote = File.read(".git/FETCH_HEAD").split("\n").count else num_remote = 0 diff --git a/levels/find_old_branch.rb b/levels/find_old_branch.rb index b107df5c..f195f68e 100644 --- a/levels/find_old_branch.rb +++ b/levels/find_old_branch.rb @@ -1,5 +1,5 @@ difficulty 4 -description "You have been working on a branch but got distracted by a major issue and forgot the name of it. Switch back to that branch." +description "You have been working on a branch but got distracted by a major issue. Switch back to that branch even though you forgot the name of it." setup do init_from_level diff --git a/levels/ignore.rb b/levels/ignore.rb index 9689fb7f..407772d8 100644 --- a/levels/ignore.rb +++ b/levels/ignore.rb @@ -1,5 +1,5 @@ difficulty 2 -description "The text editor 'vim' creates files ending in `.swp` (swap files) for all files that are currently open. We don't want them creeping into the repository. Make this repository ignore those swap files which are ending in `.swp`." +description "The text editor 'vim' creates files ending in `.swp` (swap files) for all files that are currently open. We don't want them creeping into the repository. Make this repository ignore those swap files which are ending in `.swp`." setup do repo.init diff --git a/levels/include.rb b/levels/include.rb index 2c537a25..9f0334b5 100644 --- a/levels/include.rb +++ b/levels/include.rb @@ -1,5 +1,5 @@ difficulty 2 -description "Notice a few files with the '.a' extension. We want git to ignore all but the 'lib.a' file." +description "Notice a few files with the '.a' extension. We want git to ignore all but the 'lib.a' file." setup do repo.init diff --git a/levels/log.rb b/levels/log.rb index a39a6a04..d2615d6a 100644 --- a/levels/log.rb +++ b/levels/log.rb @@ -1,6 +1,6 @@ difficulty 2 -description "You will be asked for the hash of most recent commit. You will need to investigate the logs of the repository for this." +description "Find out what the hash of the latest commit is." setup do repo.init @@ -14,5 +14,5 @@ end hint do - puts "You need to investigate the logs. There is probably a command for doing that!" + puts "You need to investigate the logs. There is probably a command for doing that!" end diff --git a/levels/number_of_files_committed.rb b/levels/number_of_files_committed.rb index 1977c29d..de52b9c8 100644 --- a/levels/number_of_files_committed.rb +++ b/levels/number_of_files_committed.rb @@ -1,30 +1,30 @@ difficulty 1 -description "There are some files in this repository, how many of the files will be committed?" +description "There are some files in this repository, how many of the files are staged for a commit?" setup do repo.init - #Modified files + # Modified files %w{rubyfile4.rb rubyfile5.rb}.each do |file| FileUtils.touch(file) repo.add(file) end repo.commit_all "Commit" - #Staged file + # Staged file File.open("rubyfile4.rb", 'w') { |f| f << "#Changes" } repo.add("rubyfile4.rb") - #Not staged file + # Not staged file File.open("rubyfile5.rb", 'w') { |f| f << "#Changes" } - #Changes to be committed + # Changes to be committed %w{rubyfile1.rb}.each do |file| FileUtils.touch(file) repo.add(file) end - #Untrached files + # Untracked files %w{rubyfile6.rb rubyfile7.rb}.each do |file| FileUtils.touch(file) end diff --git a/levels/push_branch.rb b/levels/push_branch.rb index 7f0a0a91..0a5ac8ee 100644 --- a/levels/push_branch.rb +++ b/levels/push_branch.rb @@ -1,5 +1,5 @@ difficulty 2 -description "You've made some changes to a local branch and want to share it, but aren't yet ready to merge it with the 'master' branch. Push only 'test_branch' to the remote repository" +description "You've made some changes to a local branch and want to share it, but aren't yet ready to merge it with the 'master' branch. Push only 'test_branch' to the remote repository" setup do @@ -18,12 +18,12 @@ # copy the repo to remote FileUtils.cp_r ".", tmpdir - # add another file. If successful this file won't be pushed to the remote repository + # add another file. If successful this file won't be pushed to the remote repository FileUtils.touch "file2" repo.add "file2" repo.commit_all "If this commit gets pushed to repo, then you have lost the level :( " - #This branch should not be pushed to to the remote repository + # This branch should not be pushed to to the remote repository `git checkout -b other_branch --quiet` # add another file FileUtils.touch "file3" @@ -32,7 +32,7 @@ `git checkout -b test_branch --quiet` - #This file should get pushed if the level is successful + # This file should get pushed if the level is successful FileUtils.touch "file4" repo.add "file4" repo.commit_all "committed change on test_branch" @@ -51,30 +51,30 @@ `git fetch --quiet origin` `git branch -u origin/master master 2> /dev/null` - `git checkout master --quiet` #return to master branch + `git checkout master --quiet` # return to master branch end solution do repo.init result = false - #each branch consits of one line, `wc -l counts the number of lines in order to get the number of remote branches` - #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 + # each branch consists of one line, `wc -l` counts the number of lines in order to get the number of remote branches + # 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 num_remote_branches = `git branch -r`.split("\n").count # counts the number of commits in the remote master branch' remote_master_commits = repo.commits('origin/master').count - remote_test_branch_commits = repo.commits('origin/test_branch').count #if returns 0 indicates that the remote test_branch doesn't exist + remote_test_branch_commits = repo.commits('origin/test_branch').count # if returns 0 indicates that the remote test_branch doesn't exist - #Level will be successful if the remote master branch remains at 1 commit, the remote test_branch exits and the number of remote branches + # Level will be successful if the remote master branch remains at 1 commit, the remote test_branch and only 2 remote branches exists if remote_master_commits == 1 and remote_test_branch_commits > 0 and num_remote_branches == 2 result = true - #User pushed up too many branches, level failed + # User pushed up too many branches, level failed elsif num_remote_branches > 2 puts "*** It looks like you pushed up too many branches. You need to make sure only 'test_branch' gets pushed. Please try again! ***" - #User pushed up the master banch, level failed + # User pushed up the master branch, level failed elsif remote_master_commits > 1 puts "*** It looks like you pushed up new master branch changes. You need to make sure only 'test_branch' gets pushed. Please try again! ***" end diff --git a/levels/remote.rb b/levels/remote.rb index 51568607..74520a95 100644 --- a/levels/remote.rb +++ b/levels/remote.rb @@ -1,6 +1,6 @@ difficulty 2 -description "This project has a remote repository. Identify it." +description "This project has a remote repository. Identify it." setup do repo.init @@ -12,5 +12,5 @@ end hint do - puts "You are looking for a remote. You can run `git` for a list of commands." + puts "You are looking for a remote. You can run `git` for a list of commands." end diff --git a/levels/remote_url.rb b/levels/remote_url.rb index dc15367b..128c792c 100644 --- a/levels/remote_url.rb +++ b/levels/remote_url.rb @@ -1,6 +1,6 @@ difficulty 2 -description "The remote repositories have a url associated to them. Please enter the url of remote_location." +description "The remote repositories have a url associated to them. Please enter the url of remote_location." setup do repo.init diff --git a/levels/reset.rb b/levels/reset.rb index de95b1ca..e1dcee8d 100644 --- a/levels/reset.rb +++ b/levels/reset.rb @@ -1,5 +1,5 @@ difficulty 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)." +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)." setup do repo.init diff --git a/levels/restore.rb b/levels/restore.rb index da0272de..a1f93e29 100644 --- a/levels/restore.rb +++ b/levels/restore.rb @@ -1,5 +1,5 @@ difficulty 4 -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." +description "You decided to delete your latest commit by running `git reset --hard HEAD^` (not a smart thing to do). Now you changed your mind and want that commit back. Restore the deleted commit." setup do repo.init @@ -24,5 +24,5 @@ end hint do - puts "The commit is still floating around somewhere. Have you checked out `git reflog`?" + puts "The commit is still floating around somewhere. Have you checked out `git reflog`?" end diff --git a/levels/restructure.rb b/levels/restructure.rb index 78492b27..ccab8d2e 100644 --- a/levels/restructure.rb +++ b/levels/restructure.rb @@ -1,6 +1,6 @@ difficulty 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." +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 use Git move all of the .html files into this folder." setup do repo.init diff --git a/levels/revert.rb b/levels/revert.rb index 8ad2a0a6..da123c5c 100644 --- a/levels/revert.rb +++ b/levels/revert.rb @@ -1,6 +1,5 @@ difficulty 4 -description "You have committed several times but want to undo the middle commit. -All commits have been pushed, so you can't change existing history." +description "You have committed several times but want to undo the middle commit. All commits have been pushed, so you can't change existing history." setup do repo.init diff --git a/levels/rm.rb b/levels/rm.rb index 8ee563b5..ed60d339 100644 --- a/levels/rm.rb +++ b/levels/rm.rb @@ -1,6 +1,6 @@ difficulty 2 -description "A file has been removed from the working tree, however the file was not removed from the repository. Find out what this file was and remove it." +description "A file has been removed from the working tree, however the file was not removed from the repository. Find out what this file was and remove it." setup do repo.init diff --git a/levels/rm_cached.rb b/levels/rm_cached.rb index a6d29c27..3487523a 100644 --- a/levels/rm_cached.rb +++ b/levels/rm_cached.rb @@ -1,6 +1,6 @@ difficulty 2 -description "A file has accidentally been added to your staging area, find out which file and remove it from the staging area. *NOTE* Do not remove the file from the file system, only from git." +description "A file has accidentally been added to your staging area, find out which file and remove it from the staging area. *NOTE* Do not remove the file from the file system, only from git." setup do repo.init @@ -14,5 +14,5 @@ end hint do - puts "You may need to use more than one command to complete this. You have checked your staging area in a previous level. Don't forget to run `git` for a list of commands." + puts "You may need to use more than one command to complete this. You have checked your staging area in a previous level. Don't forget to run `git` for a list of commands." end diff --git a/levels/squash.rb b/levels/squash.rb index 64559e35..1848425b 100644 --- a/levels/squash.rb +++ b/levels/squash.rb @@ -25,5 +25,5 @@ end hint do - puts "Take a look the `-i` flag of the rebase command." + puts "Take a look at the `-i` flag of the rebase command." end diff --git a/levels/stage_lines.rb b/levels/stage_lines.rb index 8a0bb5de..2c49c652 100644 --- a/levels/stage_lines.rb +++ b/levels/stage_lines.rb @@ -25,5 +25,5 @@ end hint do - puts "You might want to try to manipulate the hunks of the diff to choose which lines of the diff get staged. Read about the flags which can be passed to the `add` command; `man git-add`." + puts "You might want to try to manipulate the hunks of the diff to choose which lines of the diff get staged. Read about the flags which can be passed to the `add` command; `git --help add`." end diff --git a/levels/stash.rb b/levels/stash.rb index 3e9817e4..857eebbb 100644 --- a/levels/stash.rb +++ b/levels/stash.rb @@ -12,5 +12,5 @@ end hint do - puts "It's like stashing. Try finding appropriate git command." + puts "It's like stashing. Try finding an appropriate git command." end diff --git a/levels/status.rb b/levels/status.rb index 44a3f30e..fddb0dbe 100644 --- a/levels/status.rb +++ b/levels/status.rb @@ -1,5 +1,5 @@ difficulty 1 -description "There are some files in this repository, one of the files is untracked, which file is it?" +description "There are some files in this repository, but only one of them is untracked. Which file is it?" setup do repo.init From d701a11f779fe483887d0c1c7f23a643123ced08 Mon Sep 17 00:00:00 2001 From: Jack Aponte Date: Sat, 15 Jun 2019 03:32:51 -0700 Subject: [PATCH 040/115] Clarify that reset task can be used to select a specific level in short desc (#259) --- lib/githug/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/githug/cli.rb b/lib/githug/cli.rb index 31306568..36e165a0 100644 --- a/lib/githug/cli.rb +++ b/lib/githug/cli.rb @@ -32,7 +32,7 @@ def hint end end - desc :reset, "Reset the current level" + desc :reset, "Reset the current level or select specific level" long_desc <<-LONGDESC `githug reset` will reset the current level. You can optionally specify a LEVEL parameter which will reset the game to a specific level. For From 2db7ee6082d34af23cf37329db7b3a35b795ee9a Mon Sep 17 00:00:00 2001 From: Oliver Sartun Date: Tue, 3 Sep 2019 09:51:20 +0200 Subject: [PATCH 041/115] Fix git help command in hint (#263) The hint says to use `git gitignore --help`, but that doesn't work. ``` git: 'gitignore' is not a git command. See 'git --help'. ``` Instead, the command that does work is `git help gitignore`. --- levels/include.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/include.rb b/levels/include.rb index 9f0334b5..5ee6ce5c 100644 --- a/levels/include.rb +++ b/levels/include.rb @@ -17,5 +17,5 @@ end hint do - puts "Using `git gitignore --help`, read about the optional prefix to negate a pattern." + puts "Using `git help gitignore`, read about the optional prefix to negate a pattern." end From 69b6a7816ba4f27d27e4ddec075cef7f25a9c909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Navarro?= Date: Tue, 1 Oct 2019 09:45:43 +0200 Subject: [PATCH 042/115] Listing the levels, it show the solved levels in green and the pending ones in red. (#264) --- lib/githug/cli.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/githug/cli.rb b/lib/githug/cli.rb index 36e165a0..6b5e4b82 100644 --- a/lib/githug/cli.rb +++ b/lib/githug/cli.rb @@ -54,13 +54,21 @@ def reset(path = nil) end end - desc :levels, "List all of the levels" + desc :levels, "List all of the levels (green passed, red pending)" def levels - list_with_numbers = Level.list.each_with_index.map do |name, index| - "##{index + 1}: #{name}" + level = load_level_from_profile + pending = false + Level.list.each_with_index.map do |name, index| + if index + 1 == level.level_no + pending = true + end + if !pending + UI.success("##{index + 1}: #{name}") + else + UI.error("##{index + 1}: #{name}") + end end - UI.puts(list_with_numbers) end no_tasks do From e6c3f8d357c03db1c82d9e4c56d30ca81850bbed Mon Sep 17 00:00:00 2001 From: Jesse Hurdle Date: Mon, 11 Nov 2019 05:14:40 -0500 Subject: [PATCH 043/115] Make hint more helpful (lvl 20) (#267) (closes issue #265) --- levels/commit_in_future.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/commit_in_future.rb b/levels/commit_in_future.rb index 7395fc27..b49011fc 100644 --- a/levels/commit_in_future.rb +++ b/levels/commit_in_future.rb @@ -15,5 +15,5 @@ end hint do - puts "Build a time machine, move to the future and commit your changes, then go back and verify results ;)." + puts "Build a time machine, and commit --date \"future\"." end From a387bb37ff98447d60f51a55cc26352f7ea93c4d Mon Sep 17 00:00:00 2001 From: Mayuri Lahane Date: Mon, 8 Jun 2020 15:35:40 +0530 Subject: [PATCH 044/115] Suggestion for level_8 Description (#274) --- levels/include.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/include.rb b/levels/include.rb index 5ee6ce5c..906c6a36 100644 --- a/levels/include.rb +++ b/levels/include.rb @@ -1,5 +1,5 @@ difficulty 2 -description "Notice a few files with the '.a' extension. We want git to ignore all but the 'lib.a' file." +description "Notice a few files with the '.a' extension. We want git to ignore all the files except the 'lib.a' file." setup do repo.init From a760da2d713b4ba432b8ffbe509a030cb6411d85 Mon Sep 17 00:00:00 2001 From: Germain Chazot Date: Thu, 17 Sep 2020 11:00:05 +0100 Subject: [PATCH 045/115] Fix rename_commit level solution (#276) Fixes #258 The problem is that `repo.commits` as an array is not necessarily ordered by parent commits. So `repo.commits[1]` could virtually be any commit in the repo. As an exemple, here is what I get: ```ruby puts repo.commits[0].message puts repo.commits[1].message puts repo.commits[2].message ``` -> BEFORE `rebase -i`: ``` Initial commit First coommit Second commit ``` -> AFTER `rebase -i` and renaming the middle commit: ``` Second commit Initial commit First commit ``` This fix ensures that we look at the parent of the latest commit. --- levels/rename_commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/rename_commit.rb b/levels/rename_commit.rb index f5d6cb9c..4c8ecd93 100644 --- a/levels/rename_commit.rb +++ b/levels/rename_commit.rb @@ -17,7 +17,7 @@ end solution do - repo.commits[1].message == "First commit" + repo.commits.first.parents[0].message == "First commit" end hint do From 95ab0a8b31e21b2fb3f19e45f11e48bc78d06e4e Mon Sep 17 00:00:00 2001 From: Devidas Gaikwad Date: Tue, 10 Nov 2020 20:30:18 +0530 Subject: [PATCH 046/115] Updating hint message (#285) --- levels/commit_in_future.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/commit_in_future.rb b/levels/commit_in_future.rb index b49011fc..da5079c0 100644 --- a/levels/commit_in_future.rb +++ b/levels/commit_in_future.rb @@ -15,5 +15,5 @@ end hint do - puts "Build a time machine, and commit --date \"future\"." + puts "Build a time format, and commit your code using --date parameter for \"future\"." end From c8cdaef72b15c20bf78bfc5025083c7d8bf911d8 Mon Sep 17 00:00:00 2001 From: Ajoe-T <62591849+Ajoe-T@users.noreply.github.com> Date: Tue, 10 Nov 2020 20:30:56 +0530 Subject: [PATCH 047/115] Added more clear hint (#283) --- levels/cherry-pick.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/cherry-pick.rb b/levels/cherry-pick.rb index cf382a4b..96acc4e0 100644 --- a/levels/cherry-pick.rb +++ b/levels/cherry-pick.rb @@ -13,5 +13,5 @@ end hint do - puts "Sneak a peek at the `cherry-pick` command." + puts "Sneak a peek at the `git help cherry-pick` command." end From f36bdf339d631e1319ccfa90255ac658b4f90052 Mon Sep 17 00:00:00 2001 From: Conner Nilsen Date: Tue, 22 Dec 2020 03:59:29 -0800 Subject: [PATCH 048/115] Checkout file from branch (#287) * Add checkout_file_from_branch level * Add integration test for checkout_file_from_branch and add level to levels array * Write to files using File.write instead of echo --- levels/checkout_file_from_branch.rb | 35 +++++++++++++++++++++++++++++ lib/githug/level.rb | 2 +- spec/githug_spec.rb | 5 +++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 levels/checkout_file_from_branch.rb diff --git a/levels/checkout_file_from_branch.rb b/levels/checkout_file_from_branch.rb new file mode 100644 index 00000000..c760c838 --- /dev/null +++ b/levels/checkout_file_from_branch.rb @@ -0,0 +1,35 @@ +difficulty 2 +description "Grab the fixed app.rb file from the feature branch into master, but don't get the README.md file from that branch. Try to do it without copying it manually!" + +setup do + repo.init + FileUtils.touch("app.rb") + FileUtils.touch("README.md") + repo.add("app.rb") + File.write("app.rb", "Some buggy code") + repo.add("README.md") + File.write("README.md", "Hey! This is the master branch.") + repo.commit_all("Initial commit") + + repo.git.native :checkout, {"b" => true}, 'other_branch' + File.write("app.rb", "Fixed code") + File.write("README.md", "Hey! This is the other_branch branch, and we don't want this to be included in master!") + repo.add("app.rb") + repo.add("README.md") + repo.commit_all("Some more changes") + + repo.git.native :checkout, {}, 'master' +end + +solution do + return false unless repo.head.name == "master" + readme = File.read("README.md").gsub('"', '').strip + return false unless readme == "Hey! This is the master branch." + app = File.read("app.rb").gsub('"', '').strip + return false unless app == "Fixed code" + true +end + +hint do + puts "The checkout command is gonna be useful here." +end diff --git a/lib/githug/level.rb b/lib/githug/level.rb index 051d1738..2d0ca8f9 100644 --- a/lib/githug/level.rb +++ b/lib/githug/level.rb @@ -8,7 +8,7 @@ class Level "restructure", "log", "tag", "push_tags", "commit_amend", "commit_in_future", "reset", "reset_soft", "checkout_file", "remote", "remote_url", "pull", "remote_add", "push", "diff", "blame", "branch", - "checkout", "checkout_tag", "checkout_tag_over_branch", "branch_at", + "checkout", "checkout_tag", "checkout_tag_over_branch", "checkout_file_from_branch", "branch_at", "delete_branch", "push_branch", "merge", "fetch", "rebase", "rebase_onto", "repack", "cherry-pick", "grep", "rename_commit", "squash", "merge_squash", "reorder", "bisect", "stage_lines", "find_old_branch", "revert", "restore", "conflict", diff --git a/spec/githug_spec.rb b/spec/githug_spec.rb index 988892b9..880e17c1 100644 --- a/spec/githug_spec.rb +++ b/spec/githug_spec.rb @@ -153,6 +153,11 @@ def skip_level `githug`.should be_solved end + it "solves the checkout_file_from_branch level" do + `git checkout other_branch -- app.rb` + `githug`.should be_solved + end + it "solves the remove level" do `git remote | githug`.should be_solved end From e71c4c10dbafffee86007ffbe70da81d95a2a87f Mon Sep 17 00:00:00 2001 From: stdtom Date: Mon, 26 Jul 2021 22:11:45 +0200 Subject: [PATCH 049/115] Revert "Checkout file from branch (#287)" This reverts commit f36bdf339d631e1319ccfa90255ac658b4f90052. --- levels/checkout_file_from_branch.rb | 35 ----------------------------- lib/githug/level.rb | 2 +- spec/githug_spec.rb | 5 ----- 3 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 levels/checkout_file_from_branch.rb diff --git a/levels/checkout_file_from_branch.rb b/levels/checkout_file_from_branch.rb deleted file mode 100644 index c760c838..00000000 --- a/levels/checkout_file_from_branch.rb +++ /dev/null @@ -1,35 +0,0 @@ -difficulty 2 -description "Grab the fixed app.rb file from the feature branch into master, but don't get the README.md file from that branch. Try to do it without copying it manually!" - -setup do - repo.init - FileUtils.touch("app.rb") - FileUtils.touch("README.md") - repo.add("app.rb") - File.write("app.rb", "Some buggy code") - repo.add("README.md") - File.write("README.md", "Hey! This is the master branch.") - repo.commit_all("Initial commit") - - repo.git.native :checkout, {"b" => true}, 'other_branch' - File.write("app.rb", "Fixed code") - File.write("README.md", "Hey! This is the other_branch branch, and we don't want this to be included in master!") - repo.add("app.rb") - repo.add("README.md") - repo.commit_all("Some more changes") - - repo.git.native :checkout, {}, 'master' -end - -solution do - return false unless repo.head.name == "master" - readme = File.read("README.md").gsub('"', '').strip - return false unless readme == "Hey! This is the master branch." - app = File.read("app.rb").gsub('"', '').strip - return false unless app == "Fixed code" - true -end - -hint do - puts "The checkout command is gonna be useful here." -end diff --git a/lib/githug/level.rb b/lib/githug/level.rb index 2d0ca8f9..051d1738 100644 --- a/lib/githug/level.rb +++ b/lib/githug/level.rb @@ -8,7 +8,7 @@ class Level "restructure", "log", "tag", "push_tags", "commit_amend", "commit_in_future", "reset", "reset_soft", "checkout_file", "remote", "remote_url", "pull", "remote_add", "push", "diff", "blame", "branch", - "checkout", "checkout_tag", "checkout_tag_over_branch", "checkout_file_from_branch", "branch_at", + "checkout", "checkout_tag", "checkout_tag_over_branch", "branch_at", "delete_branch", "push_branch", "merge", "fetch", "rebase", "rebase_onto", "repack", "cherry-pick", "grep", "rename_commit", "squash", "merge_squash", "reorder", "bisect", "stage_lines", "find_old_branch", "revert", "restore", "conflict", diff --git a/spec/githug_spec.rb b/spec/githug_spec.rb index 880e17c1..988892b9 100644 --- a/spec/githug_spec.rb +++ b/spec/githug_spec.rb @@ -153,11 +153,6 @@ def skip_level `githug`.should be_solved end - it "solves the checkout_file_from_branch level" do - `git checkout other_branch -- app.rb` - `githug`.should be_solved - end - it "solves the remove level" do `git remote | githug`.should be_solved end From c7a3e021076bad6a74ed5600022612384870bb4e Mon Sep 17 00:00:00 2001 From: stdtom Date: Mon, 26 Jul 2021 22:12:16 +0200 Subject: [PATCH 050/115] Revert "Listing the levels, it show the solved levels in green and the pending ones in red. (#264)" This reverts commit 69b6a7816ba4f27d27e4ddec075cef7f25a9c909. --- lib/githug/cli.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/githug/cli.rb b/lib/githug/cli.rb index 6b5e4b82..36e165a0 100644 --- a/lib/githug/cli.rb +++ b/lib/githug/cli.rb @@ -54,21 +54,13 @@ def reset(path = nil) end end - desc :levels, "List all of the levels (green passed, red pending)" + desc :levels, "List all of the levels" def levels - level = load_level_from_profile - pending = false - Level.list.each_with_index.map do |name, index| - if index + 1 == level.level_no - pending = true - end - if !pending - UI.success("##{index + 1}: #{name}") - else - UI.error("##{index + 1}: #{name}") - end + list_with_numbers = Level.list.each_with_index.map do |name, index| + "##{index + 1}: #{name}" end + UI.puts(list_with_numbers) end no_tasks do From f830b1b9931f9580c801d42b104739ac5d7c63f9 Mon Sep 17 00:00:00 2001 From: stdtom Date: Mon, 26 Jul 2021 22:22:12 +0200 Subject: [PATCH 051/115] Removing old Ruby versions (1.8.7 and 1.9.2) from CI Versions have been end-of-life for more than 6 years and causing CI to fail for more than 2 years now. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e5588188..1b29fb4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: ruby rvm: - - 1.8.7 - - 1.9.2 - 1.9.3 - 2.0.0 - 2.1 From a251d1bc45497a303e145e42079326f2f9a7faa0 Mon Sep 17 00:00:00 2001 From: stdtom Date: Mon, 26 Jul 2021 23:03:12 +0200 Subject: [PATCH 052/115] Lift CI on new versions - new ci distro (Ubuntu 20.04 instead of 16.04 - newer Ruby versions --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1b29fb4a..c9fbee79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,14 @@ language: ruby - +dist: focal rvm: - 1.9.3 - 2.0.0 - 2.1 + - 2.4.10 + - 2.5.9 + - 2.6.8 + - 2.7.4 + - 3.0.1 - ruby-head matrix: From 13f9f1f0e1c5e9464027b1023ae9e70e3a653a02 Mon Sep 17 00:00:00 2001 From: stdtom Date: Mon, 26 Jul 2021 23:12:34 +0200 Subject: [PATCH 053/115] Remove Ruby versions unsupported on Ubuntu 20.04 --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9fbee79..d3f11e4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: ruby dist: focal rvm: - - 1.9.3 - - 2.0.0 - - 2.1 - 2.4.10 - 2.5.9 - 2.6.8 From 9a739d34a17e8cb4c8e8cee38f3a7f84af9105f9 Mon Sep 17 00:00:00 2001 From: stdtom Date: Mon, 26 Jul 2021 23:13:25 +0200 Subject: [PATCH 054/115] Remove locking of RubyGems to version 2.1.11 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d3f11e4f..78f7bef0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,6 @@ matrix: - rvm: ruby-head before_install: - - gem update --system 2.1.11 + - gem update --system - git config --global user.email 'user@example.com' - git config --global user.name 'Test User' From 90f741bebc8bcb8e6097f840edebc0ef9cbdd090 Mon Sep 17 00:00:00 2001 From: odiraneyya <66945713+odiraneyya@users.noreply.github.com> Date: Wed, 16 Mar 2022 15:12:40 +0100 Subject: [PATCH 055/115] Classroom concept, issue #313 (#314) * Classroom concept, issue #313 * Improved classroom concept documentation * Removed teaching instructions, linked to DockerHub * Update README.md * Update README.md Co-authored-by: Gary Rennie --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ README.md | 6 ++++++ 2 files changed, 41 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7d36bf69 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM ruby:slim + +LABEL org.opencontainers.image.authors="diraneyya@ip.rwth-aachen.de" + +RUN apt update && apt install -y git + +ENV DATA_PATH="/data" +ENV REPO_PATH="/root/githug" +ENV LEVEL_PATH="/git_hug" +ENV GITHUG_PROFILE_INPUT="$LEVEL_PATH/.profile.yml" +ENV GITHUG_HISTORY_OUTPUT="$DATA_PATH/history.txt" +ENV GITHUG_PROFILE_OUTPUT="$DATA_PATH/profile.yml" + +RUN mkdir -p $DATA_PATH +ADD . $REPO_PATH +WORKDIR $REPO_PATH +RUN gem build +RUN gem install *.gem + +WORKDIR / +RUN echo "y" | $GEM_HOME/bin/githug + +WORKDIR $LEVEL_PATH + +RUN printf "history -c\nHISTSIZE= \nHISTFILESIZE= \n\ +echo '--- NEW SESSION ---' >> $GITHUG_HISTORY_OUTPUT\n\ +export PATH=\"\$GEM_HOME/bin:\$PATH\"\ngithug reset\n" >> ~/.bashrc + +RUN printf "history -a\ncat \$HISTFILE >> $GITHUG_HISTORY_OUTPUT\n\ +cp $GITHUG_PROFILE_INPUT $GITHUG_PROFILE_OUTPUT" >> ~/.bash_logout +RUN printf ". ~/.bashrc\n" > ~/.bash_profile + +ENTRYPOINT ["/bin/bash", "--login"] +VOLUME $LEVEL_PATH +VOLUME $DATA_PATH diff --git a/README.md b/README.md index c158adbb..116ccdc9 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,10 @@ To install Githug, run If you get a complaint about permissions, you can rerun the command with `sudo`: sudo gem install githug + +#### Usage with Docker + +An unofficial _Docker_ image for this project by [@odiraneyya](https://github.com/odiraneyya) is available on ([Docker Hub](https://hub.docker.com/r/orwa84/githug)). ### Starting the Game @@ -148,3 +152,5 @@ The easiest way to test a level is: Please note that the `githug test` command can be run as `githug test --errors` to get an error stack trace from your solve method. It would be ideal if you add an integration test for your level. These tests live in `spec/githug_spec` and **must** be run in order. If you add a level but do not add a test, please add a simple `skip_level` test case similar to the `contribute` level. + + From c3bc5a19d9296b86c4a907a9e5960411dce7d0a7 Mon Sep 17 00:00:00 2001 From: odiraneyya <66945713+odiraneyya@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:10:52 +0100 Subject: [PATCH 056/115] Added gitconfig to deliverables and removed level-folder volume (#317) --- Dockerfile | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d36bf69..6d785eb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,14 +2,26 @@ FROM ruby:slim LABEL org.opencontainers.image.authors="diraneyya@ip.rwth-aachen.de" -RUN apt update && apt install -y git +# This is in order to have the man pages during exercises +RUN sed -i '/path-exclude \/usr\/share\/man/d' /etc/dpkg/dpkg.cfg.d/docker +RUN sed -i '/path-exclude \/usr\/share\/groff/d' /etc/dpkg/dpkg.cfg.d/docker +RUN apt update && apt install -y man git && apt install --reinstall coreutils +# The DATA_PATH is used for the deliverables, or the submissible +# content for the classroom activity. ENV DATA_PATH="/data" +# The REPO_PATH is where the original or the teacher's forked repo +# resides inside the container. ENV REPO_PATH="/root/githug" +# The LEVEL_PATH is where the current challenge resides and where +# students should navigate prior to attemping to use the `githug` +# commands. ENV LEVEL_PATH="/git_hug" -ENV GITHUG_PROFILE_INPUT="$LEVEL_PATH/.profile.yml" +ENV GITHUG_GITCONF="/root/.gitconfig" +ENV GITHUG_PROFILE="$LEVEL_PATH/.profile.yml" ENV GITHUG_HISTORY_OUTPUT="$DATA_PATH/history.txt" ENV GITHUG_PROFILE_OUTPUT="$DATA_PATH/profile.yml" +ENV GITHUG_GITCONF_OUTPUT="$DATA_PATH/gitconfig" RUN mkdir -p $DATA_PATH ADD . $REPO_PATH @@ -19,17 +31,29 @@ RUN gem install *.gem WORKDIR / RUN echo "y" | $GEM_HOME/bin/githug +RUN cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT WORKDIR $LEVEL_PATH +# The bash login script in below clears the history and restores +# progress using the contents of the $GITHUG_PROFILE_OUTPUT file. RUN printf "history -c\nHISTSIZE= \nHISTFILESIZE= \n\ -echo '--- NEW SESSION ---' >> $GITHUG_HISTORY_OUTPUT\n\ -export PATH=\"\$GEM_HOME/bin:\$PATH\"\ngithug reset\n" >> ~/.bashrc - -RUN printf "history -a\ncat \$HISTFILE >> $GITHUG_HISTORY_OUTPUT\n\ -cp $GITHUG_PROFILE_INPUT $GITHUG_PROFILE_OUTPUT" >> ~/.bash_logout -RUN printf ". ~/.bashrc\n" > ~/.bash_profile +echo '--- NEW SESSION ---' >> $GITHUG_HISTORY_OUTPUT \n\ +if ! [ -e $GITHUG_PROFILE_OUTPUT ]; then \n\ + echo 'ERROR: Corrupt level progress data. Exiting.' \n\ + echo '>>> CORRUPT DATA <<<' >> $GITHUG_HISTORY_OUTPUT \n\ + exit 1; fi \n\ +cp $GITHUG_GITCONF_OUTPUT $GITHUG_GITCONF \n\ +mkdir -p $LEVEL_PATH && cp $GITHUG_PROFILE_OUTPUT $GITHUG_PROFILE \n\ +export PATH=\"\$GEM_HOME/bin:\$PATH\" \n\ +cd $LEVEL_PATH && githug reset \n\ +echo -e '\nIMPORTANT: everything you type in this container is \ +recorded to assist in the grading process.' \n" >> ~/.bash_profile + +RUN printf "history -a\ncat \$HISTFILE >> $GITHUG_HISTORY_OUTPUT \n\ +cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n\ +cp $GITHUG_GITCONF $GITHUG_GITCONF_OUTPUT 2>/dev/null \n\ +cp $GITHUG_PROFILE $GITHUG_PROFILE_OUTPUT \n" >> ~/.bash_logout ENTRYPOINT ["/bin/bash", "--login"] -VOLUME $LEVEL_PATH VOLUME $DATA_PATH From b78c39d5a9efaa54a3958e7d6c36e2546ceaf48a Mon Sep 17 00:00:00 2001 From: Rahul Goel <211220042@nitdelhi.ac.in> Date: Fri, 13 Oct 2023 21:35:55 +0530 Subject: [PATCH 057/115] added FAQ to fix main and master branch name issue (#342) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 116ccdc9..ae8ace08 100644 --- a/README.md +++ b/README.md @@ -153,4 +153,8 @@ Please note that the `githug test` command can be run as `githug test --errors` It would be ideal if you add an integration test for your level. These tests live in `spec/githug_spec` and **must** be run in order. If you add a level but do not add a test, please add a simple `skip_level` test case similar to the `contribute` level. +## FAQs +1. Answers are not being checked properly + + *This is a common issue we are facing and we are actively working to fix it. In the mean time, You can run this command, `git branch -m master` and continue with the levels. The issue arises because of the recent git update of calling the default branch `main` instead of `master`. Happy Learning!* From 90574f4ab4eeb6d515a212c5d59fb70ced8f4653 Mon Sep 17 00:00:00 2001 From: Jeremie Dsouza <92860009+Stowaway4331@users.noreply.github.com> Date: Wed, 1 Nov 2023 06:21:30 +0000 Subject: [PATCH 058/115] Added fix for 'main doesn't work' issue --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ae8ace08..69dd3afc 100644 --- a/README.md +++ b/README.md @@ -157,4 +157,31 @@ It would be ideal if you add an integration test for your level. These tests li 1. Answers are not being checked properly - *This is a common issue we are facing and we are actively working to fix it. In the mean time, You can run this command, `git branch -m master` and continue with the levels. The issue arises because of the recent git update of calling the default branch `main` instead of `master`. Happy Learning!* + *This is a common issue we are facing and we are actively working to fix it.* + + For now, run the following commands to change the default branch name to master. This should fix most of the issues you may face. + ``` + $ git config --global init.defaultBranch master + $ githug reset + ``` + + From the current level forward, the default branch will be `master`. + +2. `githug` command doesn't work + + Githug currently isn't supported on ruby versions ^3.0.0. Use any ruby version below 3.0.0 (preferrably 2.7.1). + + If you use rvm, execute the below commands + + ``` + $ rvm install 2.7.1 + $ rvm use 2.7.1 + ``` + + If you use rbenv, execute the below commands + + ``` + $ rbenv install 2.7.1 + $ rbenv global 2.7.1 + ``` + From 411171db0cb34bef55a7b618f71f6af494caa54d Mon Sep 17 00:00:00 2001 From: nbehrnd Date: Mon, 18 Mar 2024 09:57:24 +0100 Subject: [PATCH 059/115] fix(include.rb): correct hint to man page (#347) In git (version 2.43.0), the command to access the corresponding man page differs to the one the hint so far indicated. Signed-off-by: Norwid Behrnd --- levels/include.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/include.rb b/levels/include.rb index 906c6a36..42813aca 100644 --- a/levels/include.rb +++ b/levels/include.rb @@ -17,5 +17,5 @@ end hint do - puts "Using `git help gitignore`, read about the optional prefix to negate a pattern." + puts "Using `git help ignore`, read about the optional prefix to negate a pattern." end From 62edc36baf384a9f0f6aebfacfce0edeabc0721e Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Mon, 8 Apr 2024 15:09:49 +0200 Subject: [PATCH 060/115] fix(commit.rb): explicitly define branch as master Irrespective of a defaultBranch definition in file .gitconfig, the edit allows to pass a commit to be accepted. Signed-off-by: Norwid Behrnd --- levels/commit.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/commit.rb b/levels/commit.rb index 745b03b4..5e836bf8 100644 --- a/levels/commit.rb +++ b/levels/commit.rb @@ -3,6 +3,7 @@ setup do repo.init + system "git branch -m master" FileUtils.touch("README") repo.add("README") end From dc3ba9a847817e0f65b614b6ae9d82a13fc9907b Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:19:37 +0200 Subject: [PATCH 061/115] style(config.rb): edit description of task ahead Signed-off-by: Norwid Behrnd --- levels/config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/config.rb b/levels/config.rb index 489a8060..5a349247 100644 --- a/levels/config.rb +++ b/levels/config.rb @@ -1,5 +1,5 @@ difficulty 1 -description "Set up your git name and email, this is important so that your commits can be identified." +description "Set up your git name and email; this is important so that your commits can be identified." setup do repo.init From 949bb9e303342670de91b0e3d085854a0a490c37 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:24:51 +0200 Subject: [PATCH 062/115] fix(add.rb): explicitly define branch as master Contrasting to the previous version, the name of the principal branch is explicitly defined. The description of the task ahead is lightly edited. Signed-off-by: Norwid Behrnd --- levels/add.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/levels/add.rb b/levels/add.rb index ffb4e162..574dcef6 100644 --- a/levels/add.rb +++ b/levels/add.rb @@ -1,10 +1,11 @@ difficulty 1 -description "There is a file in your folder called `README`, you should add it to your staging area -Note: You start each level with a new repo. Don't look for files from the previous one." +description "There is a file in your folder called `README`; add it to your staging area. +Note: Each level starts with a new repo. Don't look for files of the previous one." setup do repo.init FileUtils.touch("README") + system "git branch -m master" end solution do From 5278bbcf193959f4a620ef0760fc59267201fafe Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:28:24 +0200 Subject: [PATCH 063/115] style(clone_to_folder): edit description of the task ahead Signed-off-by: Norwid Behrnd --- levels/clone_to_folder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/clone_to_folder.rb b/levels/clone_to_folder.rb index 55358fcf..36759e69 100644 --- a/levels/clone_to_folder.rb +++ b/levels/clone_to_folder.rb @@ -1,5 +1,5 @@ difficulty 1 -description "Clone the repository at https://github.com/Gazler/cloneme to `my_cloned_repo`." +description "Clone the repository at https://github.com/Gazler/cloneme into the folder `my_cloned_repo`." solution do repo("my_cloned_repo").commit("157b2b61f29ab9df45f31c7cd9cb5d8ff06ecde4") From 38f8c192228f7a765535b63abb528899c106671e Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:30:07 +0200 Subject: [PATCH 064/115] fix(ignore.rb): explicitly define branch as master Signed-off-by: Norwid Behrnd --- levels/ignore.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/ignore.rb b/levels/ignore.rb index 407772d8..7127295c 100644 --- a/levels/ignore.rb +++ b/levels/ignore.rb @@ -4,6 +4,7 @@ setup do repo.init FileUtils.touch("README.swp") + system "git branch -m master" file = File.open(".git/config", "w") do |file| file.puts "[core]\nexcludesfile=" end From 9cc53a85b96e885da17c7620867b7699592e91e7 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:31:32 +0200 Subject: [PATCH 065/115] fix(include.rb): explicitly define branch as master Signed-off-by: Norwid Behrnd --- levels/include.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/include.rb b/levels/include.rb index 42813aca..7b333be6 100644 --- a/levels/include.rb +++ b/levels/include.rb @@ -6,6 +6,7 @@ FileUtils.touch("first.a") FileUtils.touch("second.a") FileUtils.touch("lib.a") + system "git branch -m master" file = File.open(".git/config", "w") do |file| file.puts "[core]\nexcludesfile=" end From 0ef415176f4897903a450fd1e205e1dba26308e0 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:32:47 +0200 Subject: [PATCH 066/115] fix(status.rb): explicitly define branch as master Explicit definition of the principal branch as master, and a light edit of the description of the task ahead. Signed-off-by: Norwid Behrnd --- levels/status.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/levels/status.rb b/levels/status.rb index fddb0dbe..ad3c79bc 100644 --- a/levels/status.rb +++ b/levels/status.rb @@ -1,10 +1,11 @@ difficulty 1 -description "There are some files in this repository, but only one of them is untracked. Which file is it?" +description "Among the files in this repository, which of them is untracked?" setup do repo.init %w{config.rb README setup.rb deploy.rb Guardfile}.each do |file| FileUtils.touch(file) + system "git branch -m master" repo.add(file) end FileUtils.touch("database.yml") From 26ce22cb6bdd3598d6dddaf17cd9af1d60f33edd Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:35:35 +0200 Subject: [PATCH 067/115] fix(number_of_files_committed): explicitly use master branch Explicitly define the principal branch as master. Light edit of the description of the task ahead and of the hint about the solution. Signed-off-by: Norwid Behrnd --- levels/number_of_files_committed.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/levels/number_of_files_committed.rb b/levels/number_of_files_committed.rb index de52b9c8..a506e65b 100644 --- a/levels/number_of_files_committed.rb +++ b/levels/number_of_files_committed.rb @@ -1,5 +1,5 @@ difficulty 1 -description "There are some files in this repository, how many of the files are staged for a commit?" +description "There are some files in this repository; how many of them are staged for a commit?" setup do repo.init @@ -8,6 +8,7 @@ %w{rubyfile4.rb rubyfile5.rb}.each do |file| FileUtils.touch(file) repo.add(file) + system "git branch -m master" end repo.commit_all "Commit" @@ -47,5 +48,5 @@ end hint do - puts "You are looking for a command to identify the status of the repository, (resembles a linux command)." + puts "You are looking for a command to identify the status of the repository (resembles a Linux command)." end From f7764b55ca133b47e8345c84e0daabcf6ad03715 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:45:42 +0200 Subject: [PATCH 068/115] fix(rm.rb): explicitly define branch as master Explicitly define the principal branch as master. Light edit of the description of the task ahead, light lint of the source code. Signed-off-by: Norwid Behrnd --- levels/rm.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/levels/rm.rb b/levels/rm.rb index ed60d339..9ad226b3 100644 --- a/levels/rm.rb +++ b/levels/rm.rb @@ -1,11 +1,12 @@ difficulty 2 -description "A file has been removed from the working tree, however the file was not removed from the repository. Find out what this file was and remove it." +description "A file has been removed from the working tree, but not from the repository. Identify this file was and remove it." setup do repo.init file = File.new("deleteme.rb", "w") - file.close + file.close + system "git branch -m master" repo.add("deleteme.rb") repo.commit_all("Added a temp file") File.delete("deleteme.rb") @@ -16,5 +17,7 @@ end hint do - puts ["You may need to use more than one command to complete this.", "You have checked your staging area in a previous level.", "Don't forget to run `git` for a list of commands."] + puts ["You may need to use more than one command to complete this.", + "You have checked your staging area in a previous level.", + "Don't forget to run `git` for a list of commands."] end From 8b8da755862a87b849371943aaac81acc9edc6d4 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:50:46 +0200 Subject: [PATCH 069/115] fix(rm_cached.rb): explicitly defbe branch as master Explicitly define the principal branch as master. Light edit of the description about the task ahead. Signed-off-by: Norwid Behrnd --- levels/rm_cached.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/levels/rm_cached.rb b/levels/rm_cached.rb index 3487523a..e9686770 100644 --- a/levels/rm_cached.rb +++ b/levels/rm_cached.rb @@ -1,10 +1,11 @@ difficulty 2 -description "A file has accidentally been added to your staging area, find out which file and remove it from the staging area. *NOTE* Do not remove the file from the file system, only from git." +description "A file has accidentally been added to your staging area. Identify and remove it from the staging area. *NOTE* Do not remove the file from the file system, only from git." setup do repo.init FileUtils.touch("deleteme.rb") + system "git branch -m master" repo.add(".gitignore") repo.add("deleteme.rb") end From e06a1a5cd49bab5e17425989e008bd6da74bdc58 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:52:14 +0200 Subject: [PATCH 070/115] fix(stash.rb): explicitly define branch as master Signed-off-by: Norwid Behrnd --- levels/stash.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/stash.rb b/levels/stash.rb index 857eebbb..ee83201e 100644 --- a/levels/stash.rb +++ b/levels/stash.rb @@ -3,6 +3,7 @@ setup do init_from_level + system "git branch -m master" end solution do From 95a6041f975284b40a5b22f44fcdcfb2f8daebc2 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:53:42 +0200 Subject: [PATCH 071/115] fix(rename.rb): explicitly define branch as master Signed-off-by: Norwid Behrnd --- levels/rename.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/rename.rb b/levels/rename.rb index 38b6d415..b88ea018 100644 --- a/levels/rename.rb +++ b/levels/rename.rb @@ -7,6 +7,7 @@ FileUtils.touch("oldfile.txt") repo.add("oldfile.txt") repo.commit_all("Commited oldfile.txt") + system "git branch -m master" end solution do From 7d4cdaf409259c1539a5267311348a300341f70c Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:56:20 +0200 Subject: [PATCH 072/115] fix(restructure.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/restructure.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/levels/restructure.rb b/levels/restructure.rb index ccab8d2e..685800f3 100644 --- a/levels/restructure.rb +++ b/levels/restructure.rb @@ -13,6 +13,8 @@ repo.add("contact.html") repo.add("index.html") + system "git branch -m master" + repo.commit_all("adding web content.") end From 1852203c26a44bc090149fc1dcebb650dc3631b0 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 21:59:30 +0200 Subject: [PATCH 073/115] fix(log.rb): explicitly use master branch Explicitly define the principal branch as master. Light edit of the description of the task ahead. Signed-off-by: Norwid Behrnd --- levels/log.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/levels/log.rb b/levels/log.rb index d2615d6a..fbd8b799 100644 --- a/levels/log.rb +++ b/levels/log.rb @@ -1,12 +1,13 @@ difficulty 2 -description "Find out what the hash of the latest commit is." +description "Identify the hash of the latest commit." setup do repo.init file = File.new("newfile.rb", "w") repo.add("newfile.rb") repo.commit_all("THIS IS THE COMMIT YOU ARE LOOKING FOR!") + system "git branch -m master" end solution do From e713bbf5dfc86a1b9993ce689bd53d73df051fee Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:00:46 +0200 Subject: [PATCH 074/115] fix(tag.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/tag.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/tag.rb b/levels/tag.rb index ad614a16..139340c9 100644 --- a/levels/tag.rb +++ b/levels/tag.rb @@ -7,6 +7,7 @@ FileUtils.touch("somefile.txt") repo.add("somefile.txt") repo.commit_all("Added some file to the repo") + system "git branch -m master" end solution do From 665d912a4c84a4ab8ca68c38a3027fd73f51c47e Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:03:26 +0200 Subject: [PATCH 075/115] fix(push_tags.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/push_tags.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/push_tags.rb b/levels/push_tags.rb index ca0cdf9d..cad75dd8 100644 --- a/levels/push_tags.rb +++ b/levels/push_tags.rb @@ -14,6 +14,7 @@ repo.add "file1" repo.commit_all "First commit" repo.git.tag({'f' => true}, "tag_to_be_pushed") + system "git branch -m master" FileUtils.touch "file2" repo.add "file2" From ef73a39a9b21470a83fa8f85581e362f20542ec9 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:04:50 +0200 Subject: [PATCH 076/115] fix(commit_amend.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/commit_amend.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/commit_amend.rb b/levels/commit_amend.rb index fe4c7757..2a265116 100644 --- a/levels/commit_amend.rb +++ b/levels/commit_amend.rb @@ -7,6 +7,7 @@ repo.add("README") repo.commit_all("Initial commit") FileUtils.touch("forgotten_file.rb") + system "git branch -m master" end solution do From d6c9656e8711659a525183e935e7f528aa4818d9 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:05:55 +0200 Subject: [PATCH 077/115] fix(commit_in_future.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/commit_in_future.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/commit_in_future.rb b/levels/commit_in_future.rb index da5079c0..f614b6c2 100644 --- a/levels/commit_in_future.rb +++ b/levels/commit_in_future.rb @@ -8,6 +8,7 @@ FileUtils.touch("README") repo.add("README") + system "git branch -m master" end solution do From aca9f705a5989610d7ea0c37459f7845ccd8418b Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:07:29 +0200 Subject: [PATCH 078/115] fix(reset.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/reset.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/reset.rb b/levels/reset.rb index e1dcee8d..fd74d815 100644 --- a/levels/reset.rb +++ b/levels/reset.rb @@ -9,6 +9,7 @@ FileUtils.touch("to_commit_first.rb") FileUtils.touch("to_commit_second.rb") repo.add(".") + system "git branch -m master" end solution do From 158e6e6abf1a279144d1cfffdb3763321cea0683 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:08:47 +0200 Subject: [PATCH 079/115] fix(reset_soft.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/reset_soft.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/reset_soft.rb b/levels/reset_soft.rb index 8b5bf9f5..6d6d7e0e 100644 --- a/levels/reset_soft.rb +++ b/levels/reset_soft.rb @@ -9,6 +9,7 @@ FileUtils.touch("newfile.rb") repo.add("newfile.rb") repo.commit_all("Premature commit") + system "git branch -m master" end solution do From b7648b85408556cc3617a01acb337281a7a96761 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:10:20 +0200 Subject: [PATCH 080/115] fix(checkout_file.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/checkout_file.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/checkout_file.rb b/levels/checkout_file.rb index 848ef1a4..6a233538 100644 --- a/levels/checkout_file.rb +++ b/levels/checkout_file.rb @@ -14,6 +14,7 @@ File.open("config.rb", "a") do |file| file.puts("These are changed you don't want to keep!") end + system "git branch -m master" end solution do From c44ebdd7482848f24e4610946533b880cff2b5dd Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:11:22 +0200 Subject: [PATCH 081/115] fix(remote.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/remote.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/remote.rb b/levels/remote.rb index 74520a95..9b42fe81 100644 --- a/levels/remote.rb +++ b/levels/remote.rb @@ -5,6 +5,7 @@ setup do repo.init repo.remote_add("my_remote_repo", "https://github.com/Gazler/githug") + system "git branch -m master" end solution do From 285fdb9c1f7a206004ed727f743a50a509c05471 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:12:41 +0200 Subject: [PATCH 082/115] fix(remote_url.rb): explicitly use master branch Signed-off-by: Norwid Behrnd --- levels/remote_url.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/remote_url.rb b/levels/remote_url.rb index 128c792c..43327ec7 100644 --- a/levels/remote_url.rb +++ b/levels/remote_url.rb @@ -6,6 +6,7 @@ repo.init repo.remote_add("my_remote_repo", "https://github.com/Gazler/githug") repo.remote_add("remote_location", "https://github.com/githug/not_a_repo") + system "git branch -m master" end solution do From 321c67eda9bd6f6adbc01bd4f0dd6e49c43e9121 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:16:01 +0200 Subject: [PATCH 083/115] fix(pull.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/pull.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/pull.rb b/levels/pull.rb index ef0d1d07..9a362e78 100644 --- a/levels/pull.rb +++ b/levels/pull.rb @@ -5,6 +5,7 @@ setup do repo.init repo.remote_add("origin", "https://github.com/pull-this/thing-to-pull") + system "git branch -m master" end solution do From 8fe0c5e6440799fcd549e1cfa61e713577bb2359 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Wed, 17 Apr 2024 22:17:01 +0200 Subject: [PATCH 084/115] fix(remote_add.rb): explicitly use branch master Signed-off-by: Norwid Behrnd --- levels/remote_add.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/remote_add.rb b/levels/remote_add.rb index a47ca08b..630fdfb5 100644 --- a/levels/remote_add.rb +++ b/levels/remote_add.rb @@ -4,6 +4,7 @@ setup do repo.init + system "git branch -m master" end solution do From 593e9729253dc39bfd95ccd8cff42e6dc77ded49 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Thu, 18 Apr 2024 22:07:30 +0200 Subject: [PATCH 085/115] fix(push.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/push.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/levels/push.rb b/levels/push.rb index af92120d..b6ff105e 100644 --- a/levels/push.rb +++ b/levels/push.rb @@ -28,6 +28,7 @@ FileUtils.touch "file3" repo.add "file3" repo.commit_all "Third commit" + system "git branch -m master" # remote repo Dir.chdir tmpdir @@ -39,6 +40,7 @@ FileUtils.touch "file4" repo.add "file4" repo.commit_all "Fourth commit" + system "git branch -m master" # tentative addition # change back to original repo to set up a remote Dir.chdir cwd From 400359ff1b9663812a4a760f52eb45fe297c4b54 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Thu, 18 Apr 2024 22:08:50 +0200 Subject: [PATCH 086/115] fix(diff.rb): explicitly use branch master Signed-off-by: Norwid Behrnd --- levels/diff.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/levels/diff.rb b/levels/diff.rb index 0cb7ac26..3c01a100 100644 --- a/levels/diff.rb +++ b/levels/diff.rb @@ -1,8 +1,9 @@ difficulty 2 -description "There have been modifications to the `app.rb` file since your last commit. Find out which line has changed." +description "Since your last commit, file `app.rb` was modified. Find out which line has changed." setup do init_from_level + system "git branch -m master" end solution do From 7efd6050d0f9ab2d3a69a7fbf72f8ef5ab8bbd03 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Thu, 18 Apr 2024 22:11:44 +0200 Subject: [PATCH 087/115] fix(blame.rb): explicitly use branch master Signed-off-by: Norwid Behrnd --- levels/blame.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/levels/blame.rb b/levels/blame.rb index 2adde08a..332d2d34 100644 --- a/levels/blame.rb +++ b/levels/blame.rb @@ -1,8 +1,9 @@ difficulty 2 -description "Someone has put a password inside the file `config.rb` find out who it was." +description "Identify who put a password inside the file `config.rb`." setup do init_from_level + system "git branch -m master" end solution do From 605c2e1b5c1dbac6548b88df019b3265e81c8d00 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Thu, 18 Apr 2024 22:14:26 +0200 Subject: [PATCH 088/115] fix(branch.rb): explicitly use branch master Signed-off-by: Norwid Behrnd --- levels/branch.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/levels/branch.rb b/levels/branch.rb index 7d20fa3d..93b184ff 100644 --- a/levels/branch.rb +++ b/levels/branch.rb @@ -1,11 +1,12 @@ difficulty 1 -description "You want to work on a piece of code that has the potential to break things, create the branch test_code." +description "To work on a piece of code that has the potential to break things, create the branch test_code." setup do repo.init FileUtils.touch("README") repo.add "README" repo.commit_all("Initial commit") + system "git branch -m master" end solution do From 2f0141b56804710eb9f4cc3ad4f3281685d1f763 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Thu, 18 Apr 2024 22:15:32 +0200 Subject: [PATCH 089/115] fix(checkout.rb): explicitly use branch master Signed-off-by: Norwid Behrnd --- levels/checkout.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/checkout.rb b/levels/checkout.rb index 67301010..471db55d 100644 --- a/levels/checkout.rb +++ b/levels/checkout.rb @@ -6,6 +6,7 @@ FileUtils.touch("README") repo.add("README") repo.commit_all("initial commit") + system "git branch -m master" end solution do From 1ebef486a073232ab7524d5d7ec1f9c479161b9e Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:21:11 +0200 Subject: [PATCH 090/115] fix(checkout_tag.rb): explicitly use branch master Signed-off-by: Norwid Behrnd --- levels/checkout_tag.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/levels/checkout_tag.rb b/levels/checkout_tag.rb index 8e571b11..e06164d6 100644 --- a/levels/checkout_tag.rb +++ b/levels/checkout_tag.rb @@ -26,6 +26,8 @@ repo.add("app.rb") repo.commit_all("Changes galore") repo.git.tag( { 'f' => true }, "v1.5" ) + + system "git branch -m master" end solution do From 1183c19146fe81e25cb5bd9e75e7d364e248d4bb Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:24:51 +0200 Subject: [PATCH 091/115] fix(checkout_tag_over_branch.rb): explicitly use branch master Signed-off-by: Norwid Behrnd --- levels/checkout_tag_over_branch.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/checkout_tag_over_branch.rb b/levels/checkout_tag_over_branch.rb index 3a6c89a5..3b87bcc1 100644 --- a/levels/checkout_tag_over_branch.rb +++ b/levels/checkout_tag_over_branch.rb @@ -7,6 +7,7 @@ FileUtils.touch("app.rb") repo.add("app.rb") repo.commit_all("Initial commit") + system "git branch -m master" `echo "Some code" >> app.rb` repo.add("app.rb") From 1c7367361db47efdfa0efb60f1a18fa4c8098c09 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:26:07 +0200 Subject: [PATCH 092/115] fix(branch_at.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/branch_at.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/branch_at.rb b/levels/branch_at.rb index 00bdba27..d3757232 100644 --- a/levels/branch_at.rb +++ b/levels/branch_at.rb @@ -12,6 +12,7 @@ File.open("file1", 'a') { |f| f.write("\nAdding some more text") } repo.add("file1") repo.commit_all("Updating file1 again") + system "git branch -m master" end solution do From e1172dd4087f5bb668446f59f192d61365d6a134 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:27:57 +0200 Subject: [PATCH 093/115] fix(delete_branch.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/delete_branch.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/levels/delete_branch.rb b/levels/delete_branch.rb index 8f579adc..9c9bb683 100644 --- a/levels/delete_branch.rb +++ b/levels/delete_branch.rb @@ -3,7 +3,8 @@ description "You have created too many branches for your project. There is an old branch in your repo called 'delete_me', you should delete it." setup do - init_from_level + init_from_level + system "git branch -m master" end solution do @@ -12,4 +13,4 @@ hint do puts "Running 'git --help branch' will give you a list of branch commands." -end \ No newline at end of file +end From 1d343495f74355f787873f951030c1da2e385b04 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:28:54 +0200 Subject: [PATCH 094/115] fix(push_branch.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/push_branch.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/push_branch.rb b/levels/push_branch.rb index 0a5ac8ee..bff9bdb5 100644 --- a/levels/push_branch.rb +++ b/levels/push_branch.rb @@ -14,6 +14,7 @@ FileUtils.touch "file1" repo.add "file1" repo.commit_all "committed changes on master" + system "git branch -m master" # copy the repo to remote FileUtils.cp_r ".", tmpdir From 13dfbf7000679d0f97df51b542fc17f3c47ee760 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:30:16 +0200 Subject: [PATCH 095/115] fix(merge.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/merge.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/levels/merge.rb b/levels/merge.rb index 73cdba38..e84412ff 100644 --- a/levels/merge.rb +++ b/levels/merge.rb @@ -1,12 +1,13 @@ difficulty 2 -description "We have a file in the branch 'feature'; Let's merge it to the master branch." +description "We have a file in the branch 'feature'. Let's merge it with the master branch." setup do - init_from_level + init_from_level + system "git branch -m master" end solution do - File.exists?("file1") && File.exists?("file2") + File.exists?("file1") && File.exists?("file2") end hint do From cd36f76e865ef59cfc79c474b31776aa46587aaf Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:31:21 +0200 Subject: [PATCH 096/115] fix(fetch.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/fetch.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/levels/fetch.rb b/levels/fetch.rb index 2b39013b..51372c08 100644 --- a/levels/fetch.rb +++ b/levels/fetch.rb @@ -9,6 +9,7 @@ # local repo repo.init + system "git branch -m master" # adds a file to origin/master FileUtils.touch "master_file" @@ -51,16 +52,16 @@ # after a git fetch command, each branch will be stored in in the .git/FETCH_HEAD file. Each branch is on its own line # This command will count the number of lines, which will give the number of branches if File.file?('.git/FETCH_HEAD') # checks for file existence - num_remote = File.read(".git/FETCH_HEAD").split("\n").count + num_remote = File.read(".git/FETCH_HEAD").split("\n").count else - num_remote = 0 + num_remote = 0 end # there should be 1 local branch and 2 remote branches for a success condition if local_branches == 1 and num_remote == 2 - result = true + result = true else - result = false + result = false end end From 59fc03869622975ca8c2526e3d790f0457f4522b Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:32:18 +0200 Subject: [PATCH 097/115] fix(rebase.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/rebase.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/rebase.rb b/levels/rebase.rb index fadfd30b..b442894b 100644 --- a/levels/rebase.rb +++ b/levels/rebase.rb @@ -4,6 +4,7 @@ setup do init_from_level + system "git branch -m master" end solution do From 347174c9484e2068fb9267c0672299fd077c3913 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:33:27 +0200 Subject: [PATCH 098/115] fix(rebase_onto.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/rebase_onto.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/rebase_onto.rb b/levels/rebase_onto.rb index e5043ef2..baa78230 100644 --- a/levels/rebase_onto.rb +++ b/levels/rebase_onto.rb @@ -13,6 +13,7 @@ File.open(authors_file, "w") { |f| f << "https://github.com/janis-vitols\n" } repo.add(authors_file) repo.commit_all("Create authors file") + system "git branch -m master" repo.git.native :checkout, { "b" => true }, "wrong_branch" File.open(authors_file, "w") { |f| f << "None\n" } From 9df68f0091eeb2dda04784308922c43178163c91 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:34:36 +0200 Subject: [PATCH 099/115] fix(repack.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/repack.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/repack.rb b/levels/repack.rb index c367474a..0dfd283d 100644 --- a/levels/repack.rb +++ b/levels/repack.rb @@ -6,6 +6,7 @@ FileUtils.touch("foo") repo.add("foo") repo.commit_all("Added foo") + system "git branch -m master" end solution do From acf36119010f00246405d6d19cae1b85fe2cce08 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:35:42 +0200 Subject: [PATCH 100/115] fix(cherry-pick.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/cherry-pick.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/levels/cherry-pick.rb b/levels/cherry-pick.rb index 96acc4e0..19166332 100644 --- a/levels/cherry-pick.rb +++ b/levels/cherry-pick.rb @@ -2,8 +2,9 @@ description "Your new feature isn't worth the time and you're going to delete it. But it has one commit that fills in `README` file, and you want this commit to be on the master as well." setup do - init_from_level - `git stash` # fix for README.md being in githug root an the level + init_from_level + `git stash` # fix for README.md being in githug root an the level + system "git branch -m master" end solution do From 9c6e46f5b2cf03cb8d06367eb36f32cb0885973f Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:36:42 +0200 Subject: [PATCH 101/115] fix(grep.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/grep.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/grep.rb b/levels/grep.rb index cc312dc3..a508210b 100644 --- a/levels/grep.rb +++ b/levels/grep.rb @@ -3,6 +3,7 @@ setup do init_from_level + system "git branch -m master" end solution do From c932283fa57c04e700a175593c8be82550c13015 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:37:40 +0200 Subject: [PATCH 102/115] fix(rename_commit.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/rename_commit.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/rename_commit.rb b/levels/rename_commit.rb index 4c8ecd93..67820f7d 100644 --- a/levels/rename_commit.rb +++ b/levels/rename_commit.rb @@ -6,6 +6,7 @@ FileUtils.touch "README" repo.add "README" repo.commit_all "Initial commit" + system "git branch -m master" FileUtils.touch "file1" repo.add "file1" From 9958594147fc0b6f0e709bf129d07e72fc70af1b Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:38:31 +0200 Subject: [PATCH 103/115] fix(squash.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/squash.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/squash.rb b/levels/squash.rb index 1848425b..35a4c047 100644 --- a/levels/squash.rb +++ b/levels/squash.rb @@ -6,6 +6,7 @@ FileUtils.touch(".hidden") repo.add(".hidden") repo.commit_all("Initial Commit") + system "git branch -m master" FileUtils.touch("README") repo.add("README") repo.commit_all("Adding README") From 6eb67dc06b1e7b9b10d71f89c8ace5b6e8bca4a8 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:39:28 +0200 Subject: [PATCH 104/115] fix(merge_squash.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/merge_squash.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/merge_squash.rb b/levels/merge_squash.rb index d0eb8b04..4eb93e60 100644 --- a/levels/merge_squash.rb +++ b/levels/merge_squash.rb @@ -7,6 +7,7 @@ FileUtils.touch "file1" repo.add "file1" repo.commit_all "First commit" + system "git branch -m master" repo.git.native :checkout, {"b" => true}, 'long-feature-branch' File.open("file3", 'w') { |f| f << "some feature\n" } From b576c5bf94f92fa56d54fb9e87011656c7488baa Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:40:15 +0200 Subject: [PATCH 105/115] fix(reorder.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/reorder.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/reorder.rb b/levels/reorder.rb index 7f247dd2..6b3fb3ff 100644 --- a/levels/reorder.rb +++ b/levels/reorder.rb @@ -7,6 +7,7 @@ FileUtils.touch "README" repo.add "README" repo.commit_all "Initial Setup" + system "git branch -m master" FileUtils.touch "file1" repo.add "file1" From 275c6ad779cd9c4b3d2d9299498931d85613f9d6 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:41:21 +0200 Subject: [PATCH 106/115] fix(bisect.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/bisect.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/levels/bisect.rb b/levels/bisect.rb index 49608bb8..62942de6 100644 --- a/levels/bisect.rb +++ b/levels/bisect.rb @@ -1,9 +1,10 @@ difficulty 3 -description "A bug was introduced somewhere along the way. You know that running `ruby prog.rb 5` should output 15. You can also run `make test`. What are the first 7 chars of the hash of the commit that introduced the bug." +description "A bug was introduced somewhere along the way. You know that running `ruby prog.rb 5` should output 15. You can also run `make test`. What are the first 7 chars of the hash of the commit (the abbreviated hash) that introduced the bug?" setup do init_from_level repo.init + system "git branch -m master" end solution do From 8a15a16d254ba8370057cf799b0aeb534f587322 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:42:27 +0200 Subject: [PATCH 107/115] fix(stage_lines.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/stage_lines.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/stage_lines.rb b/levels/stage_lines.rb index 2c49c652..07787770 100644 --- a/levels/stage_lines.rb +++ b/levels/stage_lines.rb @@ -7,6 +7,7 @@ File.open("feature.rb", "w") do |file| file.puts("this is the class of my feature") end + system "git branch -m master" repo.add("feature.rb") repo.commit_all("Added initial feature file") From eb7c0078d9ccda833ef167484291309a538a39a7 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:43:38 +0200 Subject: [PATCH 108/115] fix(find_old_branch.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/find_old_branch.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/find_old_branch.rb b/levels/find_old_branch.rb index f195f68e..64a24206 100644 --- a/levels/find_old_branch.rb +++ b/levels/find_old_branch.rb @@ -3,6 +3,7 @@ setup do init_from_level + system "git branch -m master" end solution do From 09fbafd4bc1380ac3c74a9c1e950e95323c49dea Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:44:27 +0200 Subject: [PATCH 109/115] fix(revert.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/revert.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/revert.rb b/levels/revert.rb index da123c5c..65e0969c 100644 --- a/levels/revert.rb +++ b/levels/revert.rb @@ -7,6 +7,7 @@ FileUtils.touch "file1" repo.add "file1" repo.commit_all "First commit" + system "git branch -m master" FileUtils.touch "file3" repo.add "file3" From 9b9a0a32a491d04813f807fc7a84945d0e5061b9 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:45:24 +0200 Subject: [PATCH 110/115] fix(restore.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/restore.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/restore.rb b/levels/restore.rb index a1f93e29..afd70537 100644 --- a/levels/restore.rb +++ b/levels/restore.rb @@ -6,6 +6,7 @@ FileUtils.touch 'file1' repo.add 'file1' repo.commit_all 'Initial commit' + system "git branch -m master" FileUtils.touch 'file2' repo.add 'file2' From 675fac281275c84ffe833fd4053c33c21d2c98f0 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:46:37 +0200 Subject: [PATCH 111/115] fix(conflict.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/conflict.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/levels/conflict.rb b/levels/conflict.rb index 7c0ac0d4..aa20f370 100644 --- a/levels/conflict.rb +++ b/levels/conflict.rb @@ -3,6 +3,7 @@ setup do init_from_level + system "git branch -m master" end solution do From 33fcbc581b18df58c63b63ab82f1e5b8b547df8f Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 18:47:45 +0200 Subject: [PATCH 112/115] fix(submodule.rb): explicitly run branch master Signed-off-by: Norwid Behrnd --- levels/submodule.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/levels/submodule.rb b/levels/submodule.rb index 9a7a60ec..c70f44ce 100644 --- a/levels/submodule.rb +++ b/levels/submodule.rb @@ -2,19 +2,20 @@ description "You want to include the files from the following repo: `https://github.com/jackmaney/githug-include-me` into the folder `./githug-include-me`. Do this without manually cloning the repo or copying the files from the repo into this repo." setup do - repo.init + repo.init + system "git branch -m master" end solution do - return false if not File.directory?("./githug-include-me") - return false if not File.exist?("./githug-include-me/README.md") - return false if not File.exist?("./githug-include-me/.git") - return false if File.directory?("./githug-include-me/.git") - return false if not File.exist?(".gitmodules") + return false if not File.directory?("./githug-include-me") + return false if not File.exist?("./githug-include-me/README.md") + return false if not File.exist?("./githug-include-me/.git") + return false if File.directory?("./githug-include-me/.git") + return false if not File.exist?(".gitmodules") - return true + return true end hint do - puts "Take a look at `git submodule`." + puts "Take a look at `git submodule`." end From dcbe5d3e85032ccdd393795ea1f5098f6ddf5d05 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 20:40:23 +0200 Subject: [PATCH 113/115] style(rm.rb): edit internal task description Signed-off-by: Norwid Behrnd --- levels/rm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/rm.rb b/levels/rm.rb index 9ad226b3..3edfd609 100644 --- a/levels/rm.rb +++ b/levels/rm.rb @@ -1,6 +1,6 @@ difficulty 2 -description "A file has been removed from the working tree, but not from the repository. Identify this file was and remove it." +description "A file has been removed from the working tree, but not from the repository. Identify this file and remove it." setup do repo.init From 1266b29fd710be62568d0b587b24e9850867d760 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Sun, 21 Apr 2024 20:40:55 +0200 Subject: [PATCH 114/115] style(push_tags.rb): edit internal task description Signed-off-by: Norwid Behrnd --- levels/push_tags.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/push_tags.rb b/levels/push_tags.rb index cad75dd8..68a6875c 100644 --- a/levels/push_tags.rb +++ b/levels/push_tags.rb @@ -1,5 +1,5 @@ difficulty 2 -description "There are tags in the repository that aren't pushed into remote repository. Push them now." +description "A tag in the local repository isn't pushed into remote repository. Push it now." setup do # remember the working directory so we can come back to it later From a613718f56256e785301a9d9c0b400ac84c47166 Mon Sep 17 00:00:00 2001 From: Gary Rennie Date: Sun, 11 Aug 2024 19:24:45 +0100 Subject: [PATCH 115/115] release: 0.5.1 --- githug.gemspec | 2 +- lib/githug/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/githug.gemspec b/githug.gemspec index 7e604857..89de26a2 100644 --- a/githug.gemspec +++ b/githug.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = "githug" s.version = Githug::VERSION s.authors = ["Gary Rennie"] - s.email = ["webmaster@gazler.com"] + s.email = ["gazler@gmail.com"] s.homepage = "https://github.com/Gazler/githug" s.summary = %q{An interactive way to learn git.} s.description = %q{An interactive way to learn git.} diff --git a/lib/githug/version.rb b/lib/githug/version.rb index 94a7696c..ea4fecfe 100644 --- a/lib/githug/version.rb +++ b/lib/githug/version.rb @@ -1,3 +1,3 @@ module Githug - VERSION = "0.5.0" + VERSION = "0.5.1" end