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] 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